Merge branch 'master-l10n_ae' into 'master'

[IMP]: Code optimized and demo data error solved for UAE VAT

See merge request flectra-hq/flectra!156
This commit is contained in:
Parthiv Patel 2018-10-26 08:08:02 +00:00
commit 6c04736170
3 changed files with 15 additions and 19 deletions

View File

@ -1643,7 +1643,7 @@
<field name="tax_type">customs</field>
<field name="chart_template_id" ref="uae_chart_template_standard"/>
<field name="include_base_amount" eval="True"/>
<field name="sequence"/>0</record>
<field name="sequence">0</field>
</record>
<record id="sale_uae_vat_5" model="account.tax.template">

View File

@ -10,7 +10,8 @@ United Arab Emirates accounting chart and localization.
=======================================================
""",
'depends': ['l10n_ae', 'account_invoicing', 'sale_management', 'purchase'],
'depends': ['l10n_ae', 'account_invoicing',
'sale_management', 'purchase', 'base_vat'],
'data': [
'security/ir.model.access.csv',
'data/journal_data.xml',

View File

@ -36,19 +36,16 @@ class ReportVat201(models.AbstractModel):
def get_total_sale(self, data):
return self.get_invoice_data_for_local(data, VAT_SALE_TYPE)
def get_subtotal(self, line, tax_ids):
return line.price_subtotal if any(
[tax_id for tax_id in tax_ids
if tax_id.tax_type == 'vat' and tax_id.amount != 0.0]) else 0.0
def get_customs_amount(self, tax_ids):
def get_vat_amount(self, tax_ids):
account_tax_object = self.env['account.tax']
customs_amount = 0.0
vat_amount = 0.0
for tax_line_id in tax_ids:
tax_id = account_tax_object.search([
('name', '=', tax_line_id.name), ('tax_type', '=', 'customs')])
customs_amount += tax_line_id.amount_total if tax_id else 0.0
return customs_amount
('name', '=', tax_line_id.name), ('tax_type', '=', 'vat')])
if tax_id.tax_type != 'vat':
continue
vat_amount += tax_line_id.base
return vat_amount
def get_tax_amount(self, tax_ids):
return sum([tax_id.amount for tax_id in tax_ids
@ -70,10 +67,7 @@ class ReportVat201(models.AbstractModel):
self.set_zero_exempted_amount(
data_dict, invoice_id, line,
line.invoice_line_tax_ids))
check_line_vat_tax += \
self.get_subtotal(line, line.invoice_line_tax_ids)
check_line_vat_tax += \
self.get_customs_amount(invoice_id.tax_line_ids)
check_line_vat_tax += self.get_vat_amount(invoice_id.tax_line_ids)
if invoice_id.type == 'out_refund':
data_dict['adjustment'] += check_line_vat_tax
data_dict['return_tax_amount'] += tax_amount
@ -126,9 +120,10 @@ class ReportVat201(models.AbstractModel):
tax_line_ids = line.reverse_invoice_line_tax_ids
data_dict.update(self.set_zero_exempted_amount(
data_dict, invoice_id, line, tax_line_ids))
check_line_vat_tax += self.get_subtotal(line, tax_line_ids)
check_line_vat_tax += \
self.get_customs_amount(invoice_id.tax_line_ids)
tax_ids = invoice_id.tax_line_ids
if invoice_id.reverse_charge:
tax_ids = invoice_id.reverse_tax_line_ids
check_line_vat_tax += self.get_vat_amount(tax_ids)
if invoice_id.type == 'in_refund':
data_dict['adjustment'] += check_line_vat_tax
data_dict['return_tax_amount'] += tax_amount