mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-26 18:18:30 +00:00
fixes in tax controller and tests
This commit is contained in:
@@ -136,7 +136,7 @@ class TaxController(TransactionController):
|
||||
self.doc.net_total += item.amount
|
||||
self.doc.fields[self.fmap.net_total_print] += \
|
||||
item.fields.get(self.fmap.print_amount)
|
||||
|
||||
|
||||
self.doc.net_total = flt(self.doc.net_total, self.precision.main.net_total)
|
||||
self.doc.fields[self.fmap.net_total_print] = \
|
||||
flt(self.doc.fields.get(self.fmap.net_total_print),
|
||||
@@ -269,7 +269,7 @@ class TaxController(TransactionController):
|
||||
self.doc.rounded_total = round(self.doc.grand_total)
|
||||
self.doc.fields[self.fmap.rounded_total_print] = \
|
||||
round(self.doc.fields.get(self.fmap.grand_total_print))
|
||||
|
||||
|
||||
def set_amount_in_words(self):
|
||||
from webnotes.utils import money_in_words
|
||||
base_currency = webnotes.conn.get_value("Company", self.doc.currency,
|
||||
@@ -434,12 +434,23 @@ class TaxController(TransactionController):
|
||||
return tax.rate
|
||||
|
||||
def cleanup(self):
|
||||
def _del(f, doc):
|
||||
if f in doc.fields:
|
||||
del doc.fields[f]
|
||||
elif self.fmap.get(f) and self.fmap.get(f) in doc.fields:
|
||||
del doc.fields[self.fmap.get(f)]
|
||||
|
||||
for f in ["taxes_and_charges_total_print", "rounded_total_in_words_print",
|
||||
"rounded_total_print", "rounded_total_in_words"]:
|
||||
del self.doc.fields[self.fmap.get(f) or f]
|
||||
"rounded_total_print", "rounded_total_in_words", "rounded_total"]:
|
||||
_del(f, self.doc)
|
||||
|
||||
for f in ["grand_total_print_for_current_item", "tax_amount_print",
|
||||
"grand_total_for_current_item", "tax_amount_for_current_item",
|
||||
"total_print"]:
|
||||
for doc in self.doclist.get({"parentfield": self.fmap.taxes_and_charges}):
|
||||
del doc.fields[self.fmap.get(f) or f]
|
||||
_del(f, doc)
|
||||
|
||||
for f in ["item_tax_amount"]:
|
||||
for doc in self.doclist.get({"parentfield": self.item_table_field}):
|
||||
_del(f, doc)
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ class TransactionController(DocListController):
|
||||
|
||||
"plc_exchange_rate": "plc_conversion_rate",
|
||||
"tax_calculation": "other_charges_calculation",
|
||||
"cost_center": "cost_center_other_charges",
|
||||
})
|
||||
else:
|
||||
self._fmap = webnotes.DictObj({
|
||||
@@ -113,5 +114,10 @@ class TransactionController(DocListController):
|
||||
|
||||
"valuation_tax_amount": "item_tax_amount"
|
||||
})
|
||||
|
||||
if self.doc.doctype == "Purchase Invoice":
|
||||
self._fmap.update({
|
||||
"rate": "rate"
|
||||
})
|
||||
|
||||
return self._fmap or webnotes.DictObj()
|
||||
Reference in New Issue
Block a user