From 77cc91d06b9ea1e5758546a78bbcbb2ef97f549b Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 19 Oct 2023 22:35:55 +0530 Subject: [PATCH 1/3] fix: add regional support to extend purchase gl entries --- .../doctype/purchase_invoice/purchase_invoice.py | 2 +- erpnext/controllers/stock_controller.py | 12 ++++++++++-- .../doctype/purchase_receipt/purchase_receipt.py | 12 ++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 2433268627..e8fc445bc9 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -1066,7 +1066,7 @@ class PurchaseInvoice(BuyingController): "debit_in_account_currency": ( base_asset_amount if cwip_account_currency == self.company_currency else asset_amount ), - "cost_center": self.cost_center, + "cost_center": item.cost_center or self.cost_center, "project": item.project or self.project, }, item=item, diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index ae54b801f1..9eeffd8ea6 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -76,6 +76,7 @@ class StockController(AccountsController): elif self.doctype in ["Purchase Receipt", "Purchase Invoice"] and self.docstatus == 1: gl_entries = [] gl_entries = self.get_asset_gl_entry(gl_entries) + update_regional_gl_entries(gl_entries, self) make_gl_entries(gl_entries, from_repost=from_repost) def validate_serialized_batch(self): @@ -855,8 +856,9 @@ class StockController(AccountsController): @frappe.whitelist() def show_accounting_ledger_preview(company, doctype, docname): - filters = {"company": company, "include_dimensions": 1} + filters = frappe._dict(company=company, include_dimensions=1) doc = frappe.get_doc(doctype, docname) + doc.run_method("before_gl_preview") gl_columns, gl_data = get_accounting_ledger_preview(doc, filters) @@ -867,8 +869,9 @@ def show_accounting_ledger_preview(company, doctype, docname): @frappe.whitelist() def show_stock_ledger_preview(company, doctype, docname): - filters = {"company": company} + filters = frappe._dict(company=company) doc = frappe.get_doc(doctype, docname) + doc.run_method("before_sl_preview") sl_columns, sl_data = get_stock_ledger_preview(doc, filters) @@ -1216,3 +1219,8 @@ def create_item_wise_repost_entries(voucher_type, voucher_no, allow_zero_rate=Fa repost_entries.append(repost_entry) return repost_entries + + +@erpnext.allow_regional +def update_regional_gl_entries(gl_list, doc): + return diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index de0db1aa8f..662ab6d423 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -314,6 +314,7 @@ class PurchaseReceipt(BuyingController): self.make_item_gl_entries(gl_entries, warehouse_account=warehouse_account) self.make_tax_gl_entries(gl_entries) self.get_asset_gl_entry(gl_entries) + update_regional_gl_entries(gl_entries, self) return process_gl_map(gl_entries) @@ -827,8 +828,6 @@ class PurchaseReceipt(BuyingController): pr_doc = self if (pr == self.name) else frappe.get_doc("Purchase Receipt", pr) update_billing_percentage(pr_doc, update_modified=update_modified) - self.load_from_db() - def update_billed_amount_based_on_po(po_details, update_modified=True): po_billed_amt_details = get_billed_amount_against_po(po_details) @@ -941,9 +940,6 @@ def get_billed_amount_against_po(po_items): def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate=False): - # Reload as billed amount was set in db directly - pr_doc.load_from_db() - # Update Billing % based on pending accepted qty total_amount, total_billed_amount = 0, 0 item_wise_returned_qty = get_item_wise_returned_qty(pr_doc) @@ -969,7 +965,6 @@ def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate percent_billed = round(100 * (total_billed_amount / (total_amount or 1)), 6) pr_doc.db_set("per_billed", percent_billed) - pr_doc.load_from_db() if update_modified: pr_doc.set_status(update=True) @@ -1255,3 +1250,8 @@ def get_item_account_wise_additional_cost(purchase_document): def on_doctype_update(): frappe.db.add_index("Purchase Receipt", ["supplier", "is_return", "return_against"]) + + +@erpnext.allow_regional +def update_regional_gl_entries(gl_list, doc): + return From ff7108a3b139b2f019230be681147f1a1c90a681 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Fri, 20 Oct 2023 09:33:37 +0530 Subject: [PATCH 2/3] fix: update existing doc if possible --- .../purchase_receipt/purchase_receipt.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 662ab6d423..3734892f17 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -822,14 +822,14 @@ class PurchaseReceipt(BuyingController): po_details.append(d.purchase_order_item) if po_details: - updated_pr += update_billed_amount_based_on_po(po_details, update_modified) + updated_pr += update_billed_amount_based_on_po(po_details, update_modified, self) for pr in set(updated_pr): pr_doc = self if (pr == self.name) else frappe.get_doc("Purchase Receipt", pr) update_billing_percentage(pr_doc, update_modified=update_modified) -def update_billed_amount_based_on_po(po_details, update_modified=True): +def update_billed_amount_based_on_po(po_details, update_modified=True, pr_doc=None): po_billed_amt_details = get_billed_amount_against_po(po_details) # Get all Purchase Receipt Item rows against the Purchase Order Items @@ -858,13 +858,19 @@ def update_billed_amount_based_on_po(po_details, update_modified=True): po_billed_amt_details[pr_item.purchase_order_item] = billed_against_po if pr_item.billed_amt != billed_amt_agianst_pr: - frappe.db.set_value( - "Purchase Receipt Item", - pr_item.name, - "billed_amt", - billed_amt_agianst_pr, - update_modified=update_modified, - ) + # update existing doc if possible + if pr_doc and pr_item.parent == pr_doc.name: + pr_item = next((item for item in pr_doc.items if item.name == pr_item.name), None) + pr_item.db_set("billed_amt", billed_amt_agianst_pr, update_modified=update_modified) + + else: + frappe.db.set_value( + "Purchase Receipt Item", + pr_item.name, + "billed_amt", + billed_amt_agianst_pr, + update_modified=update_modified, + ) updated_pr.append(pr_item.parent) From fff97b1cd20305adf6bbd4478adf86d6847cc025 Mon Sep 17 00:00:00 2001 From: Maharshi Patel Date: Fri, 20 Oct 2023 17:34:57 +0530 Subject: [PATCH 3/3] chore: new erpnext logo as per espresso --- erpnext/public/images/erpnext-favicon.svg | 2 +- erpnext/public/images/erpnext-logo.png | Bin 2360 -> 4260 bytes erpnext/public/images/erpnext-logo.svg | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/public/images/erpnext-favicon.svg b/erpnext/public/images/erpnext-favicon.svg index 6bc6b2c2db..768e6e5514 100644 --- a/erpnext/public/images/erpnext-favicon.svg +++ b/erpnext/public/images/erpnext-favicon.svg @@ -1,5 +1,5 @@ - + diff --git a/erpnext/public/images/erpnext-logo.png b/erpnext/public/images/erpnext-logo.png index 3090727d8ff5f95e49d25278b24b10bf13747f4a..b4c27493e215b73cb61a5323131d6d2294c419ef 100644 GIT binary patch literal 4260 zcmd^DTU1kL7TzZz1c?e*6+{`J7p(&VEgBS*go>zxAQd$#LehFc3gM2RAtXv$#)4o= zA&4mHPyrPo6a;~U9AK292q-s8fS`azBnE_VNl4Bd`!rAUG%v26wa)tY-v8ySe_y|S zF8KNGTw-i#3;;`Z@ABLSK)^`?7#ZTjbV8Q~9~MRKIvfK)`QY7)KyID|E<|GX?fe2t z+t$3o8G~RC9}j@?49db+BmmPbyFESjCm_lJw~V|4=bNATcW0}1`LJ$&;Q1q)x;Eg) zj^mlnZ2Q74?{#{eb|I}|(WR#ss5bCh)cHOCKE82LZkRZqWqdfh@A2~AtNN;HIqk1* zykX0@@yx-S*wn5a2h^kh(>yt+?aW^FgEWh!DO2tFH0#pR(x8Zl-kzSpSL(A<$~bOo z1P9RY`z!$)H{XlHyvr~4Y^R* zdB2q|l}iJUvG%(b`Xf%O<|4WUsU$eryzlCYy93vKzP)M$L>kz7Wtz^_=9N1ydB^>d z-FDS2e#%~DvpExT`Wt6=aL*I~z1VeS689j-;KhUWs}~!xcVf&3($i`py`*+c$Nk2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