コード例 #1
0
ファイル: cgi.py プロジェクト: rohitw1991/innoworth-app
	def sales_tax_html(self,parent,name,c):
		tax_html=''
		gl_data=[]
		voucher_no=name
		tax_data=sql("select charge_type,account_head,rate,description,tax_amount,total,parenttype,row_id from `tabSales Taxes and Charges` where parent='"+parent+"'",as_dict=1)
		if tax_data:
                	for tax in tax_data:
				if cint(c)==1:
					t=Document('Sales Taxes and Charges')
                        		t.parent=name
                        		t.account_head=tax['account_head']
                        		t.parentfield="other_charges"
                        		t.charge_type=tax['charge_type']
                        		t.description=tax['description']
                        		t.row_id=tax['row_id']
                        		t.docstatus=1
                        		t.parenttype='Sales Invoice'
					t.rate=tax['rate']
					t.tax_amount=tax['tax_amount']
					t.total=tax['total']
					t.save()
                		tax_html+=("<tr><td style='width:50%;'>"+tax['description']+"</td><td style='width:50%;text-align:right;'>₹ "+cstr(tax['tax_amount'])+"</td></tr>")
				if name==None:
					voucher_no=parent
				gl_data.append({
                                	"account":tax['account_head'],
                                        "cost_center":'Main - Frsh',
                                        "debit":0,
                                        "credit":cstr(tax['tax_amount']),
                                        "against":webnotes.conn.get_value('Sales Invoice',voucher_no,'debit_to'),
                                        "against_voucher":"",
                                        "against_voucher_type":"",
                                        "voucher_type":"Sales Invoice",
                                        "voucher_no":voucher_no
                                })
			self.create_gl(gl_data)	
			return tax_html 
コード例 #2
0
ファイル: cgi.py プロジェクト: rohitw1991/innoworth-app
	def create_tax(self,master,parent,item_list,parenttype,tax_table,net_total):
			row=0
			total_amt_=final_amt=0.00
			row_amt=[]
			test_dict = {}
			tax=sql("select * from `tab"+tax_table+"` where parent='"+master+"'",as_dict=1)
			for s in tax:
				t=Document(tax_table)
				t.parent=parent
				t.account_head=s['account_head']
				t.parentfield="other_charges"
				t.charge_type=s['charge_type']
				t.description=s['description']
				t.row_id=s['row_id']
				t.docstatus=1
				t.parenttype=parenttype
				actual=0
				amt=0.00
				row=row+1
				test_dict.setdefault(row,{})
				for item in item_list:
					t.rate=webnotes.conn.get_value("Item Tax",{"parent":item['item_code'],"tax_type":s['account_head']},"tax_rate")
					if not t.rate:
						t.rate=s['rate']
					if t.charge_type=="On Net Total":
						amt=cstr(flt(amt)+flt(flt(item['export_amt'])*flt(t.rate)/100))
						net_total=cstr(flt(net_total)+flt(flt(item['export_amt'])*flt(t.rate)/100))
						total_amt_=cstr(flt(flt(item['export_amt'])*flt(t.rate)/100)+flt(item['export_amt']))
						test_dict[row].setdefault(item['item_code'],{})
						test_dict[row][item['item_code']]['amount']= cstr(flt(item['export_amt'])*flt(t.rate)/100)
						test_dict[row][item['item_code']]['total']=cstr(total_amt_)

					elif t.charge_type=="On Previous Row Amount":
						for rowid in test_dict:
							if cint(rowid)==cint(s['row_id']):
								for dict_item in test_dict[rowid]:
									if dict_item==item['item_code']:
										prev_amt=cstr(test_dict[rowid][dict_item]['amount'])
										amt=cstr(flt(amt)+flt(flt(prev_amt)*flt(t.rate)/100))
                                                				net_total=cstr(flt(net_total)+flt(flt(prev_amt)*flt(t.rate)/100))
										total_amt_=cstr(flt(flt(prev_amt)*flt(t.rate)/100)+flt(item['export_amt']))
                                                				test_dict[row].setdefault(item['item_code'],{})
                                                				test_dict[row][item['item_code']]['amount']= cstr(flt(prev_amt)*flt(t.rate)/100)
                                                				test_dict[row][item['item_code']]['total']=cstr(total_amt_)

					elif t.charge_type=="On Previous Row Total":
						for rowid in test_dict:
                                                	if cint(rowid)==cint(s['row_id']):
                                                                for dict_item in test_dict[rowid]:
									if dict_item==item['item_code']:
										prev_total=cstr(test_dict[rowid][dict_item]['total'])
                                                                		amt=cstr(flt(amt)+flt(flt(prev_total)*flt(t.rate)/100))
                                                                		net_total=cstr(flt(net_total)+flt(flt(prev_total)*flt(t.rate)/100))
										total_amt_=cstr(flt(flt(prev_total)*flt(t.rate)/100)+flt(item['export_amt']))
										test_dict[row].setdefault(item['item_code'],{})
                                                                        	test_dict[row][item['item_code']]['amount']= cstr(flt(prev_total)*flt(t.rate)/100)
                                                                        	test_dict[row][item['item_code']]['total']=cstr(total_amt_)
					elif t.charge_type=="Actual":
						if cint(actual)==0:
							actual=actual+1
                                                	amt=cstr(flt(amt)+flt(t.rate))
							net_total=cstr(flt(net_total)+flt(amt))
							test_dict[row].setdefault(item['item_code'],{})
                                                        test_dict[row][item['item_code']]['amount']= cstr(amt)
                                                        test_dict[row][item['item_code']]['total']=cstr(net_total)
				final_amt=cstr(flt(final_amt)+flt(amt))	
				t.tax_amount=cstr(amt)
				t.total=cstr(net_total)
				t.save()
			return final_amt