[IMP]: Code optimized and demo data error solved

This commit is contained in:
Haresh Chavda 2018-10-26 12:49:53 +05:30
parent 920da5880e
commit 3eb97d72a9
3 changed files with 15 additions and 19 deletions

View File

@ -1643,7 +1643,7 @@
<field name="tax_type">customs</field> <field name="tax_type">customs</field>
<field name="chart_template_id" ref="uae_chart_template_standard"/> <field name="chart_template_id" ref="uae_chart_template_standard"/>
<field name="include_base_amount" eval="True"/> <field name="include_base_amount" eval="True"/>
<field name="sequence"/>0</record> <field name="sequence">0</field>
</record> </record>
<record id="sale_uae_vat_5" model="account.tax.template"> <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': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'data/journal_data.xml', 'data/journal_data.xml',

View File

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