[Enhance] Group same items during printing Delivery Note, Invoices, etc (#14250)
* add doctypes allowed to group items, average the rate * add check field to group items during print * call common before_print in delivery note * fix precision issue while calculating average
This commit is contained in:
@@ -82,7 +82,8 @@ class AccountsController(TransactionBase):
|
||||
self.validate_non_invoice_documents_schedule()
|
||||
|
||||
def before_print(self):
|
||||
if self.doctype in ['Purchase Order', 'Sales Order']:
|
||||
if self.doctype in ['Purchase Order', 'Sales Order', 'Sales Invoice', 'Purchase Invoice',
|
||||
'Supplier Quotation', 'Purchase Receipt', 'Delivery Note', 'Quotation']:
|
||||
if self.get("group_same_items"):
|
||||
self.group_similar_items()
|
||||
|
||||
@@ -663,6 +664,7 @@ class AccountsController(TransactionBase):
|
||||
if item.item_code in group_item_qty:
|
||||
item.qty = group_item_qty[item.item_code]
|
||||
item.amount = group_item_amount[item.item_code]
|
||||
item.rate = flt(flt(item.amount)/flt(item.qty), item.precision("rate"))
|
||||
del group_item_qty[item.item_code]
|
||||
else:
|
||||
duplicate_list.append(item)
|
||||
|
||||
Reference in New Issue
Block a user