Merge branch 'master-report-gst-riddhi' into 'master'
[FIX]singapore account tax group See merge request flectra-hq/flectra!54
This commit is contained in:
commit
d80ac40ac6
@ -4,10 +4,19 @@
|
||||
|
||||
<!-- Account Tax Group -->
|
||||
<record id="tax_group_0" model="account.tax.group">
|
||||
<field name="name">TAX 0%</field>
|
||||
<field name="name">Zeroed</field>
|
||||
</record>
|
||||
<record id="tax_group_7" model="account.tax.group">
|
||||
<field name="name">TAX 7%</field>
|
||||
<field name="name">Standard Rates</field>
|
||||
</record>
|
||||
<record id="tax_group_exempted" model="account.tax.group">
|
||||
<field name="name">Exempted</field>
|
||||
</record>
|
||||
<record id="tax_group_oos" model="account.tax.group">
|
||||
<field name="name">Out Of Scope</field>
|
||||
</record>
|
||||
<record id="tax_group_mes" model="account.tax.group">
|
||||
<field name="name">MES</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
@ -205,7 +205,7 @@
|
||||
<field name="refund_account_id" ref="account_account_791"/>
|
||||
<field name="chart_template_id" ref="sg_chart_template"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('tag_sg_23'),ref('tag_sg_32')])]"/>
|
||||
<field name="tax_group_id" ref="tax_group_0"/>
|
||||
<field name="tax_group_id" ref="tax_group_exempted"/>
|
||||
</record>
|
||||
|
||||
<record id="sg_sale_tax_ds_7" model="account.tax.template">
|
||||
@ -233,7 +233,7 @@
|
||||
<field name="refund_account_id" ref="account_account_793"/>
|
||||
<field name="chart_template_id" ref="sg_chart_template"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('tag_sg_24'),ref('tag_sg_33')])]"/>
|
||||
<field name="tax_group_id" ref="tax_group_0"/>
|
||||
<field name="tax_group_id" ref="tax_group_exempted"/>
|
||||
</record>
|
||||
|
||||
<record id="sg_sale_tax_os_0" model="account.tax.template">
|
||||
@ -247,7 +247,7 @@
|
||||
<field name="refund_account_id" ref="account_account_794"/>
|
||||
<field name="chart_template_id" ref="sg_chart_template"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('tag_sg_20'),ref('tag_sg_47')])]"/>
|
||||
<field name="tax_group_id" ref="tax_group_0"/>
|
||||
<field name="tax_group_id" ref="tax_group_oos"/>
|
||||
</record>
|
||||
|
||||
<record id="sg_sale_tax_zr_0" model="account.tax.template">
|
||||
@ -361,7 +361,7 @@
|
||||
<field name="type_tax_use">purchase</field>
|
||||
<field name="chart_template_id" ref="sg_chart_template"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('tag_sg_14'),ref('tag_sg_41')])]"/>
|
||||
<field name="tax_group_id" ref="tax_group_0"/>
|
||||
<field name="tax_group_id" ref="tax_group_mes"/>
|
||||
</record>
|
||||
|
||||
<record id="sg_purchase_tax_nr_0" model="account.tax.template">
|
||||
@ -403,7 +403,7 @@
|
||||
<field name="type_tax_use">purchase</field>
|
||||
<field name="chart_template_id" ref="sg_chart_template"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('tag_sg_19'),ref('tag_sg_46')])]"/>
|
||||
<field name="tax_group_id" ref="tax_group_0"/>
|
||||
<field name="tax_group_id" ref="tax_group_oos"/>
|
||||
</record>
|
||||
|
||||
<record id="sg_purchase_tax_ep_0" model="account.tax.template">
|
||||
@ -417,7 +417,7 @@
|
||||
<field name="type_tax_use">purchase</field>
|
||||
<field name="chart_template_id" ref="sg_chart_template"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('tag_sg_22'),ref('tag_sg_45')])]"/>
|
||||
<field name="tax_group_id" ref="tax_group_0"/>
|
||||
<field name="tax_group_id" ref="tax_group_exempted"/>
|
||||
</record>
|
||||
|
||||
<record id="sg_purchase_tax_mes_0" model="account.tax.template">
|
||||
@ -431,7 +431,7 @@
|
||||
<field name="type_tax_use">purchase</field>
|
||||
<field name="chart_template_id" ref="sg_chart_template"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('tag_sg_17'),ref('tag_sg_44')])]"/>
|
||||
<field name="tax_group_id" ref="tax_group_0"/>
|
||||
<field name="tax_group_id" ref="tax_group_mes"/>
|
||||
</record>
|
||||
|
||||
<record id="sg_purchase_tax_tx7_7" model="account.tax.template">
|
||||
|
@ -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',
|
||||
|
@ -1,5 +1,4 @@
|
||||
# Part of Flectra. See LICENSE file for full copyright and licensing
|
||||
# details.
|
||||
|
||||
from . import account_tax
|
||||
from . import res_company
|
||||
|
@ -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
|
@ -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)):
|
||||
|
@ -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,
|
||||
|
@ -29,7 +29,7 @@
|
||||
<field name="margin_left">7</field>
|
||||
<field name="margin_right">7</field>
|
||||
<field name="header_line" eval="False"/>
|
||||
<field name="header_spacing">35</field>
|
||||
<field name="header_spacing">40</field>
|
||||
<field name="dpi">90</field>
|
||||
</record>
|
||||
|
||||
|
@ -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(
|
||||
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flectra>
|
||||
<!-- Added new field Tax-Group -->
|
||||
<record id="view_account_tax_form_inherit" model="ir.ui.view">
|
||||
<field name="name">account.tax.inherit.form</field>
|
||||
<field name="model">account.tax</field>
|
||||
<field name="inherit_id" ref="account.view_tax_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="amount_type" position="before">
|
||||
<field name="tax_group"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</flectra>
|
Loading…
Reference in New Issue
Block a user