Skip to content

Commit 6cbf25d

Browse files
vivp-odoojasa-odoo
authored andcommitted
[IMP] l10n_in: assign gstr section for purchase documents
This commit adds purchase-related selection values to the `l10n_in_gstr_section` field and extends the logic to assign appropriate GSTR sections to purchase move lines (vendor bills and credit notes). This enhancement simplifies the domain logic used in the GSTR-2B report by avoiding complex conditions. task-4750259
1 parent a882e75 commit 6cbf25d

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

addons/l10n_in/data/template/account.tax-in.csv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@
127127
"","","","","","","","","","","","","","","","","","","tax","invoice","","","","","",""
128128
"","","","","","","","","","","","","","","","","","","base","refund","","l10n_in.tax_tag_nil_rated","","","",""
129129
"","","","","","","","","","","","","","","","","","","tax","refund","","","","","",""
130+
"non_gst_supplies_purchase","0% NGST P","Non GST Supplies","Non GST Supplies","purchase","","percent","0.0","","","non_gst_supplies_group","","","","","","","","base","invoice","","l10n_in.tax_tag_non_gst_supplies","","","",""
131+
"","","","","","","","","","","","","","","","","","","tax","invoice","","","","","",""
132+
"","","","","","","","","","","","","","","","","","","base","refund","","l10n_in.tax_tag_non_gst_supplies","","","",""
133+
"","","","","","","","","","","","","","","","","","","tax","refund","","","","","",""
130134
"igst_purchase_0","0% IGST","IGST","IGST 0%","purchase","","percent","0.0","","False","igst_group","","","","","","","","base","invoice","","l10n_in.tax_tag_zero_rated","","","",""
131135
"","","","","","","","","","","","","","","","","","","tax","invoice","","","","","",""
132136
"","","","","","","","","","","","","","","","","","","base","refund","","l10n_in.tax_tag_zero_rated","","","",""
@@ -264,6 +268,12 @@
264268
"","","","","","","","","","","","","","","","","","","base","refund","","l10n_in.tax_tag_base_igst","","","",""
265269
"","","","","","","","","","","","","","","","","","","tax","refund","p10057","","","","",""
266270
"","","","","","","","","","","","","","","","","","-100","tax","refund","p11234","l10n_in.tax_tag_igst","","","",""
271+
"igst_purchase_18_service_rc","18% IGST (IMP-Service)","18% IGST (IMP-Service)","IGST 18%","purchase","","percent","18.0","service","False","igst_group","","","","","","True","","base","invoice","","l10n_in.tax_tag_base_igst","","","",""
272+
"","","","","","","","","","","","","","","","","","","tax","invoice","p10057","","","","",""
273+
"","","","","","","","","","","","","","","","","","-100","tax","invoice","p10057","l10n_in.tax_tag_igst","","","",""
274+
"","","","","","","","","","","","","","","","","","","base","refund","","l10n_in.tax_tag_base_igst","","","",""
275+
"","","","","","","","","","","","","","","","","","","tax","refund","p10057","","","","",""
276+
"","","","","","","","","","","","","","","","","","-100","tax","refund","p10057","l10n_in.tax_tag_igst","","","",""
267277
"sgst_purchase_0_5_rc","0.5% SGST RC","SGST (RC)","SGST 0.5%","none","","percent","0.5","","False","sgst_group","","","","","","True","","base","invoice","","l10n_in.tax_tag_base_sgst","","fiscal_position_in_reverse_charge_intra","",""
268278
"","","","","","","","","","","","","","","","","","","tax","invoice","p10057","","","","",""
269279
"","","","","","","","","","","","","","","","","","-100","tax","invoice","p11232","l10n_in.tax_tag_sgst","","","",""

addons/l10n_in/models/account_move_line.py

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ class AccountMoveLine(models.Model):
2929
("sale_cdnur_exp_wop", "CDNUR(EXP-WOP)"),
3030
("sale_nil_rated", "Nil Rated"),
3131
("sale_out_of_scope", "Out of Scope"),
32+
("purchase_b2b_regular", "B2B Regular"),
33+
("purchase_b2c_regular", "B2C Regular"),
34+
("purchase_b2b_rcm", "B2B RCM"),
35+
("purchase_b2c_rcm", "B2C RCM"),
36+
("purchase_imp_services", "IMP(service)"),
37+
("purchase_imp_goods", "IMP(goods)"),
38+
("purchase_cdnr_regular", "CDNR Regular"),
39+
("purchase_cdnur_regular", "CDNUR Regular"),
40+
("purchase_cdnr_rcm", "CDNR RCM"),
41+
("purchase_cdnur_rcm", "CDNUR RCM"),
42+
("purchase_nil_rated", "Nil Rated"),
43+
("purchase_out_of_scope", "Out of Scope"),
3244
],
3345
string="GSTR Section",
3446
index=True,
@@ -95,6 +107,9 @@ def tags_have_categ(line_tax_tags, category):
95107
def is_invoice(move):
96108
return move.is_inbound() and not move.debit_origin_id
97109

110+
def is_move_bill(move):
111+
return move.is_outbound() and not move.debit_origin_id
112+
98113
def get_transaction_type(move):
99114
return 'intra_state' if move.l10n_in_state_id == move.company_id.state_id else 'inter_state'
100115

@@ -199,14 +214,84 @@ def get_sales_section(line, tax_tags_dict):
199214
# If none of the above match, default to out of scope
200215
return 'sale_out_of_scope'
201216

217+
def get_purchase_section(line, tax_tags_dict):
218+
move = line.move_id
219+
gst_treatment = move.l10n_in_gst_treatment
220+
line_tags = line.tax_tag_ids.ids
221+
is_bill = is_move_bill(move)
222+
223+
# If no relevant tags are found, or the tags do not match any category, mark as out of scope
224+
if not line_tags or not any(tags_have_categ(line_tags, c) for c in tax_tags_dict):
225+
return 'purchase_out_of_scope'
226+
227+
# Nil rated purchases
228+
if gst_treatment != 'overseas' and tags_have_categ(line_tags, 'nil'):
229+
return 'purchase_nil_rated'
230+
231+
if is_bill:
232+
# B2B Regular and Reverse Charge purchases
233+
if gst_treatment in ('regular', 'composition', 'uin_holders') and tags_have_categ(line_tags, 'gst'):
234+
if is_reverse_charge_tax(line):
235+
return 'purchase_b2b_rcm'
236+
return 'purchase_b2b_regular'
237+
238+
if gst_treatment in ('special_economic_zone', 'deemed_export') and tags_have_categ(line_tags, 'export_sez') and not is_reverse_charge_tax(line):
239+
return 'purchase_b2b_regular'
240+
241+
# B2C: Unregistered or Consumer sales with gst tags
242+
if gst_treatment in ('unregistered', 'consumer') and tags_have_categ(line_tags, 'gst'):
243+
if is_reverse_charge_tax(line):
244+
return 'purchase_b2c_rcm'
245+
return 'purchase_b2c_regular'
246+
247+
# export service type products purchases
248+
if any(tax.tax_scope == 'service' for tax in line.tax_ids | line.tax_line_id) and gst_treatment == 'overseas' and tags_have_categ(line_tags, 'export_sez'):
249+
return 'purchase_imp_services'
250+
251+
# export goods type products purchases
252+
if gst_treatment == 'overseas' and tags_have_categ(line_tags, 'export_sez') and not is_reverse_charge_tax(line):
253+
return 'purchase_imp_goods'
254+
255+
if not is_bill:
256+
# credit notes for b2b purchases
257+
if gst_treatment in ('regular', 'composition', 'uin_holders') and tags_have_categ(line_tags, 'gst'):
258+
if is_reverse_charge_tax(line):
259+
return 'purchase_cdnr_rcm'
260+
return 'purchase_cdnr_regular'
261+
262+
# credit notes for b2c purchases
263+
if gst_treatment in ('unregistered', 'consumer') and tags_have_categ(line_tags, 'gst'):
264+
if is_reverse_charge_tax(line):
265+
return 'purchase_cdnur_rcm'
266+
return 'purchase_cdnur_regular'
267+
268+
if not is_reverse_charge_tax(line):
269+
if gst_treatment in ('special_economic_zone', 'deemed_export') and tags_have_categ(line_tags, 'export_sez'):
270+
return 'purchase_cdnr_regular'
271+
272+
if gst_treatment == 'overseas' and tags_have_categ(line_tags, 'export_sez'):
273+
return 'purchase_cdnur_regular'
274+
275+
# If none of the above match, default to out of scope
276+
return 'purchase_out_of_scope'
277+
202278
indian_sale_moves_lines = self.filtered(
203279
lambda l: l.move_id.country_code == 'IN'
204280
and l.move_id.is_sale_document(include_receipts=True)
205281
and l.display_type in ('product', 'tax')
206282
)
207-
if not indian_sale_moves_lines:
283+
indian_moves_purchase_lines = self.filtered(
284+
lambda l: l.move_id.country_code == 'IN'
285+
and l.move_id.is_purchase_document(include_receipts=True)
286+
and l.display_type in ('product', 'tax')
287+
)
288+
if not indian_sale_moves_lines and not indian_moves_purchase_lines:
289+
# No Indian sale or purchase lines to process
208290
return
209291
tax_tags_dict = self._get_l10n_in_tax_tag_ids()
210292

211293
for move_line in indian_sale_moves_lines:
212294
move_line.l10n_in_gstr_section = get_sales_section(move_line, tax_tags_dict)
295+
296+
for move_line in indian_moves_purchase_lines:
297+
move_line.l10n_in_gstr_section = get_purchase_section(move_line, tax_tags_dict)

0 commit comments

Comments
 (0)