fix: calculate correct amount for qty == 0 (#33739)
This commit is contained in:
parent
a94aa7a79f
commit
327b6fdb32
@ -122,24 +122,16 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
calculate_item_values() {
|
calculate_item_values() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (!this.discount_amount_applied) {
|
if (!this.discount_amount_applied) {
|
||||||
$.each(this.frm.doc["items"] || [], function(i, item) {
|
for (item of this.frm.doc.items || []) {
|
||||||
frappe.model.round_floats_in(item);
|
frappe.model.round_floats_in(item);
|
||||||
item.net_rate = item.rate;
|
item.net_rate = item.rate;
|
||||||
|
item.qty = item.qty === undefined ? (me.frm.doc.is_return ? -1 : 1) : item.qty;
|
||||||
if ((!item.qty) && me.frm.doc.is_return) {
|
item.net_amount = item.amount = flt(item.rate * item.qty, precision("amount", item));
|
||||||
item.amount = flt(item.rate * -1, precision("amount", item));
|
|
||||||
} else if ((!item.qty) && me.frm.doc.is_debit_note) {
|
|
||||||
item.amount = flt(item.rate, precision("amount", item));
|
|
||||||
} else {
|
|
||||||
item.amount = flt(item.rate * item.qty, precision("amount", item));
|
|
||||||
}
|
|
||||||
|
|
||||||
item.net_amount = item.amount;
|
|
||||||
item.item_tax_amount = 0.0;
|
item.item_tax_amount = 0.0;
|
||||||
item.total_weight = flt(item.weight_per_unit * item.stock_qty);
|
item.total_weight = flt(item.weight_per_unit * item.stock_qty);
|
||||||
|
|
||||||
me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]);
|
me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user