From 2d283514cfbc515083d02f1b80eec226eac33270 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Fri, 5 Jul 2024 18:45:01 +0200 Subject: [PATCH] fix: remove down payment validation --- .../doctype/purchase_invoice/purchase_invoice.py | 1 - .../doctype/sales_invoice/sales_invoice.py | 15 +++++++-------- erpnext/controllers/accounts_controller.py | 9 --------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 12c39cd8cb..e07a7b33a4 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -294,7 +294,6 @@ class PurchaseInvoice(BuyingController): self.validate_write_off_account() self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount") self.create_remarks() - self.validate_down_payment_advances() self.set_status() self.validate_purchase_receipt_if_update_stock() validate_inter_company_party( diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index a0bf89e7e9..6bd0a98fca 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -239,7 +239,7 @@ class SalesInvoice(SellingController): # end: auto-generated types def __init__(self, *args, **kwargs): - super(SalesInvoice, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.status_updater = [ { "source_dt": "Sales Invoice Item", @@ -276,7 +276,7 @@ class SalesInvoice(SellingController): self.indicator_title = _("Paid") def validate(self): - super(SalesInvoice, self).validate() + super().validate() self.validate_auto_set_posting_time() self.validate_posting_datetime_chronology() @@ -298,7 +298,6 @@ class SalesInvoice(SellingController): self.clear_unallocated_advances("Sales Invoice Advance", "advances") self.add_remarks() self.validate_fixed_asset() - self.validate_down_payment_advances() self.set_income_account_for_fixed_assets() self.set_income_account_for_down_payments() self.validate_item_cost_centers() @@ -563,7 +562,7 @@ class SalesInvoice(SellingController): def on_cancel(self): check_if_return_invoice_linked_with_payment_entry(self) - super(SalesInvoice, self).on_cancel() + super().on_cancel() self.check_sales_order_on_hold_or_close("sales_order") @@ -710,7 +709,7 @@ class SalesInvoice(SellingController): if not self.due_date and self.customer: self.due_date = get_due_date(self.posting_date, "Customer", self.customer, self.company) - super(SalesInvoice, self).set_missing_values(for_validate) + super().set_missing_values(for_validate) print_format = pos.get("print_format") if pos else None if not print_format and not cint(frappe.db.get_value("Print Format", "POS Invoice", "disabled")): @@ -936,7 +935,7 @@ class SalesInvoice(SellingController): ) def validate_with_previous_doc(self): - super(SalesInvoice, self).validate_with_previous_doc( + super().validate_with_previous_doc( { "Sales Order": { "ref_dn_field": "sales_order", @@ -1050,7 +1049,7 @@ class SalesInvoice(SellingController): frappe.throw(_("Paid amount + Write Off Amount can not be greater than Grand Total")) def validate_warehouse(self): - super(SalesInvoice, self).validate_warehouse() + super().validate_warehouse() for d in self.get_item_list(): if ( @@ -1475,7 +1474,7 @@ class SalesInvoice(SellingController): # expense account gl entries if cint(self.update_stock) and erpnext.is_perpetual_inventory_enabled(self.company): - gl_entries += super(SalesInvoice, self).get_gl_entries() + gl_entries += super().get_gl_entries() def get_asset(self, item): if item.get("asset"): diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 6e04e335ce..d6085101fd 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2551,15 +2551,6 @@ class AccountsController(TransactionBase): else: frappe.throw(_("No updates pending for reposting")) - def validate_down_payment_advances(self): - for advance in self.get("advances"): - if ( - flt(advance.allocated_amount) <= flt(advance.advance_amount) - and advance.reference_type == "Payment Entry" - and cint(advance.is_down_payment) - ): - advance.allocated_amount = advance.advance_amount - def make_down_payment_final_invoice_entries(self, gl_entries): # In the case of a down payment with multiple payments, associated entries of # the gl_entries list would be credited/debited multiple times if we didn't make -- GitLab