本文整理汇总了Python中webnotes.utils.flt函数的典型用法代码示例。如果您正苦于以下问题:Python flt函数的具体用法?Python flt怎么用?Python flt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_requested_items
def get_requested_items(self):
item_projected_qty = self.get_projected_qty()
items_to_be_requested = webnotes._dict()
for item, so_item_qty in self.item_dict.items():
requested_qty = 0
total_qty = sum([flt(d[0]) for d in so_item_qty])
if total_qty > item_projected_qty.get(item, 0):
# shortage
requested_qty = total_qty - item_projected_qty.get(item, 0)
# consider minimum order qty
requested_qty = requested_qty > flt(so_item_qty[0][3]) and \
requested_qty or flt(so_item_qty[0][3])
# distribute requested qty SO wise
for item_details in so_item_qty:
if requested_qty:
sales_order = item_details[4] or "No Sales Order"
if requested_qty <= item_details[0]:
adjusted_qty = requested_qty
else:
adjusted_qty = item_details[0]
items_to_be_requested.setdefault(item, {}).setdefault(sales_order, 0)
items_to_be_requested[item][sales_order] += adjusted_qty
requested_qty -= adjusted_qty
else:
break
# requested qty >= total so qty, due to minimum order qty
if requested_qty:
items_to_be_requested.setdefault(item, {}).setdefault("No Sales Order", 0)
items_to_be_requested[item]["No Sales Order"] += requested_qty
return items_to_be_requested
示例2: get_leave_balance
def get_leave_balance(self):
leave_all = sql("select total_leaves_allocated from `tabLeave Allocation` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
leave_all = leave_all and flt(leave_all[0][0]) or 0
leave_app = sql("select SUM(total_leave_days) from `tabLeave Application` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
leave_app = leave_app and flt(leave_app[0][0]) or 0
ret = {'leave_balance':leave_all - leave_app}
return ret
示例3: get_balance
def get_balance(self):
if not getlist(self.doclist,'entries'):
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
else:
flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0
diff = flt(self.doc.difference, 2)
# If any row without amount, set the diff on that row
for d in getlist(self.doclist,'entries'):
if not d.credit and not d.debit and diff != 0:
if diff>0:
d.credit = diff
elif diff<0:
d.debit = diff
flag = 1
# Set the diff in a new row
if flag == 0 and diff != 0:
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
if diff>0:
jd.credit = abs(diff)
elif diff<0:
jd.debit = abs(diff)
# Set the total debit, total credit and difference
for d in getlist(self.doclist,'entries'):
self.doc.total_debit += flt(d.debit, 2)
self.doc.total_credit += flt(d.credit, 2)
self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2)
示例4: add_charges_in_pr
def add_charges_in_pr(self):
""" Add additional charges in selected pr proportionately"""
total_amt = self.get_total_amt()
for pr in self.selected_pr:
pr_obj = get_obj('Purchase Receipt', pr, with_children = 1)
cumulative_grand_total = flt(pr_obj.doc.grand_total)
for lc in getlist(self.doclist, 'landed_cost_details'):
amt = flt(lc.amount) * flt(pr_obj.doc.net_total)/ flt(total_amt)
self.prwise_cost[pr] = self.prwise_cost.get(pr, 0) + amt
cumulative_grand_total += amt
pr_oc_row = sql("select name from `tabPurchase Taxes and Charges` where parent = %s and category = 'Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s",(pr, lc.account_head))
if not pr_oc_row: # add if not exists
ch = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1)
ch.category = 'Valuation'
ch.add_deduct_tax = 'Add'
ch.charge_type = 'Actual'
ch.description = lc.description
ch.account_head = lc.account_head
ch.rate = amt
ch.tax_amount = amt
ch.total = cumulative_grand_total
ch.docstatus = 1
ch.idx = 500 # add at the end
ch.save(1)
else: # overwrite if exists
sql("update `tabPurchase Taxes and Charges` set rate = %s, tax_amount = %s where name = %s and parent = %s ", (amt, amt, pr_oc_row[0][0], pr))
示例5: update_against_document_in_jv
def update_against_document_in_jv(self):
"""
Links invoice and advance voucher:
1. cancel advance voucher
2. split into multiple rows if partially adjusted, assign against voucher
3. submit advance voucher
"""
lst = []
for d in getlist(self.doclist, 'advance_adjustment_details'):
if flt(d.allocated_amount) > 0:
args = {
'voucher_no' : d.journal_voucher,
'voucher_detail_no' : d.jv_detail_no,
'against_voucher_type' : 'Sales Invoice',
'against_voucher' : self.doc.name,
'account' : self.doc.debit_to,
'is_advance' : 'Yes',
'dr_or_cr' : 'credit',
'unadjusted_amt' : flt(d.advance_amount),
'allocated_amt' : flt(d.allocated_amount)
}
lst.append(args)
if lst:
get_obj('GL Control').reconcile_against_document(lst)
示例6: on_update
def on_update(self):
if cint(self.doc.update_stock) == 1:
# Set default warehouse from pos setting
if cint(self.doc.is_pos) == 1:
w = self.get_warehouse()
if w:
for d in getlist(self.doclist, 'entries'):
if not d.warehouse:
d.warehouse = cstr(w)
self.make_packing_list()
else:
self.doclist = self.doc.clear_table(self.doclist, 'packing_details')
if cint(self.doc.is_pos) == 1:
if flt(self.doc.paid_amount) == 0:
if self.doc.cash_bank_account:
webnotes.conn.set(self.doc, 'paid_amount',
(flt(self.doc.grand_total) - flt(self.doc.write_off_amount)))
else:
# show message that the amount is not paid
webnotes.conn.set(self.doc,'paid_amount',0)
webnotes.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
else:
webnotes.conn.set(self.doc,'paid_amount',0)
示例7: validate_max_discount
def validate_max_discount(self):
for d in self.doclist.get({"parentfield": self.fname}):
discount = flt(webnotes.conn.get_value("Item", d.item_code, "max_discount"))
if discount and flt(d.adj_rate) > discount:
webnotes.throw(_("You cannot give more than ") + cstr(discount) + "% " +
_("discount on Item Code") + ": " + cstr(d.item_code))
示例8: get_other_charges
def get_other_charges(self,obj, default=0):
obj.doclist = obj.doc.clear_table(obj.doclist, 'other_charges')
if not getlist(obj.doclist, 'other_charges'):
if default: add_cond = 'ifnull(t2.is_default,0) = 1'
else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
idx = 0
other_charge = webnotes.conn.sql("""\
select t1.*
from
`tabSales Taxes and Charges` t1,
`tabSales Taxes and Charges Master` t2
where
t1.parent = t2.name and
t2.company = '%s' and
%s
order by t1.idx""" % (obj.doc.company, add_cond), as_dict=1)
from webnotes.model import default_fields
for other in other_charge:
# remove default fields like parent, parenttype etc.
# from query results
for field in default_fields:
if field in other: del other[field]
d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges',
obj.doclist)
d.fields.update(other)
d.rate = flt(d.rate)
d.tax_amount = flt(d.tax_rate)
d.included_in_print_rate = cint(d.included_in_print_rate)
d.idx = idx
idx += 1
return obj.doclist
示例9: update_packing_list_item
def update_packing_list_item(self,obj, packing_item_code, qty, warehouse, line):
bin = self.get_bin_qty(packing_item_code, warehouse)
item = self.get_packing_item_details(packing_item_code)
# check if exists
exists = 0
for d in getlist(obj.doclist, 'packing_details'):
if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name:
pi, exists = d, 1
break
if not exists:
pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Item',
obj.doclist)
pi.parent_item = line.item_code
pi.item_code = packing_item_code
pi.item_name = item['item_name']
pi.parent_detail_docname = line.name
pi.description = item['description']
pi.uom = item['stock_uom']
pi.qty = flt(qty)
pi.actual_qty = bin and flt(bin['actual_qty']) or 0
pi.projected_qty = bin and flt(bin['projected_qty']) or 0
pi.prevdoc_doctype = line.prevdoc_doctype
if not pi.warehouse:
pi.warehouse = warehouse
if not pi.batch_no:
pi.batch_no = cstr(line.batch_no)
pi.idx = self.packing_list_idx
# saved, since this function is called on_update of delivery note
pi.save()
self.packing_list_idx += 1
示例10: validate_net_pay
def validate_net_pay(self):
if flt(self.doc.net_pay) < 0:
msgprint("Net pay can not be negative")
raise Exception
elif flt(self.doc.net_pay) > flt(self.doc.ctc):
msgprint("Net pay can not be greater than CTC")
raise Exception
示例11: get_available_qty
def get_available_qty(self,args):
tot_avail_qty = webnotes.conn.sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
ret = {
'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0,
'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0
}
return ret
示例12: get_workstation_details
def get_workstation_details(self,workstation):
ws = sql("select hour_rate, capacity from `tabWorkstation` where name = %s",workstation , as_dict = 1)
ret = {
'hour_rate' : ws and flt(ws[0]['hour_rate']) or '',
'workstation_capacity' : ws and flt(ws[0]['capacity']) or ''
}
return ret
示例13: validate_po_pr
def validate_po_pr(self, d):
# check po / pr for qty and rates and currency and conversion rate
# currency, import_rate must be equal to currency, import_rate of purchase order
if d.purchase_order and not d.purchase_order in self.po_list:
# currency
currency = cstr(sql("select currency from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0])
if not cstr(currency) == cstr(self.doc.currency):
msgprint("Purchase Order: " + cstr(d.purchase_order) + " currency : " + cstr(currency) + " does not match with currency of current document.")
raise Exception
# import_rate
rate = flt(sql('select import_rate from `tabPurchase Order Item` where item_code=%s and parent=%s and name = %s', (d.item_code, d.purchase_order, d.po_detail))[0][0])
if abs(rate - flt(d.import_rate)) > 1 and cint(get_defaults('maintain_same_rate')):
msgprint("Import Rate for %s in the Purchase Order is %s. Rate must be same as Purchase Order Rate" % (d.item_code,rate))
raise Exception
if d.purchase_receipt and not d.purchase_receipt in self.pr_list:
# currency , conversion_rate
data = sql("select currency, conversion_rate from `tabPurchase Receipt` where name = '%s'" % d.purchase_receipt, as_dict = 1)
if not cstr(data[0]['currency']) == cstr(self.doc.currency):
msgprint("Purchase Receipt: " + cstr(d.purchase_receipt) + " currency : " + cstr(data[0]['currency']) + " does not match with currency of current document.")
raise Exception
if not flt(data[0]['conversion_rate']) == flt(self.doc.conversion_rate):
msgprint("Purchase Receipt: " + cstr(d.purchase_receipt) + " conversion_rate : " + cstr(data[0]['conversion_rate']) + " does not match with conversion_rate of current document.")
raise Exception
示例14: get_outstanding
def get_outstanding(self, args):
args = eval(args)
o_s = sql("select outstanding_amount from `tab%s` where name = '%s'" % (args['doctype'],args['docname']))
if args['doctype'] == 'Purchase Invoice':
return {'debit': o_s and flt(o_s[0][0]) or 0}
if args['doctype'] == 'Sales Invoice':
return {'credit': o_s and flt(o_s[0][0]) or 0}
示例15: do_stock_reco
def do_stock_reco(self, is_submit = 1):
"""
Make stock entry of qty diff, calculate incoming rate to maintain valuation rate.
If no qty diff, but diff in valuation rate, make (+1,-1) entry to update valuation
"""
for row in self.data:
# Get qty as per system
sys_stock = self.get_system_stock(row[0],row[1])
# Diff between file and system
qty_diff = row[2] != '~' and flt(row[2]) - flt(sys_stock['actual_qty']) or 0
rate_diff = row[3] != '~' and flt(row[3]) - flt(sys_stock['val_rate']) or 0
# Make sl entry
if qty_diff:
self.make_sl_entry(is_submit, row, qty_diff, sys_stock)
elif rate_diff:
self.make_sl_entry(is_submit, row, 1, sys_stock)
sys_stock['val_rate'] = row[3]
sys_stock['actual_qty'] += 1
self.make_sl_entry(is_submit, row, -1, sys_stock)
if is_submit == 1:
self.add_data_in_CSV(qty_diff, rate_diff)
msgprint("Stock Reconciliation Completed Successfully...")