mirror of
https://github.com/bcomsugi/dasaproject.git
synced 2026-01-11 07:42:38 +07:00
before touching UOM into account to calculate rate discount
This commit is contained in:
parent
9e65890d0f
commit
56594e963a
@ -204,6 +204,7 @@ class SalesOrderQuery:
|
|||||||
# Memo = self.create_sub_element(ET, InvoiceAdd, "Memo", self.DN['Memo'], 10 )
|
# Memo = self.create_sub_element(ET, InvoiceAdd, "Memo", self.DN['Memo'], 10 )
|
||||||
disc_amount = 0
|
disc_amount = 0
|
||||||
for soidx, salesorder in enumerate(self.SalesOrderList):
|
for soidx, salesorder in enumerate(self.SalesOrderList):
|
||||||
|
if 'TxnID' in salesorder:
|
||||||
SOTxnId = salesorder['TxnID']
|
SOTxnId = salesorder['TxnID']
|
||||||
# disc_amount+=int(salesorder['Disc_Amount'])
|
# disc_amount+=int(salesorder['Disc_Amount'])
|
||||||
print(f'create_invoiceadd_QBXML->SOTxnId: {SOTxnId}')
|
print(f'create_invoiceadd_QBXML->SOTxnId: {SOTxnId}')
|
||||||
@ -236,6 +237,13 @@ class SalesOrderQuery:
|
|||||||
ItemRef = self.create_sub_element(ET, InvoiceLineAdd, "ItemRef", "\n ", 12)
|
ItemRef = self.create_sub_element(ET, InvoiceLineAdd, "ItemRef", "\n ", 12)
|
||||||
ItemFullName = self.create_sub_element(ET, ItemRef, "FullName", "400_Sales Discount", 12)
|
ItemFullName = self.create_sub_element(ET, ItemRef, "FullName", "400_Sales Discount", 12)
|
||||||
ItemRate = self.create_sub_element(ET, InvoiceLineAdd, "Rate", str(disc_amount), 10)
|
ItemRate = self.create_sub_element(ET, InvoiceLineAdd, "Rate", str(disc_amount), 10)
|
||||||
|
elif 'other_itemFullName' in salesorder and 'other_qty' in salesorder and 'other_rate' in salesorder:
|
||||||
|
pass
|
||||||
|
InvoiceLineAdd = self.create_sub_element(ET, InvoiceAdd, "InvoiceLineAdd", "\n ", 10 )
|
||||||
|
ItemRef = self.create_sub_element(ET, InvoiceLineAdd, "ItemRef", "\n ", 12)
|
||||||
|
ItemFullName = self.create_sub_element(ET, ItemRef, "FullName", salesorder['other_itemFullName'], 12)
|
||||||
|
Quantity = self.create_sub_element(ET, InvoiceLineAdd, "Quantity", str(salesorder['other_qty']), 12 )
|
||||||
|
ItemRate = self.create_sub_element(ET, InvoiceLineAdd, "Rate", str(salesorder['other_rate']), 10)
|
||||||
|
|
||||||
mydata = ET.tostring(root, encoding = "unicode")
|
mydata = ET.tostring(root, encoding = "unicode")
|
||||||
|
|
||||||
@ -270,7 +278,7 @@ class SalesOrderQuery:
|
|||||||
sessionManager.EndSession(ticket) # Close the company file
|
sessionManager.EndSession(ticket) # Close the company file
|
||||||
sessionManager.CloseConnection() # Close the connection
|
sessionManager.CloseConnection() # Close the connection
|
||||||
# print (f'response_string:{response_string}')
|
# print (f'response_string:{response_string}')
|
||||||
return response_string
|
return self.pprintXml(response_string)
|
||||||
|
|
||||||
def __str__(self, *args) -> str:
|
def __str__(self, *args) -> str:
|
||||||
# return str(self._get_datarow(self.connect_to_quickbooks(self.create_QBXML())))
|
# return str(self._get_datarow(self.connect_to_quickbooks(self.create_QBXML())))
|
||||||
|
|||||||
@ -172,12 +172,30 @@ def save_inv(request):
|
|||||||
data = dict(request.POST)
|
data = dict(request.POST)
|
||||||
del data['csrfmiddlewaretoken']
|
del data['csrfmiddlewaretoken']
|
||||||
del data['customer_fullname']
|
del data['customer_fullname']
|
||||||
|
### get others items into list of dict ###
|
||||||
|
others=[]
|
||||||
|
otherFullName = {'peti': 'PETI', 'expedition':'Sales_Ekspedisi'}
|
||||||
|
if 'selected_items' in data:
|
||||||
|
for _ in data['selected_items']:
|
||||||
|
if _ in data['other_items']:
|
||||||
|
data_idx = data['other_items'].index(_)
|
||||||
|
print(f'selected item:{_} is in index:{data_idx}')
|
||||||
|
other_qty = int(data['other_qty'][data_idx])
|
||||||
|
other_rate = float(data['other_rate'][data_idx])
|
||||||
|
if other_qty<=0:
|
||||||
|
other_qty = 1
|
||||||
|
if other_rate <= 0:
|
||||||
|
continue
|
||||||
|
temp_ = {'other_item':data['other_items'][data_idx], 'other_itemFullName': otherFullName[data['other_items'][data_idx]], 'other_qty':other_qty, 'other_rate': other_rate}
|
||||||
|
others.append(temp_)
|
||||||
|
del data['selected_items']
|
||||||
if 'other_items' in data:
|
if 'other_items' in data:
|
||||||
del data['other_items']
|
del data['other_items']
|
||||||
|
if 'other_qty' in data:
|
||||||
del data['other_qty']
|
del data['other_qty']
|
||||||
|
if 'other_rate' in data:
|
||||||
del data['other_rate']
|
del data['other_rate']
|
||||||
if 'selected_items' in data:
|
print(f'others:{others}')
|
||||||
del data['selected_items']
|
|
||||||
|
|
||||||
# print(f"datadict:{data}")
|
# print(f"datadict:{data}")
|
||||||
try:
|
try:
|
||||||
@ -259,24 +277,26 @@ def save_inv(request):
|
|||||||
break
|
break
|
||||||
break
|
break
|
||||||
print(f'last:{dict_}')
|
print(f'last:{dict_}')
|
||||||
if dict_ != data_to_save[-1]:
|
if dict_ != data_to_save[-1]: #append the last dict_
|
||||||
dict_['Disc_Amount']=disc_amount
|
dict_['Disc_Amount']=disc_amount
|
||||||
data_to_save.append(dict_)
|
data_to_save.append(dict_)
|
||||||
print('save the last dict')
|
print('save the last dict')
|
||||||
else:
|
else:
|
||||||
print('last data to save == dict')
|
print('last data to save == dict')
|
||||||
|
for _ in others:
|
||||||
|
data_to_save.append(_)
|
||||||
print(f'Final List:{data_to_save}')
|
print(f'Final List:{data_to_save}')
|
||||||
print("")
|
print("")
|
||||||
# print(itu)
|
# print(itu)
|
||||||
context['objects'] = itu
|
context['objects'] = itu
|
||||||
context['customer_fullname'] = customer_fullname
|
context['customer_fullname'] = customer_fullname
|
||||||
print(context['objects'])
|
# print(context['objects'])
|
||||||
print("Invoiceaddqbxml:")
|
print("Invoiceaddqbxml:")
|
||||||
invoiceaddQBXML=ini.create_invoiceadd_QBXML(data_to_save)
|
invoiceaddQBXML=ini.create_invoiceadd_QBXML(data_to_save)
|
||||||
|
|
||||||
print(invoiceaddQBXML)
|
print(invoiceaddQBXML)
|
||||||
result=None
|
result=None
|
||||||
# result = ini.connect_to_quickbooks(ini.create_invoiceadd_QBXML())
|
result = ini.connect_to_quickbooks(ini.create_invoiceadd_QBXML())
|
||||||
print("RESULT:")
|
print("RESULT:")
|
||||||
print(result)
|
print(result)
|
||||||
return render(request, "Invoice/so_details_form.html", context)
|
return render(request, "Invoice/so_details_form.html", context)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user