parent
97833b9583
commit
c7a528eee3
|
@ -5,7 +5,8 @@ from trytond.pool import PoolMeta
|
|||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
from .aeat import (BOOK_KEY, OPERATION_KEY, SEND_SPECIAL_REGIME_KEY,
|
||||
RECEIVE_SPECIAL_REGIME_KEY, IVA_SUBJECTED, EXEMPTION_CAUSE)
|
||||
RECEIVE_SPECIAL_REGIME_KEY, IVA_SUBJECTED, EXEMPTION_CAUSE,
|
||||
IVA_NOT_SUBJECTED)
|
||||
|
||||
|
||||
__all__ = ['Configuration', 'TemplateTax', 'Tax']
|
||||
|
@ -55,6 +56,8 @@ class TemplateTax(metaclass=PoolMeta):
|
|||
'Received Key')
|
||||
sii_subjected_key = fields.Selection(IVA_SUBJECTED, 'Subjected Key')
|
||||
sii_exemption_cause = fields.Selection(EXEMPTION_CAUSE, 'Exemption Cause')
|
||||
sii_not_subjected_key = fields.Selection(IVA_NOT_SUBJECTED,
|
||||
'Not Subjected Key')
|
||||
tax_used = fields.Boolean('Used in Tax')
|
||||
invoice_used = fields.Boolean('Used in invoice Total')
|
||||
|
||||
|
@ -99,6 +102,8 @@ class Tax(metaclass=PoolMeta):
|
|||
sii_received_key = fields.Selection(RECEIVE_SPECIAL_REGIME_KEY,
|
||||
'Received Key')
|
||||
sii_subjected_key = fields.Selection(IVA_SUBJECTED, 'Subjected Key')
|
||||
sii_not_subjected_key = fields.Selection(IVA_NOT_SUBJECTED,
|
||||
'Not Subjected Key')
|
||||
sii_exemption_cause = fields.Selection(EXEMPTION_CAUSE, 'Exemption Cause')
|
||||
tax_used = fields.Boolean('Used in Tax')
|
||||
invoice_used = fields.Boolean('Used in invoice Total')
|
||||
|
|
7
aeat.py
7
aeat.py
|
@ -205,9 +205,14 @@ EXEMPTION_CAUSE = [
|
|||
('E4', 'Exempt on account of Article 23 and Article 24'),
|
||||
('E5', 'Exempt on account of Article 25'),
|
||||
('E6', 'Exempt on other grounds'),
|
||||
('NotSubject', 'Not Subject'),
|
||||
]
|
||||
|
||||
IVA_NOT_SUBJECTED = [
|
||||
(None, ''),
|
||||
('7_14', 'Article 7, 14, others'),
|
||||
('location_rule', 'Location Rules'),
|
||||
]
|
||||
|
||||
_STATES = {
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}
|
||||
|
|
|
@ -39,11 +39,14 @@ class BaseInvoiceMapper(Model):
|
|||
def exempt_kind(self, tax):
|
||||
return attrgetter('sii_exemption_cause')(tax)
|
||||
|
||||
def not_subject_kind(self, tax):
|
||||
return attrgetter('sii_not_subjected_key')(tax)
|
||||
|
||||
def not_subject(self, invoice):
|
||||
base = 0
|
||||
for line in invoice.lines:
|
||||
for tax in line.taxes:
|
||||
if tax.sii_exemption_cause == 'NotSubject':
|
||||
if tax.sii_not_subjected_key:
|
||||
base += attrgetter('amount')(line)
|
||||
return base
|
||||
|
||||
|
@ -271,10 +274,12 @@ class IssuedInvoiceMapper(BaseInvoiceMapper):
|
|||
def location_rules(self, tax, must_detail_op):
|
||||
return (tax.sii_issued_key == '08'
|
||||
or (must_detail_op and self.not_exempt_kind(tax) == 'S2')
|
||||
or (self.exempt_kind(tax) == 'NotSubject'))
|
||||
or (self.not_subject_kind(tax) == 'location_rule'))
|
||||
|
||||
def art_7_14(self, tax):
|
||||
return bool(tax.sii_issued_key == '10')
|
||||
return (
|
||||
bool(tax.sii_issued_key == '10')
|
||||
or self.not_subject_kind(tax) == '7_14')
|
||||
|
||||
def build_issued_invoice(self, invoice):
|
||||
ret = {
|
||||
|
@ -331,6 +336,7 @@ class IssuedInvoiceMapper(BaseInvoiceMapper):
|
|||
for tax in self.taxes(invoice):
|
||||
exempt_kind = self.exempt_kind(tax.tax)
|
||||
not_exempt_kind = self.not_exempt_kind(tax.tax)
|
||||
not_subject_kind = self.not_subject_kind(tax.tax)
|
||||
if (not_exempt_kind in ('S2', 'S3') and
|
||||
'NIF' not in ret.get('Contraparte', {})):
|
||||
raise UserError(gettext('aeat_sii.msg_missing_nif',
|
||||
|
@ -360,22 +366,22 @@ class IssuedInvoiceMapper(BaseInvoiceMapper):
|
|||
detail['Sujeta']['NoExenta']['DesgloseIVA'][
|
||||
'DetalleIVA'].append(tax_detail)
|
||||
elif exempt_kind:
|
||||
if exempt_kind != 'NotSubject':
|
||||
baseimponible = self.get_tax_base(tax)
|
||||
if detail['Sujeta'].get('Exenta', {}).get(
|
||||
'DetalleExenta', {}).get(
|
||||
'CausaExencion', None) == exempt_kind:
|
||||
baseimponible += detail['Sujeta'].get('Exenta').get(
|
||||
'DetalleExenta').get('BaseImponible', 0)
|
||||
detail['Sujeta'].update({
|
||||
'Exenta': {
|
||||
'DetalleExenta': {
|
||||
'CausaExencion': exempt_kind,
|
||||
'BaseImponible': baseimponible
|
||||
}
|
||||
baseimponible = self.get_tax_base(tax)
|
||||
if detail['Sujeta'].get('Exenta', {}).get(
|
||||
'DetalleExenta', {}).get(
|
||||
'CausaExencion', None) == exempt_kind:
|
||||
baseimponible += detail['Sujeta'].get('Exenta').get(
|
||||
'DetalleExenta').get('BaseImponible', 0)
|
||||
detail['Sujeta'].update({
|
||||
'Exenta': {
|
||||
'DetalleExenta': {
|
||||
'CausaExencion': exempt_kind,
|
||||
'BaseImponible': baseimponible
|
||||
}
|
||||
})
|
||||
elif self.art_7_14(tax.tax):
|
||||
}
|
||||
})
|
||||
elif not_subject_kind:
|
||||
if self.art_7_14(tax.tax):
|
||||
detail['NoSujeta'].setdefault(
|
||||
'ImportePorArticulos7_14_Otros', 0)
|
||||
detail['NoSujeta']['ImportePorArticulos7_14_Otros'
|
||||
|
@ -387,6 +393,8 @@ class IssuedInvoiceMapper(BaseInvoiceMapper):
|
|||
] += self.get_tax_base(tax)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
# remove unused key
|
||||
for key in ('Sujeta', 'NoSujeta'):
|
||||
|
|
28
locale/es.po
28
locale/es.po
|
@ -86,6 +86,10 @@ msgctxt "field:account.tax,tax_used:"
|
|||
msgid "Used in Tax"
|
||||
msgstr "Usado en impuestos"
|
||||
|
||||
msgctxt "field:account.tax,sii_not_subjected_key:"
|
||||
msgid "Not Subjected Key"
|
||||
msgstr "Clave no sujeto"
|
||||
|
||||
msgctxt "field:account.tax.template,invoice_used:"
|
||||
msgid "Used in invoice Total"
|
||||
msgstr "Usado en total de factura"
|
||||
|
@ -114,6 +118,10 @@ msgctxt "field:account.tax.template,sii_subjected_key:"
|
|||
msgid "Subjected Key"
|
||||
msgstr "Clave sujeto"
|
||||
|
||||
msgctxt "field:account.tax.template,sii_not_subjected_key:"
|
||||
msgid "Not Subjected Key"
|
||||
msgstr "Clave no sujeto"
|
||||
|
||||
msgctxt "field:account.tax.template,tax_used:"
|
||||
msgid "Used in Tax"
|
||||
msgstr "Usado en impuestos"
|
||||
|
@ -924,9 +932,13 @@ msgctxt "selection:account.tax,sii_exemption_cause:"
|
|||
msgid "Exempt on other grounds"
|
||||
msgstr "Exenta, otros"
|
||||
|
||||
msgctxt "selection:account.tax,sii_exemption_cause:"
|
||||
msgid "Not Subject"
|
||||
msgstr "No sujeta"
|
||||
msgctxt "selection:account.tax,sii_not_subjected_key:"
|
||||
msgid "Article 7, 14, others"
|
||||
msgstr "Artículo 7, 14, otros"
|
||||
|
||||
msgctxt "selection:account.tax,sii_not_subjected_key:"
|
||||
msgid "Location Rules"
|
||||
msgstr "Reglas de localización"
|
||||
|
||||
msgctxt "selection:account.tax,sii_issued_key:"
|
||||
msgid ""
|
||||
|
@ -1204,9 +1216,13 @@ msgctxt "selection:account.tax.template,sii_exemption_cause:"
|
|||
msgid "Exempt on other grounds"
|
||||
msgstr "Exenta, otros"
|
||||
|
||||
msgctxt "selection:account.tax.template,sii_exemption_cause:"
|
||||
msgid "Not Subject"
|
||||
msgstr "No sujeta"
|
||||
msgctxt "selection:account.tax.template,sii_not_subjected_key:"
|
||||
msgid "Article 7, 14, others"
|
||||
msgstr "Artículo 7, 14, otros"
|
||||
|
||||
msgctxt "selection:account.tax.template,sii_not_subjected_key:"
|
||||
msgid "Location Rules"
|
||||
msgstr "Reglas de localización"
|
||||
|
||||
msgctxt "selection:account.tax.template,sii_issued_key:"
|
||||
msgid ""
|
||||
|
|
2
sii.xml
2
sii.xml
|
@ -371,7 +371,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<record model="account.tax.template" id="account_es.iva_rep_no_sujeto">
|
||||
<field name="sii_book_key">E</field>
|
||||
<field name="sii_issued_key">01</field>
|
||||
<field name="sii_exemption_cause">NotSubject</field>
|
||||
<field name="sii_exemption_cause" eval="None"/>
|
||||
<field name="tax_used" eval="False"/>
|
||||
<field name="invoice_used" eval="True"/>
|
||||
</record>
|
||||
|
|
|
@ -20,6 +20,8 @@ contains the full copyright notices and license terms. -->
|
|||
<field name="sii_subjected_key"/>
|
||||
<label name="sii_exemption_cause"/>
|
||||
<field name="sii_exemption_cause"/>
|
||||
<label name="sii_not_subjected_key"/>
|
||||
<field name="sii_not_subjected_key"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
|
@ -20,6 +20,8 @@ contains the full copyright notices and license terms. -->
|
|||
<field name="sii_subjected_key"/>
|
||||
<label name="sii_exemption_cause"/>
|
||||
<field name="sii_exemption_cause"/>
|
||||
<label name="sii_not_subjected_key"/>
|
||||
<field name="sii_not_subjected_key"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
Loading…
Reference in New Issue