本文整理汇总了Python中webnotes.utils.flt函数的典型用法代码示例。如果您正苦于以下问题:Python flt函数的具体用法?Python flt怎么用?Python flt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:XWARIOSWX,项目名称:erpnext,代码行数:35,代码来源:production_planning_tool.py
示例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
开发者ID:antoxin,项目名称:erpnext,代码行数:7,代码来源:leave_application.py
示例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)
开发者ID:cocoy,项目名称:erpnext,代码行数:30,代码来源:journal_voucher.py
示例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))
开发者ID:trycatcher,项目名称:erpnext,代码行数:29,代码来源:landed_cost_wizard.py
示例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)
开发者ID:masums,项目名称:erpnext,代码行数:26,代码来源:sales_invoice.py
示例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)
开发者ID:rajatkapoor,项目名称:erpnext,代码行数:25,代码来源:sales_invoice.py
示例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))
开发者ID:Jdfkat,项目名称:erpnext,代码行数:7,代码来源:selling_controller.py
示例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
开发者ID:BillTheBest,项目名称:erpnext,代码行数:32,代码来源:sales_common.py
示例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
开发者ID:BillTheBest,项目名称:erpnext,代码行数:35,代码来源:sales_common.py
示例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
开发者ID:ravidey,项目名称:erpnext,代码行数:7,代码来源:salary_structure.py
示例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
开发者ID:BillTheBest,项目名称:erpnext,代码行数:7,代码来源:sales_common.py
示例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
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:7,代码来源:bill_of_materials.py
示例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
开发者ID:robertbecht,项目名称:erpnext,代码行数:25,代码来源:purchase_invoice.py
示例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}
开发者ID:arunemmanuel,项目名称:erpnext,代码行数:7,代码来源:journal_voucher.py
示例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...")
开发者ID:antoxin,项目名称:erpnext,代码行数:26,代码来源:stock_reconciliation.py
示例16: check_budget
def check_budget(self,le_list,cancel):
# get value from record
acct, cost_center, debit, credit, post_dt, cfy, company = le_list
# get allocated budget
bgt = sql("select t1.budget_allocated, t1.actual, t2.distribution_id from `tabBudget Detail` t1, `tabCost Center` t2 where t1.account='%s' and t1.parent=t2.name and t2.name = '%s' and t1.fiscal_year='%s'" % (acct,cost_center,cfy), as_dict =1)
curr_amt = ((cancel and -1 or 1) * flt(debit)) + ((cancel and 1 or -1) * flt(credit))
if bgt and bgt[0]['budget_allocated']:
# check budget flag in Company
bgt_flag = sql("select yearly_bgt_flag, monthly_bgt_flag from `tabCompany` where name = '%s'" % company, as_dict =1)
if bgt_flag and bgt_flag[0]['monthly_bgt_flag'] in ['Stop', 'Warn']:
# get start date and last date
st_date = get_value('Fiscal Year', cfy, 'year_start_date').strftime('%Y-%m-%d')
lt_date = sql("select LAST_DAY('%s')" % post_dt)
# get Actual
actual = get_obj('GL Control').get_period_difference(acct + '~~~' + cstr(st_date) + '~~~' + cstr(lt_date[0][0]), cost_center)
# Get Monthly budget
budget = self.get_monthly_budget(bgt and bgt[0]['distribution_id'] or '' , cfy, st_date, post_dt, bgt[0]['budget_allocated'])
# validate monthly budget
self.validate_budget(acct, cost_center, flt(actual) + flt(curr_amt), budget, 'monthly_bgt_flag')
# update actual against budget allocated in cost center
sql("update `tabBudget Detail` set actual = ifnull(actual,0) + %s where account = '%s' and fiscal_year = '%s' and parent = '%s'" % (curr_amt,cstr(acct),cstr(cfy),cstr(cost_center)))
开发者ID:Morphnus-IT-Solutions,项目名称:cimworks,代码行数:28,代码来源:budget_control.py
示例17: get_outstanding_amount
def get_outstanding_amount(self, gle, report_date):
payment_received = 0.0
for e in self.get_gl_entries_for(gle.account, gle.voucher_type, gle.voucher_no):
if getdate(e.posting_date) <= report_date and e.name!=gle.name:
payment_received += (flt(e.credit) - flt(e.debit))
return flt(gle.debit) - flt(gle.credit) - payment_received
开发者ID:Anirudh887,项目名称:erpnext,代码行数:7,代码来源:accounts_receivable.py
示例18: determine_exclusive_rate
def determine_exclusive_rate(self):
if not any((cint(tax.included_in_print_rate) for tax in self.tax_doclist)):
# no inclusive tax
return
for item in self.item_doclist:
item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
cumulated_tax_fraction = 0
for i, tax in enumerate(self.tax_doclist):
tax.tax_fraction_for_current_item = self.get_current_tax_fraction(tax, item_tax_map)
if i==0:
tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item
else:
tax.grand_total_fraction_for_current_item = \
self.tax_doclist[i-1].grand_total_fraction_for_current_item \
+ tax.tax_fraction_for_current_item
cumulated_tax_fraction += tax.tax_fraction_for_current_item
if cumulated_tax_fraction:
item.amount = flt((item.export_amount * self.doc.conversion_rate) /
(1 + cumulated_tax_fraction), self.precision("amount", item))
item.basic_rate = flt(item.amount / item.qty, self.precision("basic_rate", item))
if item.adj_rate == 100:
item.base_ref_rate = item.basic_rate
item.basic_rate = 0.0
else:
item.base_ref_rate = flt(item.basic_rate / (1 - (item.adj_rate / 100.0)),
self.precision("base_ref_rate", item))
开发者ID:Jdfkat,项目名称:erpnext,代码行数:32,代码来源:selling_controller.py
示例19: cal_charges_and_item_tax_amt
def cal_charges_and_item_tax_amt(self):
""" Re-calculates other charges values and itemwise tax amount for getting valuation rate"""
import json
for pr in self.selected_pr:
obj = get_obj('Purchase Receipt', pr, with_children = 1)
total = 0
self.reset_other_charges(obj)
for prd in getlist(obj.doclist, 'purchase_receipt_details'):
prev_total, item_tax = flt(prd.amount), 0
total += flt(prd.qty) * flt(prd.purchase_rate)
try:
item_tax_rate = prd.item_tax_rate and json.loads(prd.item_tax_rate) or {}
except ValueError:
item_tax_rate = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
ocd = getlist(obj.doclist, 'purchase_tax_details')
# calculate tax for other charges
for oc in range(len(ocd)):
# Get rate : consider if diff for this item
if item_tax_rate.get(ocd[oc].account_head) and ocd[oc].charge_type != 'Actual':
rate = item_tax_rate[ocd[oc].account_head]
else:
rate = flt(ocd[oc].rate)
tax_amount = self.cal_tax(ocd, prd, rate, obj.doc.net_total, oc)
total, prev_total, item_tax = self.add_deduct_taxes(ocd, oc, tax_amount, total, prev_total, item_tax)
prd.item_tax_amount = flt(item_tax)
prd.save()
obj.doc.save()
开发者ID:trycatcher,项目名称:erpnext,代码行数:33,代码来源:landed_cost_wizard.py
示例20: create_auto_indent
def create_auto_indent(self, i , doc_type, doc_name, cur_qty):
""" Create indent on reaching reorder level """
indent = Document('Purchase Request')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = "This is an auto generated Purchase Request. It was raised because the (actual + ordered + indented - reserved) quantity reaches re-order level when %s %s was created"%(doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item',0)
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse
indent_details_child.schedule_date= add_days(nowdate(),cint(i['lead_time_days']))
indent_details_child.item_name = i['item_name']
indent_details_child.description = i['description']
indent_details_child.item_group = i['item_group']
indent_details_child.qty = i['re_order_qty'] or (flt(i['re_order_level']) - flt(cur_qty))
indent_details_child.brand = i['brand']
indent_details_child.save()
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_obj.validate()
set(indent_obj.doc,'docstatus',1)
indent_obj.on_submit()
msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Purchase Request %s raised. It was generated from %s %s"%(indent.name,doc_type, doc_name ))
if(i['email_notify']):
send_email_notification(doc_type,doc_name)
开发者ID:NorrWing,项目名称:erpnext,代码行数:29,代码来源:bin.py
注:本文中的webnotes.utils.flt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论