本文整理汇总了Python中webnotes.model.doc.Document.item_code方法的典型用法代码示例。如果您正苦于以下问题:Python Document.item_code方法的具体用法?Python Document.item_code怎么用?Python Document.item_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.item_code方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_material_request
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def create_material_request(self,args):
mr=Document('Material Request')
mr.material_request_type='Purchase'
mr.naming_series='MREQ-'
mr.company='InnoWorth'
mr.transaction_date=nowdate()
mr.fiscal_year=webnotes.conn.get_value("Global Defaults", None, "current_fiscal_year")
mr.status='Submitted'
mr.docstatus=1
mr.save()
mrc=Document('Material Request Item')
mrc.parent=mr.name
mrc.item_code=args[0][0]
mrc.qty=args[0][1]
mrc.schedule_date=args[0][2]
mrc.docstatus=1
mrc.warehouse=args[0][3]
mrc.item_name=args[0][4]
mrc.uom=args[0][5]
mrc.description=args[0][6]
mrc.parentfield='indent_details'
mrc.parenttype='Material Request'
mrc.save()
child_data=[]
child_data.append([mrc.item_code,mrc.qty,mrc.schedule_date,mr.name,mrc.warehouse,mrc.item_name,mrc.uom,mrc.description,mrc.name,args[0][7]])
data=[]
data.append({"item_code":mrc.item_code,"so_qty":cstr(mrc.qty),"proj_qty":('+'+cstr(mrc.qty)),"warehouse":mrc.warehouse,"bin_iqty":"Bin.indented_qty","bin_pqty":"Bin.projected_qty","type":"po"})
self.update_bin(data)
import_amount=self.create_child_po(child_data)
return import_amount
示例2: create_child_po
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def create_child_po(self,child_data):
sic=Document('Purchase Order Item')
sic.item_code=child_data[0][0]
sic.qty=child_data[0][1]
sic.stock_qty=child_data[0][1]
sic.schedule_date=child_data[0][2]
sic.prevdoc_docname=child_data[0][3]
sic.warehouse=child_data[0][4]
sic.item_name=child_data[0][5]
sic.uom=child_data[0][6]
sic.stock_uom=child_data[0][6]
sic.description=child_data[0][7]
sic.prevdoc_detail_docname=child_data[0][8]
sic.conversion_factor=1.0
sic.prevdoc_doctype='Material Request'
rate=webnotes.conn.sql("select ref_rate from `tabItem Price` where price_list='Standard Buying' and item_code='"+child_data[0][0]+"'",as_list=1)
if rate:
sic.import_ref_rate=rate[0][0]
sic.import_rate=rate[0][0]
else:
sic.import_ref_rate=1
sic.import_rate=1
if child_data[0][1]:
sic.import_amount=cstr(flt(sic.import_ref_rate)*flt(child_data[0][1]))
else:
sic.import_amount=sic.import_ref_rate
sic.parentfield='po_details'
sic.parenttype='Purchase Order'
sic.parent=child_data[0][9]
sic.save()
return sic.import_amount
示例3: create_new_item
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def create_new_item(self):
i = Document("Item")
i.item_code = self.doc.new_item_code
i.item_name = self.doc.new_item_name
i.name = i.item_code
i.is_sales_item = "Yes"
i.is_stock_item = "No"
i.save(1)
示例4: get_bin
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def get_bin(self, item_code, warehouse=None):
warehouse = warehouse or self.doc.name
bin = sql("select name from tabBin where item_code = %s and \
warehouse = %s", (item_code, warehouse))
bin = bin and bin[0][0] or ''
if not bin:
bin = Document('Bin')
bin.item_code = item_code
bin.stock_uom = webnotes.conn.get_value('Item', item_code, 'stock_uom')
bin.warehouse = warehouse
bin.warehouse_type = webnotes.conn.get_value("Warehouse", warehouse, "warehouse_type")
bin_obj = get_obj(doc=bin)
bin_obj.validate()
bin.save(1)
bin = bin.name
else:
bin_obj = get_obj('Bin', bin)
return bin_obj
示例5: update_bin
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def update_bin(self,data):
for d in data:
check=webnotes.conn.sql("select name from tabBin where warehouse='"+d['warehouse']+"' and item_code='"+d['item_code']+"'",as_list=1)
if check:
if d['type']=='po':
update=sql("update tabBin set indented_qty=indented_qty+"+cstr(d['so_qty'])+",projected_qty=projected_qty"+cstr(d['proj_qty'])+" where name='"+check[0][0]+"'")
else:
update=sql("update tabBin set reserved_qty=reserved_qty+"+d['so_qty']+",projected_qty=projected_qty"+cstr(d['proj_qty'])+" where name='"+check[0][0]+"'")
else:
Bin=Document('Bin')
Bin.warehouse=d['warehouse']
Bin.item_code=d['item_code']
d['bin_iqty']=cstr(d['so_qty'])
d['bin_pqty']=cstr(d['proj_qty'])
Bin.stock_uom=webnotes.conn.get_value("Item", d['item_code'], "stock_uom")
Bin.save()
示例6: get_bin
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def get_bin(self, item_code):
bin = sql("select name from tabBin where item_code = '%s' and warehouse = '%s'" % (item_code, self.doc.name))
bin = bin and bin[0][0] or ''
if not bin:
if not self.doc.warehouse_type :
msgprint("[Warehouse Type is Mandatory] Please Enter warehouse type in Warehouse " + self.doc.name)
raise Exception
bin = Document('Bin')
bin.item_code = item_code
bin.stock_uom = get_value('Item', item_code, 'stock_uom')
bin.warehouse = self.doc.name
bin.warehouse_type = self.doc.warehouse_type
bin_obj = get_obj(doc=bin)
bin_obj.validate()
bin.save(1)
bin = bin.name
else:
bin_obj = get_obj('Bin',bin)
return bin_obj
示例7: create_item_price
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def create_item_price(self):
item=webnotes.conn.sql("select item_code from `tabItem Price` where price_list='Standard Selling'",debug=1,as_list=1)
#webnotes.errprint(item)
if item:
if [self.doc.name] in item:
#webnotes.errprint("in if loop")
webnotes.conn.sql("""update `tabItem Price` set ref_rate='%s' where item_code='%s' and price_list='Standard Selling'"""%(self.doc.total_rate,self.doc.name))
webnotes.conn.sql('commit')
else:
#webnotes.errprint("else")
d=Document('Item Price')
d.price_list='Standard Selling'
d.item_code=self.doc.name
d.selling=1
d.item_name=self.doc.item_name
d.item_description=self.doc.description
d.ref_rate=self.doc.total_rate
d.save()
#webnotes.errprint(d)
else:
pass
示例8: make_ledger
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def make_ledger(self):
from webnotes.model.doc import Document
for d in getlist(self.doclist, 'entries'):
check=webnotes.conn.sql("select status from `tabSerial No` where name='"+(d.serial_no).strip()+"'",as_list=1)
if check[0][0]=='Available':
sle=Document('Stock Ledger Entry')
sle.item_code=d.item_code
sle.serial_no=d.serial_no
sle.posting_date=nowdate()
sle.posting_time=nowtime()
sle.actual_qty=-d.qty
qty_data=webnotes.conn.sql("select b.actual_qty,foo.warehouse from(select item_code,warehouse from `tabSerial No` where name='"+(d.serial_no).strip()+"') as foo,tabBin as b where b.item_code=foo.item_code and b.warehouse=foo.warehouse",as_list=1,debug=1)
after_transfer=cstr(flt(qty_data[0][0])-flt(d.qty))
update_bin=webnotes.conn.sql("update `tabBin` set actual_qty='"+after_transfer+"', projected_qty='"+after_transfer+"' where item_code='"+d.item_code+"' and warehouse='"+qty_data[0][1]+"'")
sle.qty_after_transaction=after_transfer
sle.warehouse=qty_data[0][1]
sle.voucher_type='Delivery Note'
sle.voucher_no='GRN000056'
sle.stock_uom=webnotes.conn.get_value("Item",d.item_code,"stock_uom")
sle.company='PowerCap'
sle.fiscal_year=webnotes.conn.get_value("Global Defaults", None, "current_fiscal_year")
update_serial=webnotes.conn.sql("update `tabSerial No` set status='Delivered',warehouse=(select name from tabCustomer where 1=2) where name='"+(d.serial_no).strip()+"'")
sle.docstatus=1
sle.save()
示例9: sle
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def sle(self):
make_bin=[]
qry="select sum(actual_qty) from `tabStock Ledger Entry` where item_code='"+self.doc.item+"' and warehouse='Finished Goods - P'"
#ebnotes.errprint(qry)
w3=webnotes.conn.sql(qry)
qty_after_transaction=cstr(cint(w3[0][0])+cint(self.doc.quantity))
actual_qty=self.doc.quantity
import time
tim=time.strftime("%X")
from webnotes.model.doc import Document
d = Document('Stock Ledger Entry')
d.item_code=self.doc.item
d.batch_no=self.doc.name
d.stock_uom='Nos'
d.warehouse='Finished Goods - P'
d.actual_qty=actual_qty
d.posting_date=today()
d.posting_time=tim
d.voucher_type='Purchase Receipt'
d.serial_no=self.doc.serial_no.replace('\n','')
d.qty_after_transaction=qty_after_transaction
d.is_cancelled = 'No'
d.company='PowerCap'
d.docstatus = 1;
d.name = 'Batch wise item updation'
d.owner = webnotes.session['user']
d.fields['__islocal'] = 1
d.save(new=1)
make_bin.append({
"doctype": 'b',
"sle_id":d.name,
"item_code": self.doc.item,
"warehouse": 'Finished Goods - P',
"actual_qty": actual_qty
})
示例10: create_dn
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def create_dn(self):
'''
import urllib.request
import json
json_dict=[]
'''
dn=Document('Delivery Note')
dn.customer=self.doc.customer
dn.customer_name=webnotes.conn.get_value("Customer",self.doc.customer,"customer_name")
dn.company='InnoWorth'
dn.conversion_rate=1.00
dn.posting_date=nowdate()
dn.posting_time=nowtime()
dn.customer_address=webnotes.conn.get_value("Address",{"customer":self.doc.customer},"name")
dn.address_display=get_address_display(dn.customer_address)
dn.price_list_currency='INR'
dn.currency='INR'
dn.docstatus=1
dn.status="Submitted"
dn.selling_price_list='Standard Selling'
dn.fiscal_year=webnotes.conn.get_value("Global Defaults", None, "current_fiscal_year")
dn.save()
j=0
html=""
net_tot=0.00
for s in getlist(self.doclist,"purchase_receipt_details"):
j=j+1
dni=Document("Delivery Note Item")
dni.item_code=s.item_code
dni.item_name=s.item_name
dni.description=s.description
dni.qty=s.qty
dni.docstatus=1
dni.ref_rate=webnotes.conn.get_value("Item Price",{"item_code":dni.item_code,"price_list":"Standard Selling"},"ref_rate")
dni.export_rate=webnotes.conn.get_value("Item Price",{"item_code":dni.item_code,"price_list":"Standard Selling"},"ref_rate")
dni.export_amount=cstr(flt(s.qty)*flt(dni.ref_rate))
net_tot=cstr(flt(net_tot)+flt(dni.export_amount))
dni.warehouse=s.warehouse
dni.stock_uom=s.uom
dni.serial_no=s.serial_no
dni.parent=dn.name
dni.save()
update_bin=("update tabBin set actual_qty=actual_qty-"+cstr(dni.qty)+" and projected_qty=projected_qty-"+cstr(dni.qty)+" where item_code='"+dni.item_code+"' and warehouse='"+dni.warehouse+"'")
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(dni.item_code)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(dni.description)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;text-align:right;'><div>"+cstr(dni.qty)+"</div></td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(dni.stock_uom)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'><div style='text-align:right'>₹ "+cstr(dni.ref_rate)+"</div></td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'><div style='text-align: right'>₹ "+cstr(dni.export_amount)+"</div></td></tr>")
stl=Document("Stock Ledger Entry")
stl.item_code=s.item_code
stl.stock_uom=s.uom
stl.serial_no=s.serial_no
stl.warehouse=s.warehouse
stl.posting_date=nowdate()
stl.voucher_type="Delivery Note"
stl.voucher_no=dn.name
stl.voucher_detail_no=dni.name
stl.is_cancelled="No"
stl.fiscal_year=webnotes.conn.get_value("Global Defaults", None, "current_fiscal_year")
stl.actual_qty=cstr(s.qty)
qty=webnotes.conn.sql("select qty_after_transaction from `tabStock Ledger Entry` where item_code='"+s.item_code+"' and warehouse='"+s.warehouse+"' order by name desc limit 1",as_list=1)
stl.qty_after_transaction=cstr(flt(qty[0][0])-flt(s.qty))
stl.save()
if dni.serial_no:
for se in dni.serial_no:
update=webnotes.conn.sql("update `tabSerial No` set status='Delivered', warehouse=(select name from tabCustomer where 1=2) where name='"+se+"'")
#json_dict.append({"serial_no":se,"supplier_name":self.doc.supplier_name,"item_code":s.item_code})
dn_=Document("Delivery Note",dn.name)
dn_.net_total_export=cstr(net_tot)
dn_.grand_total_export=cstr(net_tot)
dn_.rounded_total_export=cstr(net_tot)
a=html_data({"posting_date":datetime.datetime.strptime(nowdate(),'%Y-%m-%d').strftime('%d/%m/%Y'),"due_date":"","customer_name":dn.customer_name,"net_total":dn_.net_total_export,"grand_total":dn_.grand_total_export,"rounded_total":dn_.rounded_total_export,"table_data":html,"date_1":"Posting Date","date_2":"","doctype":"Delivery Note","doctype_no":dn.name,"company":dn.company,"addr_name":"Address","address":dn.address_display,"tax_detail":""})
attach_file(a,[dn.name,"Selling/Kirana","Delivery Note"])
'''
示例11: on_submit
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def on_submit(self):
if cint(self.doc.update_stock) == 1:
self.update_stock_ledger()
else:
# Check for Approving Authority
if not self.doc.recurring_id:
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype,
self.doc.company, self.doc.grand_total, self)
self.check_prev_docstatus()
self.update_status_updater_args()
self.update_prevdoc_status()
# this sequence because outstanding may get -ve
self.make_gl_entries()
self.check_credit_limit(self.doc.debit_to)
if not cint(self.doc.is_pos) == 1:
self.update_against_document_in_jv()
self.update_c_form()
self.update_time_log_batch(self.doc.name)
self.convert_to_recurring()
self.set_flag()
sum_physician_amt=0
sum_patient_amt=0
referrer={}
referrer1={}
for s in getlist(self.doclist,'entries'):
if s.item_code:
bin_qty=webnotes.conn.sql("select actual_qty from tabBin where item_code='"+s.item_code+"' and warehouse='"+s.warehouse+"'",as_list=1)
if bin_qty:
bin_amt=flt(bin_qty[0][0])-flt(s.qty)
else:
bin_amt=flt(s.qty)
a=webnotes.conn.sql("update tabBin set actual_qty="+cstr(bin_amt)+" where item_code='"+s.item_code+"' and warehouse='"+s.warehouse+"'")
stl=Document('Stock Ledger Entry')
stl.actual_qty=cstr(0-flt(s.qty))
stl.item_code=s.item_code
stl.warehouse=s.warehouse
stl.save()
if s.referrer_name:
check=webnotes.conn.sql("select salutation from tabLead where name='"+s.referrer_name+"'",as_list=1)
if check[0][0]=='Dr.':
sum_physician_amt = 0.0
if s.referrer_physician_credit_to:
if not cstr(s.referrer_physician_credit_to) in referrer:
referrer[cstr(s.referrer_physician_credit_to)] = 0.0
webnotes.errprint(referrer)
update_flag=webnotes.conn.sql("update `tabEncounter` set is_invoiced='True' where name='%s'"%(s.encounter_id))
if not self.doc.lump_sum_payment:
if s.referral_rule == "Percent":
sum_physician_amt=flt(sum_physician_amt) + (flt(s.export_rate)*(flt(s.referral_fee)/100))
else:
sum_physician_amt=flt(sum_physician_amt)+flt(s.referral_fee)
if s.referrer_physician_credit_to and s.referral_fee:
referrer[s.referrer_physician_credit_to] = flt(referrer[s.referrer_physician_credit_to])+sum_physician_amt
if s.referrer_physician_debit_to:
referrer1[s.referrer_physician_credit_to] = s.referrer_physician_debit_to
if self.doc.lump_sum_payment == '1':
sum_physician_amt = self.doc.amount
amt=0
for e in getlist(self.doclist,'advance_adjustment_details'):
if e.allocated_amount:
amt=amt+flt(e.allocated_amount)
outstanding_amount=flt(self.doc.patient_amount)-flt(self.doc.paid_amount_data)-flt(amt)
w=webnotes.conn.sql("update `tabSales Invoice` set outstanding_amount='"+cstr(outstanding_amount)+"' where name='"+self.doc.name+"'")
# webnotes.errprint(referrer)
# webnotes.errprint(referrer1)
for key in referrer:
self.make_JV(referrer[key],key,referrer1[key],self.doc.company)
self.make_JV1(self.doc.paid_amount_data,self.doc.debit_to,self.doc.patient_credit_to,self.doc.company)
示例12: make_si
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [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})
#.........这里部分代码省略.........
示例13: service_si
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [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_}
示例14: make_so
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def make_so(self,args):
# coding: utf-8
net_tot=0.00
so=Document('Sales Order')
so.transaction_date=nowdate()
so.price_list_currency='INR'
so.currency='INR'
so.selling_price_list='Standard Selling'
so.customer=webnotes.conn.get_value("Customer",{"innoworth_id":(args['Customer Id']).strip()},"name")
so.customer_name=webnotes.conn.get_value("Customer",{"innoworth_id":(args['Customer Id']).strip()},"customer_name")
so.delivery_date=(args['Required Date']).strip()
so.company='InnoWorth'
so.conversion_rate=1.00
so.customer_group='Individual'
if (args['Territory']).strip():
so.territory=(args['Territory']).strip()
so.charge=webnotes.conn.get_value("Applicable Territory",{"territory":so.territory},"parent")
so.fiscal_year=webnotes.conn.get_value("Global Defaults", None, "current_fiscal_year")
so.customer_address=webnotes.conn.get_value("Address",{"customer":so.customer},"name")
so.address_display=get_address_display(so.customer_address)
so.contact_person=webnotes.conn.get_value("Contact",{"customer":so.customer},"name")
so.docstatus=1
so.status='Submitted'
so.plc_conversion_rate=1
so.save()
html=""
sr=0
item_list=[]
for j in args['Child']:
sr=sr+1
soi=Document('Sales Order Item')
soi.item_code=(j['Item Name']).strip()
soi.qty=(j['Qty']).strip()
item_details=webnotes.conn.sql("select default_warehouse,item_name,stock_uom,description from tabItem where name='"+(j['Item Name']).strip()+"'",as_list=1)
soi.reserved_warehouse=item_details[0][0]
soi.item_name=item_details[0][1]
soi.stock_uom=item_details[0][2]
soi.description=item_details[0][3]
rate=webnotes.conn.sql("select ref_rate from `tabItem Price` where price_list='Standard Selling' and item_code='"+(j['Item Name']).strip()+"'",as_list=1)
if rate:
soi.ref_rate=rate[0][0]
soi.export_rate=rate[0][0]
else:
soi.ref_rate=1
soi.export_rate=1
soi.export_amount=cstr(flt(soi.ref_rate)*flt((j['Qty']).strip()))
item_list.append({"item_code":soi.item_code,"export_amt":soi.export_amount})
net_tot=cstr(flt(net_tot)+flt(soi.export_amount))
soi.parentfield='sales_order_details'
soi.parenttype='Sales Order'
soi.docstatus=1
soi.parent=so.name
soi.save(new=1)
html+=("<tr><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(sr)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(soi.item_code)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(soi.description)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;text-align:right;'><div>"+cstr(soi.qty)+"</div></td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'>"+cstr(soi.stock_uom)+"</td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'><div style='text-align:right'>₹ "+cstr(soi.ref_rate)+"</div></td><td style='border:1px solid rgb(153, 153, 153);word-wrap: break-word;'><div style='text-align: right'>₹ "+cstr(soi.export_amount)+"</div></td></tr>")
data=[]
data.append({"item_code":soi.item_code,"so_qty":soi.qty,"proj_qty":(0-flt(soi.qty)),"warehouse":soi.reserved_warehouse,"bin_iqty":"","bin_pqty":"Bin.projected_qty","type":"so"})
self.update_bin(data)
tax_total=0.00
if so.charge:
tax_total=self.create_tax(so.charge,so.name,item_list,'Sales Order','Sales Taxes and Charges',net_tot)
so_=Document("Sales Order",so.name)
so_.net_total_export=net_tot
so_.other_charges_total_export=cstr(tax_total)
so_.grand_total_export=cstr(flt(so_.net_total_export)+flt(so_.other_charges_total_export))
so_.rounded_total_export=cstr(round(flt(so_.grand_total_export)))
so_.save()
a=html_data({"posting_date":datetime.datetime.strptime(nowdate(),'%Y-%m-%d').strftime('%d/%m/%Y'),"due_date":datetime.datetime.strptime(so.delivery_date,'%Y-%m-%d').strftime('%d/%m/%Y'),"customer_name":so.customer_name,"net_total":net_tot,"grand_total":net_tot,"rounded_total":net_tot,"table_data":html,"date_1":"Sales Order Date","date_2":"Expected Delivery Date","doctype":"Sales Order","doctype_no":so.name,"company":so.company,"addr_name":"Customer Address","address":so.address_display,"tax_detail":""})
file_path_=attach_file(a,[so.name,"Selling/Kirana","Sales Order"])
return {"Sales Order":so.name,"File Copy":file_path_}
示例15: create_in
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import item_code [as 别名]
def create_in(data,_type='POST'):
from webnotes.model.doc import Document
from webnotes.utils import nowdate,add_months
data1=json.loads(data)
auth_key=data1['token']
invoice_type=data1['invoice_type']
customer=data1['customer']
dattime=data1['datetime']
item_details=data1['item_details']
login =[]
loginObj = {}
amt=0
qt=0
srl=''
cc=''
zz=''
#return data
if len(auth_key[1:-1]) <=0 or len(dattime[1:-1]) <=0 or len(customer[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
for ff in item_details:
a=ff['barcode']
c="select item_code,warehouse from `tabSerial No` where name='"+a[:-1]+"'"
cc=webnotes.conn.sql(c)
#webnotes.errprint(c)
#webnotes.errprint(cc)
amt=cint(amt)+cint(ff['rate'])
qt+=1
srl+=a[:-2].replace(',','\n')
#return cc
if cc :
qr="select name from `tabauth keys` where auth_key='"+auth_key+"'"
#return qr
res=webnotes.conn.sql(qr)
if res :
rr="select region from `tabFranchise` where contact_email='"+res[0][0]+"'"
r1=webnotes.conn.sql(rr)
if r1[0][0]==cc[0][1] :
#webnotes.errprint("same")
pass
else:
#webnotes.errprint("different warehouse")
pass
zz+="'"+a[:-1].replace(',','')+"',"
else:
if invoice_type=='CUSTOMER':
l = Document('Customer Details',customer)
l.customer_name=customer
l.save()
webnotes.conn.commit()
for ll in item_details:
m = Document('Customer Data')
m.serial_no=a[:-1]
m.parent=l.name
m.parenttype='Customer Details'
m.parentfield='customer_data'
m.save(new=1)
webnotes.conn.commit()
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+"'"
b=webnotes.conn.sql(a)
if b:
a=''
else:
d = Document('Customer')
d.customer_name=customer
d.name=customer
d.save(new=1)
webnotes.conn.commit()
qr="select name from `tabauth keys` where auth_key='"+auth_key+"'"
#webnotes.errprint(qr)
res=webnotes.conn.sql(qr)
rgn=''
if res :
rr="select region from `tabFranchise` where contact_email='"+res[0][0]+"'"
#webnotes.errprint(qr)
r1=webnotes.conn.sql(rr,as_list=1)
#webnotes.errprint(r1[0][0])
d = Document('Sales Invoice')
d.customer=customer
d.customer_name=customer
d.posting_date=dattime[1:-1]
d.due_date=dattime[1:-1]
d.remarks='Invalid QR code'
d.selling_price_list='Standard Selling'
d.currency='INR'
if r1:
d.territory=r1[0][0]
d.region=r1[0][0]
d.net_total_export=0
d.grand_total_export=0
d.rounded_total_export=0
d.plc_conversion_rate=1
from webnotes.utils import nowdate
#.........这里部分代码省略.........