diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 933090d1619..d9bac98f369 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -371,14 +371,14 @@ class calculate_taxes_and_totals(object): return grand_total_for_discount_amount - def calculate_total_advance(self, parenttype, advance_parentfield): - if self.docstatus < 2: + def calculate_total_advance(self): + if self.doc.docstatus < 2: sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.doc.precision("allocated_amount", adv)) for adv in self.doc.get("advances")]) self.doc.total_advance = flt(sum_of_allocated_amount, self.doc.precision("total_advance")) - if self.docstatus == 0: + if self.doc.docstatus == 0: self.calculate_outstanding_amount() def calculate_outstanding_amount(self): diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index a4c54b445cf..7340baf78d2 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -151,19 +151,19 @@ class update_entries_after(object): if sle.serial_no: self.valuation_rate = self.get_serialized_values(sle) self.qty_after_transaction += flt(sle.actual_qty) - self.stock_value = self.qty_after_transaction * self.valuation_rate + self.stock_value = flt(self.qty_after_transaction) * flt(self.valuation_rate) else: if sle.voucher_type=="Stock Reconciliation": # assert self.valuation_rate = sle.valuation_rate self.qty_after_transaction = sle.qty_after_transaction self.stock_queue = [[self.qty_after_transaction, self.valuation_rate]] - self.stock_value = self.qty_after_transaction * self.valuation_rate + self.stock_value = flt(self.qty_after_transaction) * flt(self.valuation_rate) else: if self.valuation_method == "Moving Average": self.get_moving_average_values(sle) self.qty_after_transaction += flt(sle.actual_qty) - self.stock_value = self.qty_after_transaction * self.valuation_rate + self.stock_value = flt(self.qty_after_transaction) * flt(self.valuation_rate) else: self.get_fifo_values(sle) self.qty_after_transaction += flt(sle.actual_qty) @@ -181,7 +181,8 @@ class update_entries_after(object): sle.valuation_rate = self.valuation_rate sle.stock_queue = json.dumps(self.stock_queue) sle.stock_value_difference = stock_value_difference - sle.save() + sle.doctype="Stock Ledger Entry" + frappe.get_doc(sle).db_update() def validate_negative_stock(self, sle): """