Replaced renamed total fields in code files
This commit is contained in:
@@ -18,7 +18,7 @@ class AccountsController(TransactionBase):
|
||||
self.validate_date_with_fiscal_year()
|
||||
if self.meta.get_field("currency"):
|
||||
self.calculate_taxes_and_totals()
|
||||
self.validate_value("grand_total", ">=", 0)
|
||||
self.validate_value("base_grand_total", ">=", 0)
|
||||
self.set_total_in_words()
|
||||
|
||||
self.validate_due_date()
|
||||
@@ -291,7 +291,7 @@ class AccountsController(TransactionBase):
|
||||
self.precision("tax_amount", tax))
|
||||
|
||||
def adjust_discount_amount_loss(self, tax):
|
||||
discount_amount_loss = self.grand_total - flt(self.base_discount_amount) - tax.total
|
||||
discount_amount_loss = self.base_grand_total - flt(self.base_discount_amount) - tax.total
|
||||
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
|
||||
discount_amount_loss, self.precision("tax_amount", tax))
|
||||
tax.total = flt(tax.total + discount_amount_loss, self.precision("total", tax))
|
||||
@@ -303,8 +303,8 @@ class AccountsController(TransactionBase):
|
||||
if tax.charge_type == "Actual":
|
||||
# distribute the tax amount proportionally to each item row
|
||||
actual = flt(tax.rate, self.precision("tax_amount", tax))
|
||||
current_tax_amount = (self.net_total
|
||||
and ((item.base_amount / self.net_total) * actual)
|
||||
current_tax_amount = (self.base_net_total
|
||||
and ((item.base_amount / self.base_net_total) * actual)
|
||||
or 0)
|
||||
elif tax.charge_type == "On Net Total":
|
||||
current_tax_amount = (tax_rate / 100.0) * item.base_amount
|
||||
@@ -510,12 +510,12 @@ class AccountsController(TransactionBase):
|
||||
|
||||
if advance_paid:
|
||||
advance_paid = flt(advance_paid[0][0], self.precision("advance_paid"))
|
||||
if flt(self.grand_total) >= advance_paid:
|
||||
if flt(self.base_grand_total) >= advance_paid:
|
||||
frappe.db.set_value(self.doctype, self.name, "advance_paid", advance_paid)
|
||||
else:
|
||||
frappe.throw(_("Total advance ({0}) against Order {1} cannot be greater \
|
||||
than the Grand Total ({2})")
|
||||
.format(advance_paid, self.name, self.grand_total))
|
||||
.format(advance_paid, self.name, self.base_grand_total))
|
||||
|
||||
@property
|
||||
def company_abbr(self):
|
||||
|
||||
@@ -21,7 +21,7 @@ class BuyingController(StockController):
|
||||
|
||||
def get_feed(self):
|
||||
return _("From {0} | {1} {2}").format(self.supplier_name, self.currency,
|
||||
self.grand_total_import)
|
||||
self.grand_total)
|
||||
|
||||
def validate(self):
|
||||
super(BuyingController, self).validate()
|
||||
@@ -74,10 +74,10 @@ class BuyingController(StockController):
|
||||
def set_total_in_words(self):
|
||||
from frappe.utils import money_in_words
|
||||
company_currency = get_company_currency(self.company)
|
||||
if self.meta.get_field("base_in_words"):
|
||||
self.base_in_words = money_in_words(self.base_grand_total, company_currency)
|
||||
if self.meta.get_field("in_words"):
|
||||
self.in_words = money_in_words(self.grand_total, company_currency)
|
||||
if self.meta.get_field("in_words_import"):
|
||||
self.in_words_import = money_in_words(self.grand_total_import,
|
||||
self.in_words = money_in_words(self.grand_total,
|
||||
self.currency)
|
||||
|
||||
def calculate_taxes_and_totals(self):
|
||||
@@ -103,55 +103,55 @@ class BuyingController(StockController):
|
||||
|
||||
|
||||
def calculate_net_total(self):
|
||||
self.net_total = self.net_total_import = 0.0
|
||||
self.base_net_total = self.net_total = 0.0
|
||||
|
||||
for item in self.get("items"):
|
||||
self.net_total += item.base_amount
|
||||
self.net_total_import += item.amount
|
||||
self.base_net_total += item.base_amount
|
||||
self.net_total += item.amount
|
||||
|
||||
self.round_floats_in(self, ["net_total", "net_total_import"])
|
||||
self.round_floats_in(self, ["base_net_total", "net_total"])
|
||||
|
||||
def calculate_totals(self):
|
||||
self.grand_total = flt(self.get("taxes")[-1].total if self.get("taxes") else self.net_total)
|
||||
self.base_grand_total = flt(self.get("taxes")[-1].total if self.get("taxes") else self.base_net_total)
|
||||
|
||||
self.total_tax = flt(self.grand_total - self.net_total, self.precision("total_tax"))
|
||||
self.base_total_taxes_and_charges = flt(self.base_grand_total - self.base_net_total, self.precision("base_total_taxes_and_charges"))
|
||||
|
||||
self.base_grand_total = flt(self.base_grand_total, self.precision("base_grand_total"))
|
||||
|
||||
if self.meta.get_field("base_rounded_total"):
|
||||
self.base_rounded_total = rounded(self.base_grand_total)
|
||||
|
||||
if self.meta.get_field("base_taxes_and_charges_added"):
|
||||
self.base_taxes_and_charges_added = flt(sum([flt(d.tax_amount) for d in self.get("taxes")
|
||||
if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.precision("base_taxes_and_charges_added"))
|
||||
|
||||
if self.meta.get_field("base_taxes_and_charges_deducted"):
|
||||
self.base_taxes_and_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.get("taxes")
|
||||
if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.precision("base_taxes_and_charges_deducted"))
|
||||
|
||||
self.grand_total = flt(self.base_grand_total / self.conversion_rate) \
|
||||
if (self.base_taxes_and_charges_added or self.base_taxes_and_charges_deducted) else self.net_total
|
||||
|
||||
self.grand_total = flt(self.grand_total, self.precision("grand_total"))
|
||||
|
||||
if self.meta.get_field("rounded_total"):
|
||||
self.rounded_total = rounded(self.grand_total)
|
||||
|
||||
if self.meta.get_field("other_charges_added"):
|
||||
self.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.get("taxes")
|
||||
if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.precision("other_charges_added"))
|
||||
if self.meta.get_field("taxes_and_charges_added"):
|
||||
self.taxes_and_charges_added = flt(self.base_taxes_and_charges_added /
|
||||
self.conversion_rate, self.precision("taxes_and_charges_added"))
|
||||
|
||||
if self.meta.get_field("other_charges_deducted"):
|
||||
self.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.get("taxes")
|
||||
if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.precision("other_charges_deducted"))
|
||||
|
||||
self.grand_total_import = flt(self.grand_total / self.conversion_rate) \
|
||||
if (self.other_charges_added or self.other_charges_deducted) else self.net_total_import
|
||||
|
||||
self.grand_total_import = flt(self.grand_total_import, self.precision("grand_total_import"))
|
||||
|
||||
if self.meta.get_field("rounded_total_import"):
|
||||
self.rounded_total_import = rounded(self.grand_total_import)
|
||||
|
||||
if self.meta.get_field("other_charges_added_import"):
|
||||
self.other_charges_added_import = flt(self.other_charges_added /
|
||||
self.conversion_rate, self.precision("other_charges_added_import"))
|
||||
|
||||
if self.meta.get_field("other_charges_deducted_import"):
|
||||
self.other_charges_deducted_import = flt(self.other_charges_deducted /
|
||||
self.conversion_rate, self.precision("other_charges_deducted_import"))
|
||||
if self.meta.get_field("taxes_and_charges_deducted"):
|
||||
self.taxes_and_charges_deducted = flt(self.base_taxes_and_charges_deducted /
|
||||
self.conversion_rate, self.precision("taxes_and_charges_deducted"))
|
||||
|
||||
def calculate_outstanding_amount(self):
|
||||
if self.doctype == "Purchase Invoice" and self.docstatus == 0:
|
||||
self.total_advance = flt(self.total_advance,
|
||||
self.precision("total_advance"))
|
||||
self.total_amount_to_pay = flt(self.grand_total - flt(self.write_off_amount,
|
||||
self.total_amount_to_pay = flt(self.base_grand_total - flt(self.write_off_amount,
|
||||
self.precision("write_off_amount")), self.precision("total_amount_to_pay"))
|
||||
self.outstanding_amount = flt(self.total_amount_to_pay - self.total_advance,
|
||||
self.precision("outstanding_amount"))
|
||||
|
||||
@@ -19,7 +19,7 @@ class SellingController(StockController):
|
||||
|
||||
def get_feed(self):
|
||||
return _("To {0} | {1} {2}").format(self.customer_name, self.currency,
|
||||
self.grand_total_export)
|
||||
self.grand_total)
|
||||
|
||||
def onload(self):
|
||||
if self.doctype in ("Sales Order", "Delivery Note", "Sales Invoice"):
|
||||
@@ -65,7 +65,7 @@ class SellingController(StockController):
|
||||
def apply_shipping_rule(self):
|
||||
if self.shipping_rule:
|
||||
shipping_rule = frappe.get_doc("Shipping Rule", self.shipping_rule)
|
||||
value = self.net_total
|
||||
value = self.base_net_total
|
||||
|
||||
# TODO
|
||||
# shipping rule calculation based on item's net weight
|
||||
@@ -114,12 +114,12 @@ class SellingController(StockController):
|
||||
disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None,
|
||||
"disable_rounded_total"))
|
||||
|
||||
if self.meta.get_field("base_in_words"):
|
||||
self.base_in_words = money_in_words(disable_rounded_total and
|
||||
self.base_grand_total or self.base_rounded_total, company_currency)
|
||||
if self.meta.get_field("in_words"):
|
||||
self.in_words = money_in_words(disable_rounded_total and
|
||||
self.grand_total or self.rounded_total, company_currency)
|
||||
if self.meta.get_field("in_words_export"):
|
||||
self.in_words_export = money_in_words(disable_rounded_total and
|
||||
self.grand_total_export or self.rounded_total_export, self.currency)
|
||||
self.grand_total or self.rounded_total, self.currency)
|
||||
|
||||
def calculate_taxes_and_totals(self):
|
||||
super(SellingController, self).calculate_taxes_and_totals()
|
||||
@@ -204,30 +204,30 @@ class SellingController(StockController):
|
||||
self._set_in_company_currency(item, "amount", "base_amount")
|
||||
|
||||
def calculate_net_total(self):
|
||||
self.net_total = self.net_total_export = 0.0
|
||||
self.base_net_total = self.net_total = 0.0
|
||||
|
||||
for item in self.get("items"):
|
||||
self.net_total += item.base_amount
|
||||
self.net_total_export += item.amount
|
||||
self.base_net_total += item.base_amount
|
||||
self.net_total += item.amount
|
||||
|
||||
self.round_floats_in(self, ["net_total", "net_total_export"])
|
||||
self.round_floats_in(self, ["base_net_total", "net_total"])
|
||||
|
||||
def calculate_totals(self):
|
||||
self.grand_total = flt(self.get("taxes")[-1].total if self.get("taxes") else self.net_total)
|
||||
self.base_grand_total = flt(self.get("taxes")[-1].total if self.get("taxes") else self.base_net_total)
|
||||
|
||||
self.other_charges_total = flt(self.grand_total - self.net_total, self.precision("other_charges_total"))
|
||||
self.base_total_taxes_and_charges = flt(self.base_grand_total - self.base_net_total, self.precision("base_total_taxes_and_charges"))
|
||||
|
||||
self.grand_total_export = flt(self.grand_total / self.conversion_rate) \
|
||||
if (self.other_charges_total or self.discount_amount) else self.net_total_export
|
||||
self.grand_total = flt(self.base_grand_total / self.conversion_rate) \
|
||||
if (self.base_total_taxes_and_charges or self.discount_amount) else self.net_total
|
||||
|
||||
self.other_charges_total_export = flt(self.grand_total_export - self.net_total_export +
|
||||
flt(self.discount_amount), self.precision("other_charges_total_export"))
|
||||
self.total_taxes_and_charges = flt(self.grand_total - self.net_total +
|
||||
flt(self.discount_amount), self.precision("total_taxes_and_charges"))
|
||||
|
||||
self.base_grand_total = flt(self.base_grand_total, self.precision("base_grand_total"))
|
||||
self.grand_total = flt(self.grand_total, self.precision("grand_total"))
|
||||
self.grand_total_export = flt(self.grand_total_export, self.precision("grand_total_export"))
|
||||
|
||||
self.base_rounded_total = rounded(self.base_grand_total)
|
||||
self.rounded_total = rounded(self.grand_total)
|
||||
self.rounded_total_export = rounded(self.grand_total_export)
|
||||
|
||||
def apply_discount_amount(self):
|
||||
if self.discount_amount:
|
||||
@@ -257,8 +257,8 @@ class SellingController(StockController):
|
||||
flt(tax.rate) / 100
|
||||
actual_taxes_dict.setdefault(tax.idx, actual_tax_amount)
|
||||
|
||||
grand_total_for_discount_amount = flt(self.grand_total - sum(actual_taxes_dict.values()),
|
||||
self.precision("grand_total"))
|
||||
grand_total_for_discount_amount = flt(self.base_grand_total - sum(actual_taxes_dict.values()),
|
||||
self.precision("base_grand_total"))
|
||||
return grand_total_for_discount_amount
|
||||
|
||||
def calculate_outstanding_amount(self):
|
||||
@@ -266,19 +266,19 @@ class SellingController(StockController):
|
||||
# write_off_amount is only for POS Invoice
|
||||
# total_advance is only for non POS Invoice
|
||||
if self.doctype == "Sales Invoice" and self.docstatus == 0:
|
||||
self.round_floats_in(self, ["grand_total", "total_advance", "write_off_amount",
|
||||
self.round_floats_in(self, ["base_grand_total", "total_advance", "write_off_amount",
|
||||
"paid_amount"])
|
||||
total_amount_to_pay = self.grand_total - self.write_off_amount
|
||||
total_amount_to_pay = self.base_grand_total - self.write_off_amount
|
||||
self.outstanding_amount = flt(total_amount_to_pay - self.total_advance \
|
||||
- self.paid_amount, self.precision("outstanding_amount"))
|
||||
|
||||
def calculate_commission(self):
|
||||
if self.meta.get_field("commission_rate"):
|
||||
self.round_floats_in(self, ["net_total", "commission_rate"])
|
||||
self.round_floats_in(self, ["base_net_total", "commission_rate"])
|
||||
if self.commission_rate > 100.0:
|
||||
throw(_("Commission rate cannot be greater than 100"))
|
||||
|
||||
self.total_commission = flt(self.net_total * self.commission_rate / 100.0,
|
||||
self.total_commission = flt(self.base_net_total * self.commission_rate / 100.0,
|
||||
self.precision("total_commission"))
|
||||
|
||||
def calculate_contribution(self):
|
||||
@@ -291,7 +291,7 @@ class SellingController(StockController):
|
||||
self.round_floats_in(sales_person)
|
||||
|
||||
sales_person.allocated_amount = flt(
|
||||
self.net_total * sales_person.allocated_percentage / 100.0,
|
||||
self.base_net_total * sales_person.allocated_percentage / 100.0,
|
||||
self.precision("allocated_amount", sales_person))
|
||||
|
||||
total += sales_person.allocated_percentage
|
||||
|
||||
@@ -196,7 +196,7 @@ class StatusUpdater(Document):
|
||||
ref_fieldname = ref_dt.lower().replace(" ", "_")
|
||||
zero_amount_refdoc = []
|
||||
all_zero_amount_refdoc = frappe.db.sql_list("""select name from `tab%s`
|
||||
where docstatus=1 and net_total = 0""" % ref_dt)
|
||||
where docstatus=1 and base_net_total = 0""" % ref_dt)
|
||||
|
||||
for item in self.get("items"):
|
||||
if item.get(ref_fieldname) \
|
||||
|
||||
Reference in New Issue
Block a user