From c136d86a7bfecca56567616c1e082fbc2f273f22 Mon Sep 17 00:00:00 2001 From: Riddhi Kansara Date: Tue, 1 May 2018 17:42:07 +0530 Subject: [PATCH] [FIX]singapore account tax group [FIX]modify test cases based on tax group [FIX]l10n_sg_gst report issue --- addons/l10n_sg/data/account_data.xml | 13 ++++- addons/l10n_sg/data/account_tax_data.xml | 14 ++--- addons/l10n_sg_gst/__manifest__.py | 1 - addons/l10n_sg_gst/models/__init__.py | 1 - addons/l10n_sg_gst/models/account_tax.py | 32 ------------ .../l10n_sg_gst/report/account_gst5_report.py | 11 ++-- .../report/account_gst_analysis_report.py | 51 ++++++++----------- .../l10n_sg_gst/report/report_paperformat.xml | 2 +- .../tests/test_gst_summary_report.py | 40 ++++++++------- addons/l10n_sg_gst/views/account_tax_view.xml | 15 ------ 10 files changed, 68 insertions(+), 112 deletions(-) delete mode 100644 addons/l10n_sg_gst/models/account_tax.py delete mode 100644 addons/l10n_sg_gst/views/account_tax_view.xml diff --git a/addons/l10n_sg/data/account_data.xml b/addons/l10n_sg/data/account_data.xml index b7f9af41..989f159d 100644 --- a/addons/l10n_sg/data/account_data.xml +++ b/addons/l10n_sg/data/account_data.xml @@ -4,10 +4,19 @@ - TAX 0% + Zeroed - TAX 7% + Standard Rates + + + Exempted + + + Out Of Scope + + + MES diff --git a/addons/l10n_sg/data/account_tax_data.xml b/addons/l10n_sg/data/account_tax_data.xml index 666ab3bc..19323fa9 100644 --- a/addons/l10n_sg/data/account_tax_data.xml +++ b/addons/l10n_sg/data/account_tax_data.xml @@ -205,7 +205,7 @@ - + @@ -233,7 +233,7 @@ - + @@ -247,7 +247,7 @@ - + @@ -361,7 +361,7 @@ purchase - + @@ -403,7 +403,7 @@ purchase - + @@ -417,7 +417,7 @@ purchase - + @@ -431,7 +431,7 @@ purchase - + diff --git a/addons/l10n_sg_gst/__manifest__.py b/addons/l10n_sg_gst/__manifest__.py index 8794662e..10ccb5c1 100644 --- a/addons/l10n_sg_gst/__manifest__.py +++ b/addons/l10n_sg_gst/__manifest__.py @@ -20,7 +20,6 @@ There are Different type of GST Reports available for Singapore Localization. 'depends': ['account_invoicing', 'l10n_sg'], 'data': [ 'views/res_company_view.xml', - 'views/account_tax_view.xml', 'report/report_paperformat.xml', 'wizard/gst5_select_period_view.xml', 'wizard/gst7_select_period_view.xml', diff --git a/addons/l10n_sg_gst/models/__init__.py b/addons/l10n_sg_gst/models/__init__.py index 33fc99c4..1abe09cc 100644 --- a/addons/l10n_sg_gst/models/__init__.py +++ b/addons/l10n_sg_gst/models/__init__.py @@ -1,5 +1,4 @@ # Part of Flectra. See LICENSE file for full copyright and licensing # details. -from . import account_tax from . import res_company diff --git a/addons/l10n_sg_gst/models/account_tax.py b/addons/l10n_sg_gst/models/account_tax.py deleted file mode 100644 index dd868bb1..00000000 --- a/addons/l10n_sg_gst/models/account_tax.py +++ /dev/null @@ -1,32 +0,0 @@ -# Part of Flectra. See LICENSE file for full copyright and licensing -# details. - -from flectra import models, fields, api - - -class AccountTax(models.Model): - _inherit = 'account.tax' - - tax_group = fields.Selection([('standard_rates', 'Standard Rates'), - ('zeroed', 'Zeroed'), - ('exempted', 'Exempted'), ('MES', 'MES'), - ('out_of_scope', 'Out Of Scope')], - string='Tax Group') - - -class AccountTaxTemplate(models.Model): - _inherit = 'account.tax.template' - - tax_group = fields.Selection([('standard_rates', 'Standard Rates'), - ('zeroed', 'Zeroed'), - ('exempted', 'Exempted'), ('MES', 'MES'), - ('out_of_scope', 'Out Of Scope')], - string='Tax Group') - - @api.multi - def _get_tax_vals(self, company, tax_template_to_tax): - res = super(AccountTaxTemplate, self)._get_tax_vals( - company, tax_template_to_tax) - if self.tax_group: - res.update({'tax_group': self.tax_group}) - return res diff --git a/addons/l10n_sg_gst/report/account_gst5_report.py b/addons/l10n_sg_gst/report/account_gst5_report.py index e6498ce8..cd2cfefb 100644 --- a/addons/l10n_sg_gst/report/account_gst5_report.py +++ b/addons/l10n_sg_gst/report/account_gst5_report.py @@ -59,24 +59,25 @@ class AccountGst5Report(models.AbstractModel): final_purchase_domain = [('type_tax_use', '=', 'purchase')] gst_taxes_results = self._cr.fetchall() if tax_group == 'MES': - final_domain = final_purchase_domain + [('tax_group', '=', 'MES')] + final_domain = final_purchase_domain + [('tax_group_id', '=', self.env.ref("l10n_sg.tax_group_mes").name)] elif tax_group == 'purchase': - final_domain = final_purchase_domain + [('tax_group', '!=', 'MES')] + final_domain = final_purchase_domain + [('tax_group_id', '!=', self.env.ref("l10n_sg.tax_group_mes").name)] elif tax_group == 'purchase-tax': flag = 1 final_domain = final_purchase_domain if tax_group == 'standard_rates': - final_domain = final_sale_domain + [('tax_group', '=', 'standard_rates')] + final_domain = final_sale_domain + [('tax_group_id', '=', self.env.ref("l10n_sg.tax_group_7").name)] elif tax_group == 'zeroed': - final_domain = final_sale_domain + [('tax_group', '=', 'zeroed')] + final_domain = final_sale_domain + [('tax_group_id', '=', self.env.ref("l10n_sg.tax_group_0").name)] elif tax_group == 'exempted': - final_domain = final_sale_domain + [('tax_group', '=', 'exempted')] + final_domain = final_sale_domain + [('tax_group_id', '=', self.env.ref("l10n_sg.tax_group_exempted").name)] elif tax_group == 'sales-tax': flag = 1 final_domain = final_sale_domain elif tax_group == 'sales': final_domain = final_sale_domain tax_ids = self.env['account.tax'].search(final_domain) + print("tax_ids......",tax_ids) if flag: for i in range(len(taxes_result)): diff --git a/addons/l10n_sg_gst/report/account_gst_analysis_report.py b/addons/l10n_sg_gst/report/account_gst_analysis_report.py index 2692b07b..ce827edc 100644 --- a/addons/l10n_sg_gst/report/account_gst_analysis_report.py +++ b/addons/l10n_sg_gst/report/account_gst_analysis_report.py @@ -12,26 +12,18 @@ from flectra.addons.l10n_sg_gst.report.account_gst5_report import taxes_query, \ class AccountGstAnalysisView(models.AbstractModel): _name = 'report.l10n_sg_gst.account_gst_analysis_view' - def compute_group_total(self, tax_browse, gst_taxes_result, group_name): + def compute_total(self, tax_browse, taxes_result, group_name): amount = 0.00 - for i in range(len(gst_taxes_result)): - if tax_browse.id == gst_taxes_result[i][0]: - if tax_browse.tax_group in group_name: - amount += gst_taxes_result[i][1] + for i in range(len(taxes_result)): + if tax_browse.id == taxes_result[i][0] and tax_browse.tax_group_id in group_name: + amount += taxes_result[i][1] return abs(amount) or 0.00 - def compute_gst_total(self, tax_browse, texes_result, group_name): - tax_amount = 0.00 - for i in range(len(texes_result)): - if tax_browse.id == texes_result[i][0]: - if tax_browse.tax_group in group_name: - tax_amount += texes_result[i][1] - return abs(tax_amount) or 0.00 - def get_common_data(self, tax_ids, data): result = [] gst_perc = standard_total = zeroed_total = exempted_total = mes_total \ = out_scope_total = gross_amount_total = gst_amount_total = 0.0 + group_name = tax_ids.mapped('tax_group_id') for tax_browse in tax_ids: date_start = data['form']['date_from'] date_stop = data['form']['date_to'] @@ -50,30 +42,27 @@ class AccountGstAnalysisView(models.AbstractModel): else: gst_perc = tax_browse.amount - standard = self.compute_group_total(tax_browse, - gst_taxes_result, ['standard_rates']) + standard = self.compute_total(tax_browse, + gst_taxes_result, [self.env.ref("l10n_sg.tax_group_7")]) standard_total += standard - zeroed = self.compute_group_total(tax_browse, - gst_taxes_result, ['zeroed']) + zeroed = self.compute_total(tax_browse, + gst_taxes_result, [self.env.ref("l10n_sg.tax_group_0")]) zeroed_total += zeroed - exempted = self.compute_group_total(tax_browse, - gst_taxes_result, ['exempted']) + exempted = self.compute_total(tax_browse, + gst_taxes_result, [self.env.ref("l10n_sg.tax_group_exempted")]) exempted_total += exempted - mes = self.compute_group_total(tax_browse, - gst_taxes_result, ['MES']) + mes = self.compute_total(tax_browse, + gst_taxes_result, [self.env.ref("l10n_sg.tax_group_mes")]) mes_total += mes - out_scope = self.compute_group_total(tax_browse, - gst_taxes_result, ['out_of_scope']) + out_scope = self.compute_total(tax_browse, + gst_taxes_result, [self.env.ref("l10n_sg.tax_group_oos")]) out_scope_total += out_scope - gross_amount = self.compute_group_total(tax_browse, - gst_taxes_result, - ['standard_rates', 'zeroed', 'exempted', 'MES', - 'out_of_scope']) + + gross_amount = self.compute_total(tax_browse, + gst_taxes_result, group_name) gross_amount_total += gross_amount - gst_amount = self.compute_gst_total(tax_browse, - texes_result, - ['standard_rates', 'zeroed', 'exempted', 'MES', - 'out_of_scope']) + gst_amount = self.compute_total(tax_browse, + texes_result, group_name) gst_amount_total += gst_amount result.append({ 'tax_name': tax_browse.name, diff --git a/addons/l10n_sg_gst/report/report_paperformat.xml b/addons/l10n_sg_gst/report/report_paperformat.xml index 22979c6e..e3a74631 100644 --- a/addons/l10n_sg_gst/report/report_paperformat.xml +++ b/addons/l10n_sg_gst/report/report_paperformat.xml @@ -29,7 +29,7 @@ 7 7 - 35 + 40 90 diff --git a/addons/l10n_sg_gst/tests/test_gst_summary_report.py b/addons/l10n_sg_gst/tests/test_gst_summary_report.py index aac317b9..0ebe54f7 100644 --- a/addons/l10n_sg_gst/tests/test_gst_summary_report.py +++ b/addons/l10n_sg_gst/tests/test_gst_summary_report.py @@ -24,6 +24,12 @@ class TestGstF5(TransactionCase): self.product7 = self.env.ref('product.product_product_8') self.product8 = self.env.ref('product.product_product_9') self.product9 = self.env.ref('product.product_product_10') + self.standard_rates = self.env.ref('l10n_sg.tax_group_7').id + self.zeroed = self.env.ref('l10n_sg.tax_group_0').id + self.mes = self.env.ref('l10n_sg.tax_group_mes').id + self.oos = self.env.ref('l10n_sg.tax_group_oos').id + self.exempted = self.env.ref('l10n_sg.tax_group_exempted').id + self.gst_customer_id_1 = self.res_partner_model.create(dict( name="Cyril", @@ -38,71 +44,71 @@ class TestGstF5(TransactionCase): self.sale_tax_id_1 = self.account_tax.search( [('name', '=', 'Sales Tax 7% SR')]) - self.sale_tax_id_1.write({'tax_group': 'standard_rates'}) + self.sale_tax_id_1.write({'tax_group_id': self.standard_rates}) self.sale_tax_id_2 = self.account_tax.search( [('name', '=', 'Sales Tax 0% ZR')]) - self.sale_tax_id_2.write({'tax_group': 'zeroed'}) + self.sale_tax_id_2.write({'tax_group_id': self.zeroed}) self.sale_tax_id_3 = self.account_tax.search( [('name', '=', 'Sales Tax 0% OS')]) - self.sale_tax_id_3.write({'tax_group': 'out_of_scope'}) + self.sale_tax_id_3.write({'tax_group_id': self.oos}) self.sale_tax_id_4 = self.account_tax.search( [('name', '=', 'Sales Tax 0% ESN33')]) - self.sale_tax_id_4.write({'tax_group': 'exempted'}) + self.sale_tax_id_4.write({'tax_group_id': self.exempted}) self.sale_tax_id_5 = self.account_tax.search( [('name', '=', 'Sales Tax 7% DS')]) - self.sale_tax_id_5.write({'tax_group': 'standard_rates'}) + self.sale_tax_id_5.write({'tax_group_id': self.standard_rates}) self.sale_tax_id_6 = self.account_tax.search( [('name', '=', 'Sales Tax 0% ES33')]) - self.sale_tax_id_6.write({'tax_group': 'exempted'}) + self.sale_tax_id_6.write({'tax_group_id': self.exempted}) self.purchase_tax_id_1 = self.account_tax.search( [('name', '=', 'Purchase Tax 7% TX-N33')]) - self.purchase_tax_id_1.write({'tax_group': 'standard_rates'}) + self.purchase_tax_id_1.write({'tax_group_id': self.standard_rates}) self.purchase_tax_id_2 = self.account_tax.search( [('name', '=', 'Purchase Tax 7% BL')]) - self.purchase_tax_id_2.write({'tax_group': 'standard_rates'}) + self.purchase_tax_id_2.write({'tax_group_id': self.standard_rates}) self.purchase_tax_id_3 = self.account_tax.search( [('name', '=', 'Purchase Tax 7% IM')]) - self.purchase_tax_id_3.write({'tax_group': 'standard_rates'}) + self.purchase_tax_id_3.write({'tax_group_id': self.standard_rates}) self.purchase_tax_id_4 = self.account_tax.search( [('name', '=', 'Purchase Tax 7% TX-RE')]) - self.purchase_tax_id_4.write({'tax_group': 'standard_rates'}) + self.purchase_tax_id_4.write({'tax_group_id': self.standard_rates}) self.purchase_tax_id_5 = self.account_tax.search( [('name', '=', 'Purchase Tax 0% ME')]) - self.purchase_tax_id_5.write({'tax_group': 'standard_rates'}) + self.purchase_tax_id_5.write({'tax_group_id': self.standard_rates}) self.purchase_tax_id_6 = self.account_tax.search( [('name', '=', 'Purchase Tax 0% NR')]) - self.purchase_tax_id_6.write({'tax_group': 'standard_rates'}) + self.purchase_tax_id_6.write({'tax_group_id': self.standard_rates}) self.purchase_tax_id_7 = self.account_tax.search( [('name', '=', 'Purchase Tax 0% ZP')]) - self.purchase_tax_id_7.write({'tax_group': 'standard_rates'}) + self.purchase_tax_id_7.write({'tax_group_id': self.standard_rates}) self.purchase_tax_id_8 = self.account_tax.search( [('name', '=', 'Purchase Tax 0% OP')]) - self.purchase_tax_id_8.write({'tax_group': 'out_of_scope'}) + self.purchase_tax_id_8.write({'tax_group_id': self.standard_rates}) self.purchase_tax_id_9 = self.account_tax.search( [('name', '=', 'Purchase Tax 0% EP')]) - self.purchase_tax_id_9.write({'tax_group': 'exempted'}) + self.purchase_tax_id_9.write({'tax_group_id': self.exempted}) self.purchase_tax_id_10 = self.account_tax.search( [('name', '=', 'Purchase Tax MES')]) - self.purchase_tax_id_10.write({'tax_group': 'MES'}) + self.purchase_tax_id_10.write({'tax_group_id': self.mes}) self.purchase_tax_id_11 = self.account_tax.search( [('name', '=', 'Purchase Tax 7% TX7')]) - self.purchase_tax_id_11.write({'tax_group': 'standard_rates'}) + self.purchase_tax_id_11.write({'tax_group_id': self.standard_rates}) def test_create_customer_invoice(self): customer_invoice = self.account_invoice_model.create( diff --git a/addons/l10n_sg_gst/views/account_tax_view.xml b/addons/l10n_sg_gst/views/account_tax_view.xml deleted file mode 100644 index 41c0ea08..00000000 --- a/addons/l10n_sg_gst/views/account_tax_view.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - account.tax.inherit.form - account.tax - - - - - - - - -