[FIX] l10n_in: fix gst payment report calculations and demo data

closes odoo/odoo#35067

Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
Jigar Vaghela
2019-07-22 12:00:38 +00:00
parent fce64e7d94
commit b1150c696c
5 changed files with 126 additions and 53 deletions
+83 -9
View File
@@ -9,21 +9,39 @@
<field name="invoice_user_id" ref="base.user_demo"/>
<field name="invoice_payment_term_id" ref="account.account_payment_term"/>
<field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/>
<field name="invoice_line_ids" eval="[
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.product_product_8'),
'quantity': 2,
'price_unit': 40000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 28),
('tax_group_id', '=', ref('l10n_in.gst_group'))], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_9'),
'quantity': 3,
'price_unit': 400.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', ref('l10n_in.gst_group'))], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_10'),
'quantity': 4,
'price_unit': 300.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
'|',
'&amp;',
('amount', '=', 18),
('tax_group_id', '=', ref('l10n_in.gst_group')),
'&amp;',
('tax_group_id', '=', ref('l10n_in.cess_group')),
('children_tax_ids.amount','=', 5)
], limit=2).ids)]
}),
]"/>
</record>
@@ -35,42 +53,62 @@
<field name="invoice_user_id" ref="base.user_demo"/>
<field name="invoice_payment_term_id" ref="account.account_payment_term"/>
<field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/>
<field name="invoice_line_ids" eval="[
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.product_product_16'),
'quantity': 1,
'price_unit': 1500.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', obj().env.ref('l10n_in.gst_group').id)], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_20'),
'quantity': 1,
'price_unit': 2300.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', obj().env.ref('l10n_in.gst_group').id)], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_22'),
'quantity': 1,
'price_unit': 2600.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 5),
('tax_group_id', '=', obj().env.ref('l10n_in.gst_group').id)], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_24'),
'quantity': 2,
'price_unit': 1655.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 5),
('tax_group_id', '=', obj().env.ref('l10n_in.gst_group').id)], limit=1).ids)]
}),
]"/>
</record>
<!-- Demo of B2CL (business to consumer small) Taxable supplies made to other unregistered Person and below INR 2.5 lakhs invoice value.-->
<!-- Demo of B2CL (business to consumer - Large) Taxable supplies made to other unregistered Person and invoice value is more than INR 2.5 lakhs.-->
<record id="demo_invoice_b2cl" model="account.move">
<field name="type">out_invoice</field>
<field name="partner_id" ref="l10n_in.res_partner_unregistered_customer_out_state"/>
<field name="invoice_user_id" ref="base.user_demo"/>
<field name="invoice_payment_term_id" ref="account.account_payment_term"/>
<field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/>
<field name="invoice_line_ids" eval="[
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.consu_delivery_01'),
'quantity': 3,
'price_unit': 90000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', obj().env.ref('l10n_in.igst_group').id)], limit=1).ids)]
}),
]"/>
</record>
@@ -92,11 +130,15 @@
<field name="l10n_in_shipping_bill_number">999704</field>
<field name="l10n_in_shipping_bill_date" eval="time.strftime('%Y-%m')+'-02'"/>
<field name="l10n_in_shipping_port_code_id" ref="l10n_in.port_code_inixy1"/>
<field name="invoice_line_ids" eval="[
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.product_product_4'),
'quantity': 30,
'price_unit': 8000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', obj().env.ref('l10n_in.igst_group').id)], limit=1).ids)]
}),
]"/>
</record>
@@ -108,16 +150,22 @@
<field name="invoice_user_id" ref="base.user_demo"/>
<field name="invoice_payment_term_id" ref="account.account_payment_term"/>
<field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/>
<field name="invoice_line_ids" eval="[
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.product_product_1'),
'quantity': 2,
'price_unit': 25000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('tax_group_id', '=', obj().env.ref('l10n_in.exempt_group').id)], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_5'),
'quantity': 1,
'price_unit': 400.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('tax_group_id', '=', obj().env.ref('l10n_in.nil_rated_group').id)], limit=1).ids)]
}),
]"/>
</record>
@@ -131,21 +179,39 @@
<field name="invoice_payment_term_id" ref="account.account_payment_term"/>
<field name="invoice_date" eval="time.strftime('%Y-%m')+'-02'"/>
<field name="reversed_entry_id" ref="l10n_in.demo_invoice_b2b"/>
<field name="invoice_line_ids" eval="[
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.product_product_8'),
'quantity': 2,
'price_unit': 40000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 28),
('tax_group_id', '=', obj().env.ref('l10n_in.gst_group').id)], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_9'),
'quantity': 3,
'price_unit': 400.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', obj().env.ref('l10n_in.gst_group').id)], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_10'),
'quantity': 3,
'price_unit': 400.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
'|',
'&amp;',
('amount', '=', 18),
('tax_group_id', '=', ref('l10n_in.gst_group')),
'&amp;',
('tax_group_id', '=', ref('l10n_in.cess_group')),
('children_tax_ids.amount','=', 5)
], limit=2).ids)]
}),
]"/>
</record>
@@ -158,11 +224,15 @@
<field name="invoice_payment_term_id" ref="account.account_payment_term"/>
<field name="invoice_date" eval="time.strftime('%Y-%m')+'-02'"/>
<field name="reversed_entry_id" ref="l10n_in.demo_invoice_b2cl"/>
<field name="invoice_line_ids" eval="[
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.consu_delivery_01'),
'quantity': 3,
'price_unit': 90000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', obj().env.ref('l10n_in.gst_group').id)], limit=1).ids)]
}),
]"/>
</record>
@@ -175,11 +245,15 @@
<field name="invoice_user_id" ref="base.user_demo"/>
<field name="invoice_payment_term_id" ref="account.account_payment_term"/>
<field name="invoice_date" eval="(datetime.now() + relativedelta(months=1)).strftime('%Y-%m-01')"/>
<field name="invoice_line_ids" eval="[
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.consu_delivery_01'),
'quantity': 3,
'price_unit': 2000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', obj().env.ref('l10n_in.gst_group').id)], limit=1).ids)]
}),
]"/>
</record>
+38 -38
View File
@@ -11,7 +11,6 @@ class L10nInAccountInvoiceReport(models.Model):
_order = 'date desc'
account_move_id = fields.Many2one('account.move', string="Account Move")
invoice_id = fields.Many2one('account.move', string="Invoice")
company_id = fields.Many2one('res.company', string="Company")
date = fields.Date(string="Accounting Date")
name = fields.Char(string="Invoice Number")
@@ -36,12 +35,14 @@ class L10nInAccountInvoiceReport(models.Model):
shipping_bill_date = fields.Date(string="Shipping Bill Date")
shipping_port_code_id = fields.Many2one('l10n_in.port.code', string='Shipping port code')
ecommerce_partner_id = fields.Many2one('res.partner', string="E-commerce")
invoice_type = fields.Selection([
move_type = fields.Selection(selection=[
('entry', 'Journal Entry'),
('out_invoice', 'Customer Invoice'),
('in_invoice', 'Vendor Bill'),
('out_refund', 'Customer Credit Note'),
('in_invoice', 'Vendor Bill'),
('in_refund', 'Vendor Credit Note'),
])
('out_receipt', 'Sales Receipt'),
('in_receipt', 'Purchase Receipt')])
partner_vat = fields.Char(string="Customer GSTIN")
ecommerce_vat = fields.Char(string="E-commerce GSTIN")
tax_rate = fields.Float(string="Rate")
@@ -77,7 +78,7 @@ class L10nInAccountInvoiceReport(models.Model):
sub.total,
sub.journal_id,
sub.company_id,
sub.invoice_type,
sub.move_type,
sub.reversed_entry_id,
sub.partner_vat,
sub.ecommerce_vat,
@@ -117,16 +118,16 @@ class L10nInAccountInvoiceReport(models.Model):
am.name,
am.state,
am.date,
ai.l10n_in_export_type AS l10n_in_export_type,
ai.l10n_in_reseller_partner_id AS ecommerce_partner_id,
ai.l10n_in_shipping_bill_number AS shipping_bill_number,
ai.l10n_in_shipping_bill_date AS shipping_bill_date,
ai.l10n_in_shipping_port_code_id AS shipping_port_code_id,
am.l10n_in_export_type AS l10n_in_export_type,
am.l10n_in_reseller_partner_id AS ecommerce_partner_id,
am.l10n_in_shipping_bill_number AS shipping_bill_number,
am.l10n_in_shipping_bill_date AS shipping_bill_date,
am.l10n_in_shipping_port_code_id AS shipping_port_code_id,
am.amount_total AS total,
am.journal_id,
aj.company_id,
ai.type AS invoice_type,
ai.reversed_entry_id AS reversed_entry_id,
am.type AS move_type,
am.reversed_entry_id AS reversed_entry_id,
p.vat AS partner_vat,
CASE WHEN rp.vat IS NULL THEN '' ELSE rp.vat END AS ecommerce_vat,
(CASE WHEN at.l10n_in_reverse_charge = True
@@ -139,20 +140,20 @@ class L10nInAccountInvoiceReport(models.Model):
THEN concat(cps.l10n_in_tin,'-',cps.name)
ELSE ''
END) AS place_of_supply,
(CASE WHEN ai.type in ('out_refund', 'in_refund') and refund_ai.date <= to_date('2017-07-01', 'YYYY-MM-DD')
(CASE WHEN am.type in ('out_refund', 'in_refund') and refund_am.date <= to_date('2017-07-01', 'YYYY-MM-DD')
THEN 'Y'
ELSE 'N'
END) as is_pre_gst,
(CASE WHEN ai.l10n_in_reseller_partner_id IS NOT NULL
(CASE WHEN am.l10n_in_reseller_partner_id IS NOT NULL
THEN 'Y'
ELSE 'N'
END) as is_ecommerce,
(CASE WHEN ai.l10n_in_reseller_partner_id IS NOT NULL
(CASE WHEN am.l10n_in_reseller_partner_id IS NOT NULL
THEN 'Y'
ELSE 'N'
END) as b2cl_is_ecommerce,
(CASE WHEN ai.l10n_in_reseller_partner_id IS NOT NULL
(CASE WHEN am.l10n_in_reseller_partner_id IS NOT NULL
THEN 'E'
ELSE 'OE'
END) as b2cs_is_ecommerce,
@@ -161,34 +162,34 @@ class L10nInAccountInvoiceReport(models.Model):
WHEN ps.id != cp.state_id and p.id IS NOT NULL
THEN 'Inter State'
END) AS supply_type,
(CASE WHEN ai.l10n_in_export_type in ('deemed', 'export_with_igst', 'sez_with_igst')
(CASE WHEN am.l10n_in_export_type in ('deemed', 'export_with_igst', 'sez_with_igst')
THEN 'EXPWP'
WHEN ai.l10n_in_export_type in ('sale_from_bonded_wh', 'sez_without_igst')
WHEN am.l10n_in_export_type in ('sale_from_bonded_wh', 'sez_without_igst')
THEN 'EXPWOP'
ELSE ''
END) AS export_type,
(CASE WHEN refund_ai.l10n_in_export_type in ('deemed', 'export_with_igst', 'sez_with_igst')
(CASE WHEN refund_am.l10n_in_export_type in ('deemed', 'export_with_igst', 'sez_with_igst')
THEN 'EXPWP'
WHEN refund_ai.l10n_in_export_type in ('sale_from_bonded_wh', 'sez_without_igst')
WHEN refund_am.l10n_in_export_type in ('sale_from_bonded_wh', 'sez_without_igst')
THEN 'EXPWOP'
ELSE 'B2CL'
END) AS refund_export_type,
(CASE WHEN ai.l10n_in_export_type = 'regular'
(CASE WHEN am.l10n_in_export_type = 'regular'
THEN 'Regular'
WHEN ai.l10n_in_export_type = 'deemed'
WHEN am.l10n_in_export_type = 'deemed'
THEN 'Deemed'
WHEN ai.l10n_in_export_type = 'sale_from_bonded_wh'
WHEN am.l10n_in_export_type = 'sale_from_bonded_wh'
THEN 'Sale from Bonded WH'
WHEN ai.l10n_in_export_type = 'export_with_igst'
WHEN am.l10n_in_export_type = 'export_with_igst'
THEN 'Export with IGST'
WHEN ai.l10n_in_export_type = 'sez_with_igst'
WHEN am.l10n_in_export_type = 'sez_with_igst'
THEN 'SEZ with IGST payment'
WHEN ai.l10n_in_export_type = 'sez_without_igst'
WHEN am.l10n_in_export_type = 'sez_without_igst'
THEN 'SEZ without IGST payment'
END) AS b2b_type,
(CASE WHEN ai.type = 'out_refund'
(CASE WHEN am.type = 'out_refund'
THEN 'C'
WHEN ai.type = 'in_refund'
WHEN am.type = 'in_refund'
THEN 'D'
ELSE ''
END) as refund_invoice_type,
@@ -196,12 +197,12 @@ class L10nInAccountInvoiceReport(models.Model):
THEN TO_CHAR(am.date, 'DD-MON-YYYY')
ELSE ''
END) as gst_format_date,
(CASE WHEN refund_ai.date IS NOT NULL
THEN TO_CHAR(refund_ai.date, 'DD-MON-YYYY')
(CASE WHEN refund_am.date IS NOT NULL
THEN TO_CHAR(refund_am.date, 'DD-MON-YYYY')
ELSE ''
END) as gst_format_refund_date,
(CASE WHEN ai.l10n_in_shipping_bill_date IS NOT NULL
THEN TO_CHAR(ai.l10n_in_shipping_bill_date, 'DD-MON-YYYY')
(CASE WHEN am.l10n_in_shipping_bill_date IS NOT NULL
THEN TO_CHAR(am.l10n_in_shipping_bill_date, 'DD-MON-YYYY')
ELSE ''
END) as gst_format_shipping_bill_date,
CASE WHEN tag_rep_ln.account_tax_report_line_id IN
@@ -231,7 +232,7 @@ class L10nInAccountInvoiceReport(models.Model):
THEN NULL
ELSE (CASE WHEN aml.tax_base_amount <> 0 THEN aml.tax_base_amount ELSE NULL END)
END AS price_total,
(CASE WHEN aj.type = 'sale' AND (ai.type IS NULL OR ai.type != 'out_refund') THEN -1 ELSE 1 END) AS amount_sign,
(CASE WHEN aj.type = 'sale' AND (am.type IS NULL OR am.type != 'out_refund') THEN -1 ELSE 1 END) AS amount_sign,
at.id AS tax_id,
at.amount AS tax_rate
"""
@@ -249,11 +250,10 @@ class L10nInAccountInvoiceReport(models.Model):
JOIN account_tax_report_line_tags_rel tag_rep_ln ON aat.id = tag_rep_ln.account_account_tag_id
LEFT JOIN res_partner cp ON cp.id = c.partner_id
LEFT JOIN res_country_state cps ON cps.id = cp.state_id
LEFT JOIN account_move ai ON ai.id = aml.move_id
LEFT JOIN account_move refund_ai ON refund_ai.id = ai.reversed_entry_id
LEFT JOIN account_move refund_am ON refund_am.id = am.reversed_entry_id
LEFT JOIN res_partner p ON p.id = aml.partner_id
LEFT JOIN res_country_state ps ON ps.id = p.state_id
LEFT JOIN res_partner rp ON rp.id = ai.l10n_in_reseller_partner_id
LEFT JOIN res_partner rp ON rp.id = am.l10n_in_reseller_partner_id
"""
return from_str
@@ -279,7 +279,7 @@ class L10nInAccountInvoiceReport(models.Model):
sub.total,
sub.journal_id,
sub.company_id,
sub.invoice_type,
sub.move_type,
sub.reversed_entry_id,
sub.partner_vat,
sub.ecommerce_vat,
@@ -310,4 +310,4 @@ class L10nInAccountInvoiceReport(models.Model):
FROM (
%s %s %s
) AS sub %s)""" % (self._table, self._select(), self._sub_select(),
self._from(), self._where(), self._group_by()))
self._from(), self._where(), self._group_by()))
@@ -31,7 +31,7 @@ class L10nInPaymentReport(models.AbstractModel):
def _compute_l10n_in_tax(self, taxes, price_unit, currency=None, quantity=1.0, product=None, partner=None):
"""common method to compute gst tax amount base on tax group"""
res = {'igst_amount': 0.0, 'sgst_amount': 0.0, 'cgst_amount': 0.0, 'cess_amount': 0.0}
AccountTag = self.env['account.account.tag']
AccountTaxRepartitionLine = self.env['account.tax.repartition.line']
tax_report_line_igst = self.env.ref('l10n_in.tax_report_line_igst', False)
tax_report_line_cgst = self.env.ref('l10n_in.tax_report_line_cgst', False)
tax_report_line_sgst = self.env.ref('l10n_in.tax_report_line_sgst', False)
@@ -39,7 +39,7 @@ class L10nInPaymentReport(models.AbstractModel):
filter_tax = taxes.filtered(lambda t: t.type_tax_use != 'none')
tax_compute = filter_tax.compute_all(price_unit, currency=currency, quantity=quantity, product=product, partner=partner)
for tax_data in tax_compute['taxes']:
tax_report_lines = AccountTag.browse(tax_data['tag_ids'][0][2]).mapped('tax_report_line_ids')
tax_report_lines = AccountTaxRepartitionLine.browse(tax_data['tax_repartition_line_id']).mapped('tag_ids.tax_report_line_ids')
if tax_report_line_sgst in tax_report_lines:
res['sgst_amount'] += tax_data['amount']
if tax_report_line_cgst in tax_report_lines:
+1 -1
View File
@@ -23,7 +23,7 @@ class L10nInExemptedReport(models.Model):
def _select(self):
select_str = """SELECT aml.id AS id,
aml.partner_id AS partner_id,
aml.date_maturity AS date,
am.date,
aml.balance * (CASE WHEN aj.type = 'sale' THEN -1 ELSE 1 END) AS price_total,
am.journal_id,
aj.company_id,
+2 -3
View File
@@ -36,7 +36,7 @@ class L10nInProductHsnReport(models.Model):
aml.partner_id AS partner_id,
aml.product_id,
aml.product_uom_id AS uom_id,
aml.date_maturity AS date,
am.date,
am.journal_id,
aj.company_id,
CASE WHEN pt.l10n_in_hsn_code IS NULL THEN '' ELSE pt.l10n_in_hsn_code END AS hsn_code,
@@ -93,8 +93,7 @@ class L10nInProductHsnReport(models.Model):
LEFT JOIN account_tax_report_line_tags_rel tag_rep_ln ON aat.id = tag_rep_ln.account_account_tag_id
LEFT JOIN account_move_line_account_tax_rel mt ON mt.account_move_line_id = aml.id
LEFT JOIN uom_uom uom ON uom.id = aml.product_uom_id
LEFT JOIN account_move ai ON ai.id = aml.move_id
WHERE aa.internal_type = 'other' AND (aml.tax_line_id IS NOT NULL OR mt.account_tax_id IS NULL) AND (ai.type IS NULL OR ai.type in ('in_invoice', 'out_invoice'))
WHERE aa.internal_type = 'other' AND (aml.tax_line_id IS NOT NULL OR mt.account_tax_id IS NULL) AND (am.type IS NULL OR am.type in ('in_invoice', 'out_invoice'))
"""
return from_str