From 0d629ad677a60eadf703c9c1b6df2dafa8ee1220 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Thu, 16 Sep 2021 19:33:57 +0530 Subject: [PATCH] feat: Merge POS invoices based on customer group (#27471) * feat: Merge POS invoices based on customer group * fix: Linting Issues * fix: fieldname Co-authored-by: Saqib (cherry picked from commit c9c89572502dab66595cbe0e0aa764143fc44b5a) # Conflicts: # erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.json # erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py # erpnext/accounts/doctype/sales_invoice/sales_invoice.py # erpnext/hooks.py # erpnext/patches.txt # erpnext/patches/v13_0/create_accounting_dimensions_in_pos_doctypes.py --- .../pos_invoice_merge_log.json | 10 ++++++++++ .../pos_invoice_merge_log.py | 16 ++++++++++++++++ .../doctype/sales_invoice/sales_invoice.py | 3 +++ erpnext/hooks.py | 10 ++++++++++ erpnext/patches.txt | 5 +++++ ...e_accounting_dimensions_in_pos_doctypes.py | 19 +++++++++++++++++++ 6 files changed, 63 insertions(+) diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.json b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.json index a0594556474..bdb8f0272fc 100644 --- a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.json +++ b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.json @@ -6,7 +6,10 @@ "engine": "InnoDB", "field_order": [ "posting_date", +<<<<<<< HEAD "posting_time", +======= +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) "merge_invoices_based_on", "column_break_3", "pos_closing_entry", @@ -106,6 +109,7 @@ "label": "Customer Group", "mandatory_depends_on": "eval:doc.merge_invoices_based_on == 'Customer Group'", "options": "Customer Group" +<<<<<<< HEAD }, { "fieldname": "posting_time", @@ -113,12 +117,18 @@ "label": "Posting Time", "no_copy": 1, "reqd": 1 +======= +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) } ], "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2022-08-01 11:36:42.456429", +======= + "modified": "2021-09-14 11:17:19.001142", +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) "modified_by": "Administrator", "module": "Accounts", "name": "POS Invoice Merge Log", diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py index 3cfffc8d368..8723cc3a9b1 100644 --- a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py +++ b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py @@ -36,7 +36,11 @@ class POSInvoiceMergeLog(Document): frappe.throw(error_list, title=_("Duplicate POS Invoices found"), as_list=True) def validate_customer(self): +<<<<<<< HEAD if self.merge_invoices_based_on == "Customer Group": +======= + if self.merge_invoices_based_on == 'Customer Group': +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) return for d in self.pos_invoices: @@ -165,6 +169,7 @@ class POSInvoiceMergeLog(Document): for item in doc.get("items"): found = False for i in items: +<<<<<<< HEAD if ( i.item_code == item.item_code and not i.serial_no @@ -173,6 +178,10 @@ class POSInvoiceMergeLog(Document): and i.net_rate == item.net_rate and i.warehouse == item.warehouse ): +======= + if (i.item_code == item.item_code and not i.serial_no and not i.batch_no and + i.uom == item.uom and i.net_rate == item.net_rate and i.warehouse == item.warehouse): +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) found = True i.qty = i.qty + item.qty i.amount = i.amount + item.net_amount @@ -238,6 +247,7 @@ class POSInvoiceMergeLog(Document): invoice.taxes_and_charges = None invoice.ignore_pricing_rule = 1 invoice.customer = self.customer +<<<<<<< HEAD invoice.disable_rounded_total = cint( frappe.db.get_value("POS Profile", invoice.pos_profile, "disable_rounded_total") ) @@ -245,6 +255,12 @@ class POSInvoiceMergeLog(Document): if self.merge_invoices_based_on == "Customer Group": invoice.flags.ignore_pos_profile = True invoice.pos_profile = "" +======= + + if self.merge_invoices_based_on == 'Customer Group': + invoice.flags.ignore_pos_profile = True + invoice.pos_profile = '' +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) return invoice diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 4a4a0f839d2..2b907c46ad2 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -556,7 +556,10 @@ class SalesInvoice(SellingController): ) from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details +<<<<<<< HEAD +======= +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) if not self.pos_profile and not self.flags.ignore_pos_profile: pos_profile = get_pos_profile(self.company) or {} if not pos_profile: diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 651e6a0ac22..ce5b403c527 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -564,6 +564,7 @@ payment_gateway_enabled = "erpnext.accounts.utils.create_payment_gateway_account communication_doctypes = ["Customer", "Supplier"] +<<<<<<< HEAD accounting_dimension_doctypes = [ "GL Entry", "Sales Invoice", @@ -608,6 +609,15 @@ accounting_dimension_doctypes = [ "Purchase Order", "Purchase Receipt", "Sales Order", +======= +accounting_dimension_doctypes = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "Asset", + "Expense Claim", "Expense Claim Detail", "Expense Taxes and Charges", "Stock Entry", "Budget", "Payroll Entry", "Delivery Note", + "Sales Invoice Item", "Purchase Invoice Item", "Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", + "Purchase Receipt Item", "Stock Entry Detail", "Payment Entry Deduction", "Sales Taxes and Charges", "Purchase Taxes and Charges", "Shipping Rule", + "Landed Cost Item", "Asset Value Adjustment", "Loyalty Program", "Fee Schedule", "Fee Structure", "Stock Reconciliation", + "Travel Request", "Fees", "POS Profile", "Opening Invoice Creation Tool", "Opening Invoice Creation Tool Item", "Subscription", + "Subscription Plan", "POS Invoice", "POS Invoice Item" +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) ] regional_overrides = { diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e81892bd14f..cfb731fa2a8 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -315,6 +315,7 @@ erpnext.patches.v13_0.create_website_items #30-09-2021 erpnext.patches.v13_0.populate_e_commerce_settings erpnext.patches.v13_0.make_homepage_products_website_items erpnext.patches.v13_0.update_dates_in_tax_withholding_category +<<<<<<< HEAD erpnext.patches.v13_0.fix_invoice_statuses erpnext.patches.v13_0.replace_supplier_item_group_with_party_specific_item erpnext.patches.v13_0.gst_fields_for_pos_invoice @@ -379,3 +380,7 @@ erpnext.patches.v13_0.update_asset_value_for_manual_depr_entries erpnext.patches.v13_0.update_docs_link erpnext.patches.v13_0.correct_asset_value_if_je_with_workflow execute:frappe.db.set_value("Accounts Settings", "Accounts Settings", "service_provider", "frankfurter.app") +======= +erpnext.patches.v14_0.update_opportunity_currency_fields +erpnext.patches.v13_0.create_accounting_dimensions_in_pos_doctypes +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) diff --git a/erpnext/patches/v13_0/create_accounting_dimensions_in_pos_doctypes.py b/erpnext/patches/v13_0/create_accounting_dimensions_in_pos_doctypes.py index 51ab0e8b65c..1bd2a05f0aa 100644 --- a/erpnext/patches/v13_0/create_accounting_dimensions_in_pos_doctypes.py +++ b/erpnext/patches/v13_0/create_accounting_dimensions_in_pos_doctypes.py @@ -3,12 +3,18 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_field def execute(): +<<<<<<< HEAD frappe.reload_doc("accounts", "doctype", "accounting_dimension") accounting_dimensions = frappe.db.sql( """select fieldname, label, document_type, disabled from `tabAccounting Dimension`""", as_dict=1, ) +======= + frappe.reload_doc('accounts', 'doctype', 'accounting_dimension') + accounting_dimensions = frappe.db.sql("""select fieldname, label, document_type, disabled from + `tabAccounting Dimension`""", as_dict=1) +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) if not accounting_dimensions: return @@ -17,9 +23,15 @@ def execute(): for d in accounting_dimensions: if count % 2 == 0: +<<<<<<< HEAD insert_after_field = "dimension_col_break" else: insert_after_field = "accounting_dimensions_section" +======= + insert_after_field = 'dimension_col_break' + else: + insert_after_field = 'accounting_dimensions_section' +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) for doctype in ["POS Invoice", "POS Invoice Item"]: @@ -35,10 +47,17 @@ def execute(): "label": d.label, "fieldtype": "Link", "options": d.document_type, +<<<<<<< HEAD "insert_after": insert_after_field, } if df["fieldname"] not in fieldnames: +======= + "insert_after": insert_after_field + } + + if df['fieldname'] not in fieldnames: +>>>>>>> c9c8957250 (feat: Merge POS invoices based on customer group (#27471)) create_custom_field(doctype, df) frappe.clear_cache(doctype=doctype)