本文整理汇总了Python中webnotes.model.doc.Document.cost_center方法的典型用法代码示例。如果您正苦于以下问题:Python Document.cost_center方法的具体用法?Python Document.cost_center怎么用?Python Document.cost_center使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.cost_center方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_advance_entry
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import cost_center [as 别名]
def create_advance_entry(advance_amount, customer_name, debit_to, company):
jv = Document('Journal Voucher')
jv.voucher_type = 'Cash Voucher'
jv.user_remark = 'Advance Payment'
jv.fiscal_year = webnotes.conn.get_value('Global Defaults',None,'current_fiscal_year')
jv.user_remark = "Advance from patient %s"%customer_name
jv.remark = "User Remark : Advance from patient %s"%customer_name
jv.company = company
jv.posting_date = nowdate()
jv.docstatus=1
jv.save()
chld1 = Document('Journal Voucher Detail')
chld1.parent = jv.name
chld1.account = debit_to
chld1.cost_center = webnotes.conn.get_value('Company',company,'cost_center')
chld1.credit = advance_amount
chld1.is_advance = 'Yes'
chld1.save()
chld2 = Document('Journal Voucher Detail')
chld2.parent = jv.name
chld2.account = webnotes.conn.get_value('Company',company,'default_cash_account')
chld2.cost_center = webnotes.conn.get_value('Company',company,'cost_center')
chld2.debit = advance_amount
chld2.save()
create_gl_entry(jv.name, jv.user_remark, company)
示例2: create_gl
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import cost_center [as 别名]
def create_gl(self,data):
for r in data:
gl=Document("GL Entry")
gl.account=r['account']
gl.debit=r['debit']
gl.credit=r['credit']
gl.against=r['against']
gl.against_voucher_type=r['against_voucher_type']
gl.voucher_type=r['voucher_type']
gl.against_voucher=r['against_voucher']
gl.voucher_no=r['voucher_no']
gl.cost_center=r['cost_center']
gl.posting_date=nowdate()
gl.aging_date=nowdate()
gl.fiscal_year=webnotes.conn.get_value("Global Defaults",None,"current_fiscal_year")
gl.company='InnoWorth'
gl.is_opening='No'
gl.save()
示例3: create_invoice
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import cost_center [as 别名]
def create_invoice(auth_key,invoice_type,customer,serial_number,dattime,_type='POST'):
login =[]
loginObj = {}
if len(auth_key[1:-1])<=0 or len(dattime[1:-1])<=0 or len(customer[1:-1])<=0 or len(serial_number[1:-1])<=0 :
loginObj['status']='401'
loginObj['error']='Incomplete data to generate Sales Invoice , Please provide token no , Datetime,customer and serial no'
return loginObj
qr="select name from `tabauth keys` where auth_key="+auth_key
res=webnotes.conn.sql(qr)
rgn=webnotes.conn.sql("select region from `tabFranchise` where contact_email='"+res[0][0]+"'")
zz=serial_number[1:-1].count(' ')
xx=serial_number[1:-1].replace('[','').split(' ')
#xxx=xx.replace(' ','\n')
yy="select item_code,item_name,description from `tabSerial No` where name='"+cstr(xx[0])+"'"
zzz=webnotes.conn.sql(yy)
if not zzz:
loginObj['status']='402'
loginObj['error']='Invalid serails no, please try againg'
return loginObj
pp="select ref_rate from `tabItem Price` where price_list='Standard Selling' and item_code='"+zzz[0][0]+"'"
ppp=webnotes.conn.sql(pp)
if res:
from webnotes.model.doc import Document
d = Document('Sales Invoice')
d.customer=customer[1:-1]
d.customer_name=customer[1:-1]
d.region=rgn[0][0]
d.posting_date=dattime[1:-1]
d.due_date=dattime[1:-1]
d.selling_price_list='Standard Selling'
d.currency='INR'
d.territory='India'
if ppp:
d.net_total_export=ppp[0][0]*zz
d.grand_total_export=ppp[0][0]*zz
d.rounded_total_export=ppp[0][0]*zz
d.outstanding_amount=ppp[0][0]*zz
d.plc_conversion_rate=1
from webnotes.utils import nowdate
from accounts.utils import get_fiscal_year
today = nowdate()
d.fiscal_year=get_fiscal_year(today)[0]
d.debit_to=customer[1:-1]+" - P"
d.is_pos=1
d.cash_bank_account='Cash - P'
d.save()
webnotes.conn.commit()
e=Document('Sales Invoice Item')
e.item_code=zzz[0][0]
e.item_name=zzz[0][1]
e.description=zzz[0][2]
e.qty=zz
e.stock_uom='Nos'
if ppp:
e.ref_rate=ppp[0][0]
e.export_rate=ppp[0][0]
e.export_amount='0'
e.income_account='Sales - P'
e.cost_center='Main - P'
e.serial_no_=serial_number[1:-1].replace('[','').replace(']','')
e.parent=d.name
e.parenttype='Sales Invoice'
e.parentfield='entries'
e.save()
webnotes.conn.commit()
key={}
key['invoice_id_id']=d.name
login.append(key)
loginObj['status']='200'
loginObj['invoice']=login
return loginObj
else:
loginObj['status']='401'
loginObj['error']='invalid token please contact administrator'
return loginObj
示例4: create_in
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import cost_center [as 别名]
#.........这里部分代码省略.........
#webnotes.errprint(g[:-2])
g1="update `tabSerial No` set warehouse='',delivery_date=CURDATE(),status='Delivered',customer='"+customer+"' where name='"+g[:-1]+"'"
webnotes.conn.sql(g1)
webnotes.conn.commit()
for hh in item_details:
h=hh['barcode']
g=h[:-2]
i="select item_code from `tabSerial No` where name='"+g+"'"
ii=webnotes.conn.sql(i)
qrt="select name from `tabauth keys` where auth_key='"+auth_key+"'"
res=webnotes.conn.sql(qrt)
net=0
if res:
a="select name from tabCustomer where name='"+customer+"'"
#webnotes.errprint(a)
b=webnotes.conn.sql(a)
#webnotes.errprint(b)
if b:
a=''
else:
#webnotes.errprint("else")
d = Document('Customer')
d.customer_name=customer
d.name=customer
d.save(new=1)
webnotes.conn.commit()
d = Document('Sales Invoice')
d.customer=customer
d.customer_name=customer
d.posting_date=dattime[1:-1]
d.due_date=dattime[1:-1]
d.selling_price_list='Standard Selling'
d.currency='INR'
d.territory=r1[0][0]
d.net_total_export=0
d.grand_total_export=0
d.rounded_total_export=0
d.plc_conversion_rate=1
d.region=r1[0][0]
from webnotes.utils import nowdate
from accounts.utils import get_fiscal_year
today = nowdate()
d.fiscal_year=get_fiscal_year(today)[0]
d.debit_to=customer[1:-1]+" - P"
d.is_pos=1
d.cash_bank_account='Cash - P'
d.save(new=1)
webnotes.conn.commit()
for x in qty_dict.keys():
e=Document('Sales Invoice Item')
e.item_code=x
e.item_name=x
e.description=x
e.qty=qty_dict[x]
e.stock_uom='Nos'
e.ref_rate=cint(rate_dict[x])/cint(qty_dict[x])
e.export_rate=cint(rate_dict[x])/cint(qty_dict[x])
e.export_amount=cint(rate_dict[x])
e.income_account='Sales - P'
e.cost_center='Main - P'
e.serial_no_=srl_dict[x]
e.parent=d.name
e.parenttype='Sales Invoice'
e.parentfield='entries'
e.save(new=1)
net+=cint(rate_dict[x])
qrs="select warranty_period from tabItem where name='"+x+"'"
#webnotes.errprint(qrs)
ress=webnotes.conn.sql(qrs)
#webnotes.errprint(ress[0][0])
if ress:
exdt=add_months(cstr(nowdate()),cint(ress[0][0]))
else:
exdt='null'
#webnotes.errprint(cstr(srl_dict[x]))
#webnotes.errprint(g)
g2="update `tabSerial No` set warehouse='', warranty_expiry_date='"+cstr(exdt)+"',delivery_date=CURDATE(),status='Delivered',customer='"+customer+"' where name='"+cstr(h[:-1])+"'"
#webnotes.errprint(g2)
#webnotes.errprint("in x in qty dict")
webnotes.conn.sql(g2)
webnotes.conn.commit()
d = Document('Sales Invoice',d.name)
d.net_total_export=net
d.net_total=net
d.grand_total_export=net
d.rounded_total_export=net
d.outstanding_amount=net
d.docstatus=1
d.save()
webnotes.conn.commit()
key={}
key['invoice_id']=d.name
login.append(key)
loginObj['status']='200'
loginObj['invoice']=login
return loginObj
else:
loginObj['status']='401'
loginObj['error']='invalid token please contact administrator'
return loginObj
示例5: service_si
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import cost_center [as 别名]
def service_si(self,s):
total_amt=0.00
si=Document("Sales Invoice")
si.customer=webnotes.conn.get_value("Customer",{"innoworth_id":(s['Customer Id']).strip()},"name")
si.customer_name=webnotes.conn.get_value("Customer",{"innoworth_id":(s['Customer Id']).strip()},"name")
si.posting_date=nowdate()
si.due_date=nowdate()
si.company='InnoWorth'
si.conversion_rate=1.00
si.customer_group='Individual'
si.territory=s['Territory']
si.charge=webnotes.conn.get_value("Applicable Territory",{"territory":s['Territory']},"parent")
si.debit_to=webnotes.conn.get_value('Account',{"master_name":si.customer},'name')
si.price_list_currency='INR'
si.currency='INR'
si.selling_price_list='Standard Selling'
si.fiscal_year=webnotes.conn.get_value("Global Defaults", None, "current_fiscal_year")
si.docstatus=1
si.save()
html=""
j=0
item_list=[]
for r in s['Child']:
j=j+1
child_data=sql("select name,item_name,item_group,description,stock_uom from `tabItem` where name='"+(r['Item Name']).strip()+"'",as_list=1)
sic=Document("Sales Invoice Item")
sic.parent=si.name
sic.item_code=child_data[0][0]
sic.item_name=child_data[0][1]
sic.item_group=child_data[0][2]
sic.description=child_data[0][3]
sic.qty=(r['Qty']).strip()
sic.stock_uom=child_data[0][4]
sic.ref_rate=webnotes.conn.get_value("Item Price",{"item_code":(r['Item Name']).strip(),"price_list":"Standard Selling"},"ref_rate")
sic.export_rate=webnotes.conn.get_value("Item Price",{"item_code":(r['Item Name']).strip(),"price_list":"Standard Selling"},"ref_rate")
if child_data[0][1]:
sic.export_amount=cstr(flt(sic.ref_rate)*flt((r['Qty']).strip()))
else:
sic.export_amount=cstr((r['Qty']).strip())
total_amt=cstr(flt(total_amt)+flt(sic.export_amount))
sic.income_account='Sales - innow'
sic.cost_center='Main - innow'
sic.docstatus=1
item_list.append({"item_code":sic.item_code,"export_amt":sic.export_amount})
sic.save()
html+=("<tr><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(j)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(sic.item_code)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(sic.description)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;text-align:right;'><div>"+cstr(sic.qty)+"</div></td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(sic.stock_uom)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'><div style='text-align:right'>₹ "+cstr(sic.ref_rate)+"</div></td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'><div style='text-align: right'>₹ "+cstr(sic.export_amount)+"</div></td></tr>")
tax_total=0.00
tax_html=""
if si.charge:
tax_total=self.create_tax(si.charge,si.name,item_list,'Sales Invoice','Sales Taxes and Charges',total_amt)
tax_html=self.sales_tax_html(si.name,None,0)
si_=Document('Sales Invoice',si.name)
si_.net_total_export=cstr(total_amt)
si_.other_charges_total_export=cstr(tax_total)
si_.grand_total_export=cstr(flt(si_.net_total_export)+flt(si_.other_charges_total_export))
si_.grand_total=cstr(si_.grand_total_export)
si_.rounded_total_export=cstr(round(flt(si_.grand_total_export)))
adv=c_amt=0.00
flag=False
check=0
total=si_.grand_total_export
parent_jv=[]
advance_payment=sql("select credit,parent,name,against_account from `tabJournal Voucher Detail` where account='"+si.debit_to+"' and is_advance='Yes' and credit<>0 and ifnull(against_invoice,'')='' and docstatus=1 order by name asc",as_list=1)
if advance_payment:
for s in advance_payment:
if s[1] not in parent_jv:
parent_jv.append(s[1])
if flt(total) < flt(s[0]) and flag==False:
adv=cstr(si_.grand_total_export)
update_jv=sql("update `tabJournal Voucher Detail` set against_invoice='"+si.name+"', credit='"+cstr(total)+"' where name='"+s[2]+"'")
jv = Document("Journal Voucher Detail")
jv.account=si.debit_to
jv.cost_center= "Main - Frsh"
jv.credit= cstr(flt(s[0])-flt(total))
jv.is_advance= "Yes"
jv.parent=s[1]
jv.against_account=s[3]
jv.docstatus=1
jv.save()
flag=True
elif flag==False:
adv=cstr(flt(adv)+flt(s[0]))
total=cstr(flt(total)-flt(s[0]))
update_jv=sql("update `tabJournal Voucher Detail` set against_invoice='"+si.name+"' where name='"+s[2]+"'")
if flt(total)==0:
flag=True
else:
flag=False
si_.total_advance=cstr(adv)
si_.outstanding_amount=cstr(flt(si_.grand_total_export)-flt(adv))
si_.docstatus=1
si_.save()
if parent_jv:
self.make_adv_payment_gl(parent_jv)
data=[{"against_voucher":si.name,"account":si.debit_to,"debit":cstr(si_.grand_total_export),"credit":"0","against":"Sales - innow","against_voucher_type":"Sales Invoice","voucher_type":"Sales Invoice","voucher_no":si.name,"cost_center":""},{"against_voucher":"","account":'Sales - innow',"debit":"0","credit":cstr(total_amt),"against":si.debit_to,"against_voucher_type":"","voucher_type":"Sales Invoice","voucher_no":si.name,"cost_center":"Main - innow"}]
self.create_gl(data)
a=html_data({"posting_date":datetime.datetime.strptime(nowdate(),'%Y-%m-%d').strftime('%d/%m/%Y'),"due_date":datetime.datetime.strptime(nowdate(),'%Y-%m-%d').strftime('%d/%m/%Y'),"customer_name":si.customer_name,"net_total":si_.net_total_export,"grand_total":si_.grand_total_export,"rounded_total":si_.rounded_total_export,"table_data":html,"date_1":"Posting Date","date_2":"Due Date","doctype":"Sales Invoice","doctype_no":si.name,"company":si.company,"addr_name":"","address":"","tax_detail":tax_html})
file_path_=attach_file(a,[si.name,"Account/Kirana","Sales Invoice"])
return {"Sales Invoice":si.name,"File Copy":file_path_}
示例6: make_si
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import cost_center [as 别名]
def make_si(self,args):
parent=sql("select * from `tabSales Order` where name='"+(args['Sales Order No']).strip()+"'",as_dict=1)
if parent:
for r in parent:
si=Document("Sales Invoice")
si.customer=r['customer']
si.customer_name=r['customer_name']
si.posting_date=nowdate()
si.due_date=nowdate()
si.charge=r['charge']
si.company='InnoWorth'
si.conversion_rate=1.00
si.customer_group='Individual'
si.territory=r['territory']
si.debit_to=webnotes.conn.get_value('Account',{"master_name":r['customer']},'name')
si.price_list_currency='INR'
si.currency='INR'
si.selling_price_list='Standard Selling'
si.fiscal_year=webnotes.conn.get_value("Global Defaults", None, "current_fiscal_year")
si.net_total_export=cstr(r['net_total_export'])
si.grand_total_export=cstr(r['grand_total_export'])
si.other_charges_total_export=cstr(r['other_charges_total_export'])
si.grand_total=cstr(r['grand_total_export'])
si.rounded_total_export=cstr(r['rounded_total_export'])
si.save()
si=Document("Sales Invoice",si.name)
adv=c_amt=0.00
flag=False
check=0
total=si.grand_total_export
parent_jv=[]
advance_payment=sql("select credit,parent,name,against_account from `tabJournal Voucher Detail` where account='"+si.debit_to+"' and is_advance='Yes' and credit<>0 and ifnull(against_invoice,'')='' and docstatus=1 order by name asc",as_list=1)
if advance_payment:
for s in advance_payment:
if s[1] not in parent_jv:
parent_jv.append(s[1])
if flt(total) < flt(s[0]) and flag==False:
adv=cstr(si.grand_total_export)
update_jv=sql("update `tabJournal Voucher Detail` set against_invoice='"+si.name+"', credit='"+cstr(total)+"' where name='"+s[2]+"'")
jv = Document("Journal Voucher Detail")
jv.account=si.debit_to
jv.cost_center= "Main - Frsh"
jv.credit= cstr(flt(s[0])-flt(total))
jv.is_advance= "Yes"
jv.parent=s[1]
jv.against_account=s[3]
jv.docstatus=1
jv.save()
flag=True
elif flag==False:
adv=cstr(flt(adv)+flt(s[0]))
total=cstr(flt(total)-flt(s[0]))
update_jv=sql("update `tabJournal Voucher Detail` set against_invoice='"+si.name+"' where name='"+s[2]+"'")
if flt(total)==0:
flag=True
else:
flag=False
si.total_advance=cstr(adv)
si.outstanding_amount=cstr(flt(r['grand_total_export'])-flt(adv))
si.docstatus=1
si.save()
update=sql("update `tabSales Order` set per_billed='100' where name='"+cstr(r['name'])+"'")
child=sql("select * from `tabSales Order Item` where parent='"+(args['Sales Order No']).strip()+"'",as_dict=1)
html=""
j=0
credit_amt=0.00
for s in child:
j=j+1
sic=Document("Sales Invoice Item")
sic.parent=si.name
sic.item_code=s['item_code']
sic.item_name=s['item_name']
sic.item_group=s['item_group']
sic.description=s['description']
sic.qty=s['qty']
sic.stock_uom=s['stock_uom']
sic.ref_rate=s['ref_rate']
sic.amount=s['export_amount']
c_amt=cstr(flt(c_amt)+flt(sic.amount))
sic.export_rate=s['export_rate']
sic.export_amount=s['export_amount']
sic.income_account='Sales - innow'
sic.cost_center='Main - innow'
sic.warehouse=s['reserved_warehouse']
sic.sales_order=r['name']
sic.so_detail=s['name']
sic.docstatus=1
html+=("<tr><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(j)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(sic.item_code)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(sic.description)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;text-align:right;'><div>"+cstr(sic.qty)+"</div></td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(sic.stock_uom)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'><div style='text-align:right'>₹ "+cstr(sic.ref_rate)+"</div></td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'><div style='text-align: right'>₹ "+cstr(sic.export_amount)+"</div></td></tr>")
update=sql("update `tabSales Order Item` set billed_amt='"+cstr(s['export_amount'])+"' where name='"+cstr(s['name'])+"'")
sic.save()
tax_html=self.sales_tax_html((args['Sales Order No']).strip(),si.name,1)
if parent_jv:
self.make_adv_payment_gl(parent_jv)
data=[{"against_voucher":si.name,"account":si.debit_to,"debit":cstr(si.grand_total_export),"credit":"0","against":"Sales - innow","against_voucher_type":"Sales Invoice","voucher_type":"Sales Invoice","voucher_no":si.name,"cost_center":""},{"account":'Sales - innow',"debit":"0","credit":cstr(c_amt),"against":si.debit_to,"against_voucher_type":"","voucher_type":"Sales Invoice","voucher_no":si.name,"cost_center":"Main - innow","against_voucher":""}]
self.create_gl(data)
a=html_data({"posting_date":datetime.datetime.strptime(nowdate(),'%Y-%m-%d').strftime('%d/%m/%Y'),"due_date":datetime.datetime.strptime(nowdate(),'%Y-%m-%d').strftime('%d/%m/%Y'),"customer_name":si.customer_name,"net_total":cstr(si.net_total_export),"grand_total":cstr(si.grand_total_export),"rounded_total":cstr(si.rounded_total_export),"table_data":html,"date_1":"Posting Date","date_2":"Due Date","doctype":"Sales Invoice","doctype_no":si.name,"company":si.company,"addr_name":"","address":"","tax_detail":tax_html})
#.........这里部分代码省略.........