diff --git a/addons/l10n_in_edi/models/account_edi_format.py b/addons/l10n_in_edi/models/account_edi_format.py index fc38229d623..ed99a9231c7 100644 --- a/addons/l10n_in_edi/models/account_edi_format.py +++ b/addons/l10n_in_edi/models/account_edi_format.py @@ -30,13 +30,26 @@ class AccountEdiFormat(models.Model): return journal.company_id.country_id.code == 'IN' return super()._is_enabled_by_default_on_journal(journal) + def _get_l10n_in_base_tags(self): + return ( + self.env.ref('l10n_in.tax_tag_base_sgst').ids + + self.env.ref('l10n_in.tax_tag_base_cgst').ids + + self.env.ref('l10n_in.tax_tag_base_igst').ids + + self.env.ref('l10n_in.tax_tag_base_cess').ids + + self.env.ref('l10n_in.tax_tag_zero_rated').ids + + self.env.ref("l10n_in.tax_tag_exempt").ids + + self.env.ref("l10n_in.tax_tag_nil_rated").ids + + self.env.ref("l10n_in.tax_tag_non_gst_supplies").ids + ) + def _get_move_applicability(self, move): # EXTENDS account_edi self.ensure_one() if self.code != 'in_einvoice_1_03': return super()._get_move_applicability(move) - - if move.is_sale_document() and move.country_code == 'IN' and move.l10n_in_gst_treatment in ( + all_base_tags = self._get_l10n_in_base_tags() + is_under_gst = any(move_line_tag.id in all_base_tags for move_line_tag in move.line_ids.tax_tag_ids) + if move.is_sale_document(include_receipts=True) and move.country_code == 'IN' and is_under_gst and move.l10n_in_gst_treatment in ( "regular", "composition", "overseas", @@ -71,6 +84,7 @@ class AccountEdiFormat(models.Model): error_message += self._l10n_in_validate_partner(move.company_id.partner_id, is_company=True) if not re.match("^.{1,16}$", move.name): error_message.append(_("Invoice number should not be more than 16 characters")) + all_base_tags = self._get_l10n_in_base_tags() for line in move.invoice_line_ids.filtered(lambda line: line.display_type not in ('line_note', 'line_section', 'rounding')): if line.price_subtotal < 0: # Line having a negative amount is not allowed. @@ -79,6 +93,9 @@ class AccountEdiFormat(models.Model): "Please create a credit note instead.")) if line.display_type == 'product' and line.discount < 0: error_message.append(_("Negative discount is not allowed, set in line %s", line.name)) + if not line.tax_tag_ids or not any(move_line_tag.id in all_base_tags for move_line_tag in line.tax_tag_ids): + error_message.append(_( + """Set an appropriate GST tax on line "%s" (if it's zero rated or nil rated then select it also)""", line.product_id.name)) if line.product_id: hsn_code = self._l10n_in_edi_extract_digits(line.product_id.l10n_in_hsn_code) if not hsn_code: