refactor(UAE VAT 201): break functions

This commit is contained in:
Mohammad Hasnain 2020-10-29 09:52:17 +05:30
parent bf261a6c39
commit eb3084b072
2 changed files with 34 additions and 17 deletions

View File

@ -113,6 +113,7 @@ def standard_rated_expenses_emiratewise(data, filters):
"amount": frappe.format(amount, 'Currency'),
"vat_amount": frappe.format(vat, 'Currency'),
}
amounts_by_emirate = append_emiratewise_expenses(data, emirates, amounts_by_emirate)
for d, emirate in enumerate(emirates, 97):
if emirate in amounts_by_emirate:
@ -125,6 +126,18 @@ def standard_rated_expenses_emiratewise(data, filters):
frappe.format(0, 'Currency'), frappe.format(0, 'Currency'))
return emirates, amounts_by_emirate
def append_emiratewise_expenses(data, emirates, amounts_by_emirate):
"""Append emiratewise standard rated expenses and vat."""
for d, emirate in enumerate(emirates, 97):
if emirate in amounts_by_emirate:
amounts_by_emirate[emirate]["no"] = _('1{0}').format(chr(d))
amounts_by_emirate[emirate]["legend"] = _('Standard rated supplies in {0}').format(emirate)
data.append(amounts_by_emirate[emirate])
else:
append_data(data, _('1{0}').format(chr(d)),
_('Standard rated supplies in {0}').format(emirate),
frappe.format(0, 'Currency'), frappe.format(0, 'Currency'))
return amounts_by_emirate
def append_vat_on_expenses(data, filters):
"""Appends Expenses and All Other Inputs."""

View File

@ -123,7 +123,10 @@ def make_regional_gl_entries(gl_entries, doc):
for tax in doc.get('taxes'):
if tax.category not in ("Total", "Valuation and Total"):
continue
gl_entries = make_gl_entry(tax, gl_entries, doc, tax_accounts)
return gl_entries
def make_gl_entry(tax, gl_entries, doc, tax_accounts):
dr_or_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
if flt(tax.base_tax_amount_after_discount_amount) and tax.account_head in tax_accounts:
account_currency = get_account_currency(tax.account_head)
@ -142,6 +145,7 @@ def make_regional_gl_entries(gl_entries, doc):
)
return gl_entries
def validate_returns(doc, method):
"""Standard Rated expenses should not be set when Reverse Charge Applicable is set."""
country = frappe.get_cached_value('Company', doc.company, 'country')