fix: Advance payment against payment terms (#34872)
* fix: Advance payment against payment terms (#34872)
(cherry picked from commit 5c75894065)
# Conflicts:
# erpnext/accounts/doctype/payment_entry/payment_entry.py
* chore: resolve conflicts
* chore: fix tests
---------
Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
@@ -175,6 +175,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
|
"description": "Payment Terms from orders will be fetched into the invoices as is",
|
||||||
"fieldname": "automatically_fetch_payment_terms",
|
"fieldname": "automatically_fetch_payment_terms",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Automatically Fetch Payment Terms from Order"
|
"label": "Automatically Fetch Payment Terms from Order"
|
||||||
@@ -299,7 +300,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-03-28 09:50:20.375233",
|
"modified": "2023-04-14 17:22:03.680886",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounts Settings",
|
"name": "Accounts Settings",
|
||||||
|
|||||||
@@ -1917,7 +1917,12 @@ def get_payment_entry(
|
|||||||
if doc.doctype == "Purchase Invoice" and doc.invoice_is_blocked():
|
if doc.doctype == "Purchase Invoice" and doc.invoice_is_blocked():
|
||||||
frappe.msgprint(_("{0} is on hold till {1}").format(doc.name, doc.release_date))
|
frappe.msgprint(_("{0} is on hold till {1}").format(doc.name, doc.release_date))
|
||||||
else:
|
else:
|
||||||
if doc.doctype in ("Sales Invoice", "Purchase Invoice") and frappe.get_value(
|
if doc.doctype in (
|
||||||
|
"Sales Invoice",
|
||||||
|
"Purchase Invoice",
|
||||||
|
"Purchase Order",
|
||||||
|
"Sales Order",
|
||||||
|
) and frappe.get_value(
|
||||||
"Payment Terms Template",
|
"Payment Terms Template",
|
||||||
{"name": doc.payment_terms_template},
|
{"name": doc.payment_terms_template},
|
||||||
"allocate_payment_based_on_payment_terms",
|
"allocate_payment_based_on_payment_terms",
|
||||||
|
|||||||
@@ -256,8 +256,8 @@ class AccountsController(TransactionBase):
|
|||||||
self.validate_payment_schedule_dates()
|
self.validate_payment_schedule_dates()
|
||||||
self.set_due_date()
|
self.set_due_date()
|
||||||
self.set_payment_schedule()
|
self.set_payment_schedule()
|
||||||
self.validate_payment_schedule_amount()
|
|
||||||
if not self.get("ignore_default_payment_terms_template"):
|
if not self.get("ignore_default_payment_terms_template"):
|
||||||
|
self.validate_payment_schedule_amount()
|
||||||
self.validate_due_date()
|
self.validate_due_date()
|
||||||
self.validate_advance_entries()
|
self.validate_advance_entries()
|
||||||
|
|
||||||
@@ -1577,6 +1577,7 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
base_grand_total = self.get("base_rounded_total") or self.base_grand_total
|
base_grand_total = self.get("base_rounded_total") or self.base_grand_total
|
||||||
grand_total = self.get("rounded_total") or self.grand_total
|
grand_total = self.get("rounded_total") or self.grand_total
|
||||||
|
automatically_fetch_payment_terms = 0
|
||||||
|
|
||||||
if self.doctype in ("Sales Invoice", "Purchase Invoice"):
|
if self.doctype in ("Sales Invoice", "Purchase Invoice"):
|
||||||
base_grand_total = base_grand_total - flt(self.base_write_off_amount)
|
base_grand_total = base_grand_total - flt(self.base_write_off_amount)
|
||||||
@@ -1622,6 +1623,7 @@ class AccountsController(TransactionBase):
|
|||||||
)
|
)
|
||||||
self.append("payment_schedule", data)
|
self.append("payment_schedule", data)
|
||||||
|
|
||||||
|
if not automatically_fetch_payment_terms:
|
||||||
for d in self.get("payment_schedule"):
|
for d in self.get("payment_schedule"):
|
||||||
if d.invoice_portion:
|
if d.invoice_portion:
|
||||||
d.payment_amount = flt(
|
d.payment_amount = flt(
|
||||||
@@ -1687,6 +1689,10 @@ class AccountsController(TransactionBase):
|
|||||||
"invoice_portion": schedule.invoice_portion,
|
"invoice_portion": schedule.invoice_portion,
|
||||||
"mode_of_payment": schedule.mode_of_payment,
|
"mode_of_payment": schedule.mode_of_payment,
|
||||||
"description": schedule.description,
|
"description": schedule.description,
|
||||||
|
"payment_amount": schedule.payment_amount,
|
||||||
|
"base_payment_amount": schedule.base_payment_amount,
|
||||||
|
"outstanding": schedule.outstanding,
|
||||||
|
"paid_amount": schedule.paid_amount,
|
||||||
}
|
}
|
||||||
|
|
||||||
if schedule.discount_type == "Percentage":
|
if schedule.discount_type == "Percentage":
|
||||||
|
|||||||
@@ -2011,7 +2011,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
prompt_user_for_reference_date(){
|
prompt_user_for_reference_date(){
|
||||||
var me = this;
|
let me = this;
|
||||||
frappe.prompt({
|
frappe.prompt({
|
||||||
label: __("Cheque/Reference Date"),
|
label: __("Cheque/Reference Date"),
|
||||||
fieldname: "reference_date",
|
fieldname: "reference_date",
|
||||||
@@ -2038,7 +2038,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
let has_payment_schedule = this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length;
|
let has_payment_schedule = this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length;
|
||||||
if(!is_eligible || !has_payment_schedule) return false;
|
if(!is_eligible || !has_payment_schedule) return false;
|
||||||
|
|
||||||
let has_discount = this.frm.doc.payment_schedule.some(row => row.discount_date);
|
let has_discount = this.frm.doc.payment_schedule.some(row => row.discount);
|
||||||
return has_discount;
|
return has_discount;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user