From 6a0d4f1aec322edf217b8dab4556ec5f22adcf08 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 25 Sep 2024 13:32:05 +0530 Subject: [PATCH] chore: linter changes --- .../doctype/journal_entry/journal_entry.py | 6 ++-- .../doctype/payment_entry/payment_entry.py | 6 ++-- .../payment_request/payment_request.py | 12 ++++---- erpnext/accounts/utils.py | 13 ++++----- .../purchase_order/test_purchase_order.py | 12 ++------ erpnext/controllers/accounts_controller.py | 4 +-- .../v15_0/create_advance_payment_status.py | 28 ++++++++----------- .../doctype/sales_order/test_sales_order.py | 12 ++------ 8 files changed, 37 insertions(+), 56 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 31037d26c1ce..780c8590bc1b 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -233,9 +233,9 @@ def get_title(self): def update_advance_paid(self): advance_paid = frappe._dict() - advance_payment_doctypes = frappe.get_hooks( - "advance_payment_customer_doctypes" - ) + frappe.get_hooks("advance_payment_supplier_doctypes") + advance_payment_doctypes = frappe.get_hooks("advance_payment_customer_doctypes") + frappe.get_hooks( + "advance_payment_supplier_doctypes" + ) for d in self.get("accounts"): if d.is_advance: if d.reference_type in advance_payment_doctypes: diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 125b2c351821..56f8e8da96aa 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -919,9 +919,9 @@ def set_amounts_in_company_currency(self): def calculate_base_allocated_amount_for_reference(self, d) -> float: base_allocated_amount = 0 - advance_payment_doctypes = frappe.get_hooks( - "advance_payment_customer_doctypes" - ) + frappe.get_hooks("advance_payment_supplier_doctypes") + advance_payment_doctypes = frappe.get_hooks("advance_payment_customer_doctypes") + frappe.get_hooks( + "advance_payment_supplier_doctypes" + ) if d.reference_doctype in advance_payment_doctypes: # When referencing Sales/Purchase Order, use the source/target exchange rate depending on payment type. # This is so there are no Exchange Gain/Loss generated for such doctypes diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index 0f7280760f5e..4b885a401328 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -170,9 +170,9 @@ def on_submit(self): elif self.payment_channel == "Phone": self.request_phone_payment() - advance_payment_doctypes = frappe.get_hooks( - "advance_payment_customer_doctypes" - ) + frappe.get_hooks("advance_payment_supplier_doctypes") + advance_payment_doctypes = frappe.get_hooks("advance_payment_customer_doctypes") + frappe.get_hooks( + "advance_payment_supplier_doctypes" + ) if self.reference_doctype in advance_payment_doctypes: # set advance payment status ref_doc.set_total_advance_paid() @@ -215,9 +215,9 @@ def on_cancel(self): self.check_if_payment_entry_exists() self.set_as_cancelled() ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) - advance_payment_doctypes = frappe.get_hooks( - "advance_payment_customer_doctypes" - ) + frappe.get_hooks("advance_payment_supplier_doctypes") + advance_payment_doctypes = frappe.get_hooks("advance_payment_customer_doctypes") + frappe.get_hooks( + "advance_payment_supplier_doctypes" + ) if self.reference_doctype in advance_payment_doctypes: # set advance payment status ref_doc.set_total_advance_paid() diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 8afeed2d8d34..a5f4d9c88ea8 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -618,13 +618,12 @@ def update_reference_in_journal_entry(d, journal_entry, do_not_save=False): # Update Advance Paid in SO/PO since they might be getting unlinked update_advance_paid = [] - advance_payment_doctypes = frappe.get_hooks( - "advance_payment_customer_doctypes" - ) + frappe.get_hooks("advance_payment_supplier_doctypes") + advance_payment_doctypes = frappe.get_hooks("advance_payment_customer_doctypes") + frappe.get_hooks( + "advance_payment_supplier_doctypes" + ) if jv_detail.get("reference_type") in advance_payment_doctypes: update_advance_paid.append((jv_detail.reference_type, jv_detail.reference_name)) - if flt(d["unadjusted_amount"]) - flt(d["allocated_amount"]) != 0: # adjust the unreconciled balance amount_in_account_currency = flt(d["unadjusted_amount"]) - flt(d["allocated_amount"]) @@ -699,9 +698,9 @@ def update_reference_in_payment_entry( existing_row = payment_entry.get("references", {"name": d["voucher_detail_no"]})[0] # Update Advance Paid in SO/PO since they are getting unlinked - advance_payment_doctypes = frappe.get_hooks( - "advance_payment_customer_doctypes" - ) + frappe.get_hooks("advance_payment_supplier_doctypes") + advance_payment_doctypes = frappe.get_hooks("advance_payment_customer_doctypes") + frappe.get_hooks( + "advance_payment_supplier_doctypes" + ) if existing_row.get("reference_doctype") in advance_payment_doctypes: update_advance_paid.append((existing_row.reference_doctype, existing_row.reference_name)) diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index 68407fa1e1bf..8e95f839c06b 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -1128,17 +1128,13 @@ def test_purchase_order_advance_payment_status(self): from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request po = create_purchase_order() - self.assertEqual( - frappe.db.get_value(po.doctype, po.name, "advance_payment_status"), "Not Initiated" - ) + self.assertEqual(frappe.db.get_value(po.doctype, po.name, "advance_payment_status"), "Not Initiated") pr = make_payment_request(dt=po.doctype, dn=po.name, submit_doc=True, return_doc=True) self.assertEqual(frappe.db.get_value(po.doctype, po.name, "advance_payment_status"), "Initiated") pe = get_payment_entry(po.doctype, po.name).save().submit() - self.assertEqual( - frappe.db.get_value(po.doctype, po.name, "advance_payment_status"), "Fully Paid" - ) + self.assertEqual(frappe.db.get_value(po.doctype, po.name, "advance_payment_status"), "Fully Paid") pe.reload() pe.cancel() @@ -1146,9 +1142,7 @@ def test_purchase_order_advance_payment_status(self): pr.reload() pr.cancel() - self.assertEqual( - frappe.db.get_value(po.doctype, po.name, "advance_payment_status"), "Not Initiated" - ) + self.assertEqual(frappe.db.get_value(po.doctype, po.name, "advance_payment_status"), "Not Initiated") def prepare_data_for_internal_transfer(): diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 387fece0511a..5eb9ac8f40bd 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1975,9 +1975,7 @@ def set_total_advance_paid(self): self.set_advance_payment_status(advance_paid, order_total) - def set_advance_payment_status( - self, advance_paid: float | None = None, order_total: float | None = None - ): + def set_advance_payment_status(self, advance_paid: float | None = None, order_total: float | None = None): new_status = None # if money is paid set the paid states if advance_paid: diff --git a/erpnext/patches/v15_0/create_advance_payment_status.py b/erpnext/patches/v15_0/create_advance_payment_status.py index 18ab9fa88c30..0b7163c6620e 100644 --- a/erpnext/patches/v15_0/create_advance_payment_status.py +++ b/erpnext/patches/v15_0/create_advance_payment_status.py @@ -9,16 +9,14 @@ def execute(): if frappe.reload_doc("selling", "doctype", "Sales Order"): so = frappe.qb.DocType("Sales Order") - frappe.qb.update(so).set(so.advance_payment_status, "Not Requested").where( - so.docstatus == 1 - ).where(so.advance_paid == 0.0).run() - - frappe.qb.update(so).set(so.advance_payment_status, "Partially Paid").where( - so.docstatus == 1 - ).where(so.advance_payment_status.isnull()).where( - so.advance_paid < (so.rounded_total or so.grand_total) + frappe.qb.update(so).set(so.advance_payment_status, "Not Requested").where(so.docstatus == 1).where( + so.advance_paid == 0.0 ).run() + frappe.qb.update(so).set(so.advance_payment_status, "Partially Paid").where(so.docstatus == 1).where( + so.advance_payment_status.isnull() + ).where(so.advance_paid < (so.rounded_total or so.grand_total)).run() + frappe.qb.update(so).set(so.advance_payment_status, "Fully Paid").where(so.docstatus == 1).where( so.advance_payment_status.isnull() ).where(so.advance_paid == (so.rounded_total or so.grand_total)).run() @@ -32,16 +30,14 @@ def execute(): if frappe.reload_doc("buying", "doctype", "Purchase Order"): po = frappe.qb.DocType("Purchase Order") - frappe.qb.update(po).set(po.advance_payment_status, "Not Initiated").where( - po.docstatus == 1 - ).where(po.advance_paid == 0.0).run() - - frappe.qb.update(po).set(po.advance_payment_status, "Partially Paid").where( - po.docstatus == 1 - ).where(po.advance_payment_status.isnull()).where( - po.advance_paid < (po.rounded_total or po.grand_total) + frappe.qb.update(po).set(po.advance_payment_status, "Not Initiated").where(po.docstatus == 1).where( + po.advance_paid == 0.0 ).run() + frappe.qb.update(po).set(po.advance_payment_status, "Partially Paid").where(po.docstatus == 1).where( + po.advance_payment_status.isnull() + ).where(po.advance_paid < (po.rounded_total or po.grand_total)).run() + frappe.qb.update(po).set(po.advance_payment_status, "Fully Paid").where(po.docstatus == 1).where( po.advance_payment_status.isnull() ).where(po.advance_paid == (po.rounded_total or po.grand_total)).run() diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 7c1cdd2dcf6e..6d8c6ad6decd 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -2117,17 +2117,13 @@ def test_sales_order_advance_payment_status(self): from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request so = make_sales_order(qty=1, rate=100) - self.assertEqual( - frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Not Requested" - ) + self.assertEqual(frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Not Requested") pr = make_payment_request(dt=so.doctype, dn=so.name, submit_doc=True, return_doc=True) self.assertEqual(frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Requested") pe = get_payment_entry(so.doctype, so.name).save().submit() - self.assertEqual( - frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Fully Paid" - ) + self.assertEqual(frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Fully Paid") pe.reload() pe.cancel() @@ -2135,9 +2131,7 @@ def test_sales_order_advance_payment_status(self): pr.reload() pr.cancel() - self.assertEqual( - frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Not Requested" - ) + self.assertEqual(frappe.db.get_value(so.doctype, so.name, "advance_payment_status"), "Not Requested") def automatically_fetch_payment_terms(enable=1):