[FIX] l10n_in: decrease a value of B2CS and HSN in case of refund

Before this commit:

  B2CS is not decreased in case of refund but it's shown in CDNUR but CDNUR has a condition that only shows a refund of B2CL.
  HSN value is not decreased in case of refund

After this commit:

  Refund is decreased from B2CS and not show that in CDNUR
  HSN value is decreased in case of refund

B2CS = Business to Consumers Small
B2CL = Business to Consumers Large (invoice value is more than Rs.2.5 lakhs)
CDNUR = Credit/Debit Notes for Unregistered
HSN = Harmonized System of Nomenclature(hsn code per product)

closes odoo/odoo#71225

Opw: 2446769
X-original-commit: 9f6b5b889b9402a391a1215c44ce2c5501e1b5de
Related: odoo/enterprise#18497
Signed-off-by: Josse Colpaert <jco@openerp.com>
Signed-off-by: Jigar Vaghela <jva-odoo@users.noreply.github.com>
This commit is contained in:
Jigar Vaghela
2021-05-27 06:52:51 +00:00
parent acb8bcdf3d
commit 83222bee07
2 changed files with 37 additions and 20 deletions
@@ -78,7 +78,7 @@ class L10nInAccountInvoiceReport(models.Model):
sub.shipping_bill_number,
sub.shipping_bill_date,
sub.shipping_port_code_id,
sub.total,
sub.total * sub.b2cs_refund_sign as total,
sub.journal_id,
sub.company_id,
sub.move_type,
@@ -103,11 +103,11 @@ class L10nInAccountInvoiceReport(models.Model):
sub.gst_format_date,
sub.gst_format_refund_date,
sub.gst_format_shipping_bill_date,
sum(sub.igst_amount) * sub.amount_sign AS igst_amount,
sum(sub.cgst_amount) * sub.amount_sign AS cgst_amount,
sum(sub.sgst_amount) * sub.amount_sign AS sgst_amount,
avg(sub.cess_amount) * sub.amount_sign AS cess_amount,
sum(sub.price_total) AS price_total,
sum(sub.igst_amount) * sub.amount_sign * sub.b2cs_refund_sign AS igst_amount,
sum(sub.cgst_amount) * sub.amount_sign * sub.b2cs_refund_sign AS cgst_amount,
sum(sub.sgst_amount) * sub.amount_sign * sub.b2cs_refund_sign AS sgst_amount,
avg(sub.cess_amount) * sub.amount_sign * sub.b2cs_refund_sign AS cess_amount,
sum(sub.price_total) * sub.amount_sign * sub.b2cs_refund_sign AS price_total,
sub.tax_id
"""
return select_str
@@ -231,9 +231,16 @@ class L10nInAccountInvoiceReport(models.Model):
CASE WHEN tag_rep_ln.account_tax_report_line_id IN
(SELECT res_id FROM ir_model_data WHERE module='l10n_in' AND name in ('tax_report_line_sgst', 'tax_report_line_sgst_rc'))
THEN NULL
ELSE (CASE WHEN aml.tax_base_amount <> 0 THEN aml.tax_base_amount ELSE NULL END)
ELSE (CASE WHEN aml.tax_base_amount <> 0 THEN aml.tax_base_amount * (CASE WHEN aml.balance < 0 THEN -1 ELSE 1 END) ELSE NULL END)
END AS price_total,
(CASE WHEN (aj.type = 'sale' AND am.move_type != 'out_refund') or (aj.type = 'purchase' AND at.l10n_in_reverse_charge AND am.move_type != 'in_refund') THEN -1 ELSE 1 END) AS amount_sign,
(CASE WHEN am.move_type in ('in_refund','out_refund')
AND p.vat IS NULL
AND am.l10n_in_gst_treatment != 'overseas'
AND (ABS(am.amount_total_signed) <= 250000 OR
(ps.id = cp.state_id OR p.id IS NULL))
THEN -1
ELSE 1 END) AS b2cs_refund_sign,
(CASE WHEN atr.parent_tax IS NOT NULL THEN atr.parent_tax
ELSE at.id END) AS tax_id,
(CASE WHEN atr.parent_tax IS NOT NULL THEN parent_at.amount
@@ -303,7 +310,8 @@ class L10nInAccountInvoiceReport(models.Model):
sub.gst_format_shipping_bill_date,
sub.amount_sign,
sub.tax_id,
sub.tax_rate
sub.tax_rate,
sub.b2cs_refund_sign
"""
return group_by_str
+21 -12
View File
@@ -46,37 +46,45 @@ class L10nInProductHsnReport(models.Model):
(SELECT res_id FROM ir_model_data WHERE module='l10n_in' AND name in ('tax_report_line_sgst', 'tax_report_line_sgst_rc')) OR at.l10n_in_reverse_charge = True
THEN 0
ELSE aml.quantity
END AS quantity,
END * (CASE WHEN am.move_type in ('in_refund','out_refund') THEN -1 ELSE 1 END)
AS quantity,
CASE WHEN tag_rep_ln.account_tax_report_line_id IN
(SELECT res_id FROM ir_model_data WHERE module='l10n_in' AND name in ('tax_report_line_igst', 'tax_report_line_igst_rc'))
THEN aml.balance * (CASE WHEN aj.type = 'sale' THEN -1 ELSE 1 END)
THEN aml.balance * (CASE WHEN aj.type = 'sale' and am.move_type != 'out_refund' THEN -1 ELSE 1 END)
ELSE 0
END AS igst_amount,
END * (CASE WHEN am.move_type in ('in_refund','out_refund') THEN -1 ELSE 1 END)
AS igst_amount,
CASE WHEN tag_rep_ln.account_tax_report_line_id IN
(SELECT res_id FROM ir_model_data WHERE module='l10n_in' AND name in ('tax_report_line_cgst', 'tax_report_line_cgst_rc'))
THEN aml.balance * (CASE WHEN aj.type = 'sale' THEN -1 ELSE 1 END)
THEN aml.balance * (CASE WHEN aj.type = 'sale' and am.move_type != 'out_refund' THEN -1 ELSE 1 END)
ELSE 0
END AS cgst_amount,
END * (CASE WHEN am.move_type in ('in_refund','out_refund') THEN -1 ELSE 1 END)
AS cgst_amount,
CASE WHEN tag_rep_ln.account_tax_report_line_id IN
(SELECT res_id FROM ir_model_data WHERE module='l10n_in' AND name in ('tax_report_line_sgst', 'tax_report_line_sgst_rc'))
THEN aml.balance * (CASE WHEN aj.type = 'sale' THEN -1 ELSE 1 END)
THEN aml.balance * (CASE WHEN aj.type = 'sale' and am.move_type != 'out_refund' THEN -1 ELSE 1 END)
ELSE 0
END AS sgst_amount,
END * (CASE WHEN am.move_type in ('in_refund','out_refund') THEN -1 ELSE 1 END)
AS sgst_amount,
CASE WHEN tag_rep_ln.account_tax_report_line_id IN
(SELECT res_id FROM ir_model_data WHERE module='l10n_in' AND name in ('tax_report_line_cess', 'tax_report_line_cess_rc'))
THEN aml.balance * (CASE WHEN aj.type = 'sale' THEN -1 ELSE 1 END)
THEN aml.balance * (CASE WHEN aj.type = 'sale' and am.move_type != 'out_refund' THEN -1 ELSE 1 END)
ELSE 0
END AS cess_amount,
END * (CASE WHEN am.move_type in ('in_refund','out_refund') THEN -1 ELSE 1 END)
AS cess_amount,
CASE WHEN tag_rep_ln.account_tax_report_line_id IN
(SELECT res_id FROM ir_model_data WHERE module='l10n_in' AND name in ('tax_report_line_sgst', 'tax_report_line_sgst_rc'))
THEN 0
ELSE (CASE WHEN aml.tax_line_id IS NOT NULL THEN aml.tax_base_amount ELSE aml.balance * (CASE WHEN aj.type = 'sale' THEN -1 ELSE 1 END) END)
END AS price_total,
(CASE WHEN tag_rep_ln.account_tax_report_line_id IN
END * (CASE WHEN am.move_type in ('in_refund','out_refund') THEN -1 ELSE 1 END)
AS price_total,
((CASE WHEN tag_rep_ln.account_tax_report_line_id IN
(SELECT res_id FROM ir_model_data WHERE module='l10n_in' AND name in ('tax_report_line_sgst', 'tax_report_line_sgst_rc'))
THEN 0
ELSE (CASE WHEN aml.tax_line_id IS NOT NULL THEN aml.tax_base_amount ELSE 1 END)
END) + (aml.balance * (CASE WHEN aj.type = 'sale' THEN -1 ELSE 1 END)) AS total
END) + (aml.balance * (CASE WHEN aj.type = 'sale' and am.move_type != 'out_refund' THEN -1 ELSE 1 END))
)* (CASE WHEN am.move_type in ('in_refund','out_refund') THEN -1 ELSE 1 END)
AS total
"""
return select_str
@@ -94,6 +102,7 @@ class L10nInProductHsnReport(models.Model):
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
WHERE aa.internal_type = 'other' AND (aml.tax_line_id IS NOT NULL OR mt.account_tax_id IS NULL)
AND am.state = 'posted'
"""
return from_str