Skip to content

Commit

Permalink
[IMP] l10n_it_fatturapa_out: get account_invoice_it_cedente_prestator…
Browse files Browse the repository at this point in the history
…e template easier to override
  • Loading branch information
tafaRU committed Dec 16, 2021
1 parent 4ae3317 commit 5429bcb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
48 changes: 26 additions & 22 deletions l10n_it_fatturapa_out/data/invoice_it_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,44 +296,46 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati)
<CedentePrestatore>
<DatiAnagrafici>
<IdFiscaleIVA>
<IdPaese t-esc="get_vat_country(company_id.vat)" />
<IdCodice t-esc="get_vat_number(company_id.vat)" />
<IdPaese t-esc="get_vat_country(partner_id.vat)" />
<IdCodice t-esc="get_vat_number(partner_id.vat)" />
</IdFiscaleIVA>
<CodiceFiscale
t-if="company_id.partner_id.fiscalcode"
t-esc="company_id.partner_id.fiscalcode"
t-if="partner_id.fiscalcode"
t-esc="partner_id.fiscalcode"
/>
<Anagrafica>
<Denominazione t-esc="company_id.partner_id.display_name" />
<Denominazione t-esc="partner_id.display_name" />
<Nome
t-if="not company_id.partner_id.is_company"
t-esc="company_id.partner_id.firstname"
t-if="not partner_id.is_company"
t-esc="partner_id.firstname"
/>
<Cognome
t-if="not company_id.partner_id.is_company"
t-esc="company_id.partner_id.lastname"
t-if="not partner_id.is_company"
t-esc="partner_id.lastname"
/>
<!-- <Titolo t-esc=""/>-->
<CodEORI
t-if="company_id.partner_id.eori_code"
t-esc="company_id.partner_id.eori_code"
t-if="partner_id.eori_code"
t-esc="partner_id.eori_code"
/>
</Anagrafica>
<!-- <AlboProfessionale t-esc=""/>-->
<!-- <ProvinciaAlbo t-esc=""/>-->
<!-- <NumeroIscrizioneAlbo t-esc=""/>-->
<!-- <DataIscrizioneAlbo t-esc=""/>-->
<RegimeFiscale
t-esc="company_id.fatturapa_fiscal_position_id.code"
/>
<RegimeFiscale>RF01</RegimeFiscale>
<!-- https://github.com/OCA/l10n-italy/issues/2557-->
<!-- TODO: creare fatturapa_fiscal_position_id sul partner e controllare che sia-->
<!-- uguale a quello definito sulla company in preventive_checks-->
<!-- t-esc="partner_id.fatturapa_fiscal_position_id.code"-->
</DatiAnagrafici>
<Sede>
<t t-call="l10n_it_fatturapa_out.account_invoice_it_FatturaPA_sede">
<t t-set="partner_id" t-value="company_id.partner_id" />
</t>
<t
t-call="l10n_it_fatturapa_out.account_invoice_it_FatturaPA_sede"
/>
</Sede>
<StabileOrganizzazione
t-if="company_id.fatturapa_stabile_organizzazione"
t-if="company_id and company_id.fatturapa_stabile_organizzazione"
>
<t t-call="l10n_it_fatturapa_out.account_invoice_it_FatturaPA_sede">
<t
Expand All @@ -343,7 +345,7 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati)
</t>
</StabileOrganizzazione>
<IscrizioneREA
t-if="company_id.rea_office and company_id.rea_code and company_id.rea_liquidation_state"
t-if="company_id and company_id.rea_office and company_id.rea_code and company_id.rea_liquidation_state"
>
<!--1.2.4-->
<Ufficio
Expand All @@ -361,7 +363,7 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati)
/>
<StatoLiquidazione t-esc="company_id.rea_liquidation_state" />
</IscrizioneREA>
<Contatti>
<Contatti t-if="company_id">
<Telefono
t-if="format_phone(company_id.partner_id.phone)"
t-esc="format_phone(company_id.partner_id.phone)"
Expand All @@ -373,7 +375,7 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati)
<Email t-if="company_id.email" t-esc="company_id.email" />
</Contatti>
<RiferimentoAmministrazione
t-if="company_id.fatturapa_pub_administration_ref"
t-if="company_id and company_id.fatturapa_pub_administration_ref"
t-esc="company_id.fatturapa_pub_administration_ref"
/>
</CedentePrestatore>
Expand Down Expand Up @@ -701,7 +703,9 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati)
/>
<t
t-call="l10n_it_fatturapa_out.account_invoice_it_cedente_prestatore"
/>
>
<t t-set="partner_id" t-value="company_id.partner_id" />
</t>
<t
t-call="l10n_it_fatturapa_out.account_invoice_it_rappresentante_fiscale"
/>
Expand Down
6 changes: 6 additions & 0 deletions l10n_it_fatturapa_out/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ def preventive_checks(self):
raise UserError(
_("Invoice %s contains product lines w/o taxes") % invoice.name
)
company_id = invoice.company_id
if company_id.vat != company_id.partner_id.vat:
raise UserError(
_("Invoice %s: company and company partner must have same vat")
% invoice.name
)
return

def action_invoice_cancel(self):
Expand Down
11 changes: 7 additions & 4 deletions l10n_it_fatturapa_out/tests/fatturapa_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@ def AttachFileToInvoice(self, InvoiceId, filename):
}
)

def set_sequences(self, invoice_number, dt):
def set_sequences(
self,
invoice_number,
dt,
sequence_name="Customer Invoices : Check Number Sequence",
):
seq_pool = self.env["ir.sequence"]
inv_seq = seq_pool.search(
[("name", "=", "Customer Invoices : Check Number Sequence")], limit=1
)
inv_seq = seq_pool.search([("name", "=", sequence_name)], limit=1)
seq_date = self.env["ir.sequence.date_range"].search(
[
("sequence_id", "=", inv_seq.id),
Expand Down
6 changes: 4 additions & 2 deletions l10n_it_fatturapa_out/wizard/efattura.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def format_phone(number):
return number
return False

def format_price(line):
def format_price(line, sign=1):
res = line.price_unit
if line.tax_ids and line.tax_ids[0].price_include:
res = line.price_unit / (1 + (line.tax_ids[0].amount / 100))
Expand All @@ -115,7 +115,9 @@ def format_price(line):
res = -res

# XXX arrotondamento?
res = "{prezzo:.{precision}f}".format(prezzo=res, precision=price_precision)
res = "{prezzo:.{precision}f}".format(
prezzo=sign * res, precision=price_precision
)
return res

def format_quantity(line):
Expand Down

0 comments on commit 5429bcb

Please sign in to comment.