Skip to content

Commit

Permalink
fix: calculate correct amount for qty == 0 (#33739)
Browse files Browse the repository at this point in the history
fix: calculate correct amount for qty == 0 (#33739)

(cherry picked from commit 327b6fd)

Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
  • Loading branch information
mergify[bot] and barredterra authored Jan 20, 2023
1 parent cf6d454 commit 1c1c903
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions erpnext/public/js/controllers/taxes_and_totals.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,16 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
calculate_item_values() {
var me = this;
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);
item.net_rate = item.rate;

if ((!item.qty) && me.frm.doc.is_return) {
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.qty = item.qty === undefined ? (me.frm.doc.is_return ? -1 : 1) : item.qty;
item.net_amount = item.amount = flt(item.rate * item.qty, precision("amount", item));
item.item_tax_amount = 0.0;
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"]);
});
}
}
}

Expand Down

0 comments on commit 1c1c903

Please sign in to comment.