Merge pull request #19137 from marination/invoice-discounting

fix: Outstanding Amount field of Discounted Invoices Table in Invoice Discounting
This commit is contained in:
Deepesh Garg 2019-09-30 12:43:09 +05:30 committed by GitHub
commit 91aa671a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View File

@ -38,13 +38,13 @@
"read_only": 1
},
{
"fetch_from": "sales_invoice.grand_total",
"fetch_from": "sales_invoice.outstanding_amount",
"fetch_if_empty": 1,
"fieldname": "outstanding_amount",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Outstanding Amount",
"options": "Company:company:default_currency",
"read_only": 1
"options": "Company:company:default_currency"
},
{
"fieldname": "column_break_3",
@ -60,7 +60,7 @@
}
],
"istable": 1,
"modified": "2019-08-07 15:13:55.808349",
"modified": "2019-09-26 11:05:36.016772",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Discounted Invoice",

View File

@ -97,7 +97,6 @@ frappe.ui.form.on('Invoice Discounting', {
}
frm.set_value("total_amount", total_amount);
},
get_invoices: (frm) => {
var d = new frappe.ui.Dialog({
title: __('Get Invoices based on Filters'),

View File

@ -26,14 +26,20 @@ class InvoiceDiscounting(AccountsController):
frappe.throw(_("Loan Start Date and Loan Period are mandatory to save the Invoice Discounting"))
def validate_invoices(self):
discounted_invoices = [record.sales_invoice for record in
frappe.get_all("Discounted Invoice",fields = ["sales_invoice"], filters= {"docstatus":1})]
discounted_invoices = [record.sales_invoice for record in
frappe.get_all("Discounted Invoice",fields=["sales_invoice"], filters={"docstatus":1})]
for record in self.invoices:
if record.sales_invoice in discounted_invoices:
frappe.throw("Row({0}): {1} is already discounted in {2}"
frappe.throw(_("Row({0}): {1} is already discounted in {2}")
.format(record.idx, frappe.bold(record.sales_invoice), frappe.bold(record.parent)))
actual_outstanding = frappe.db.get_value("Sales Invoice", record.sales_invoice,"outstanding_amount")
if record.outstanding_amount > actual_outstanding :
frappe.throw(_
("Row({0}): Outstanding Amount cannot be greater than actual Outstanding Amount {1} in {2}").format(
record.idx, frappe.bold(actual_outstanding), frappe.bold(record.sales_invoice)))
def calculate_total_amount(self):
self.total_amount = sum([flt(d.outstanding_amount) for d in self.invoices])