mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-05 22:48:27 +00:00
fix: update repair cost logic to set value only for positive amounts
(cherry picked from commit 00ffdee928)
This commit is contained in:
@@ -128,7 +128,7 @@ frappe.ui.form.on("Asset Repair Purchase Invoice", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
expense_account: function (frm, cdt, cdn) {
|
expense_account: function (frm, cdt, cdn) {
|
||||||
var row = locals[cdt][cdn];
|
let row = locals[cdt][cdn];
|
||||||
|
|
||||||
if (!row.purchase_invoice || !row.expense_account) {
|
if (!row.purchase_invoice || !row.expense_account) {
|
||||||
frappe.model.set_value(cdt, cdn, "repair_cost", 0);
|
frappe.model.set_value(cdt, cdn, "repair_cost", 0);
|
||||||
@@ -143,13 +143,19 @@ frappe.ui.form.on("Asset Repair Purchase Invoice", {
|
|||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
if (r.message !== undefined) {
|
if (r.message !== undefined) {
|
||||||
frappe.model.set_value(cdt, cdn, "repair_cost", r.message);
|
if (r.message > 0) {
|
||||||
|
frappe.model.set_value(cdt, cdn, "repair_cost", r.message);
|
||||||
if (r.message <= 0) {
|
} else {
|
||||||
|
frappe.model.set_value(cdt, cdn, "repair_cost", 0);
|
||||||
|
let pi_link = frappe.utils.get_form_link(
|
||||||
|
"Purchase Invoice",
|
||||||
|
row.purchase_invoice,
|
||||||
|
true
|
||||||
|
);
|
||||||
frappe.msgprint({
|
frappe.msgprint({
|
||||||
title: __("No Available Amount"),
|
|
||||||
message: __(
|
message: __(
|
||||||
"There is no available repair cost for this Purchase Invoice and Expense Account combination."
|
"Row {0}: The entire expense amount for account {1} in {2} has already been allocated.",
|
||||||
|
[row.idx, row.expense_account.bold(), pi_link]
|
||||||
),
|
),
|
||||||
indicator: "orange",
|
indicator: "orange",
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user