def setDatiRiepilogo(self, invoice, body): if not invoice.tax_line_ids: raise UserError( _("Invoice {invoice} has no tax lines").format( invoice=invoice.display_name)) for tax_line in invoice.tax_line_ids: tax = tax_line.tax_id riepilogo = DatiRiepilogoType( AliquotaIVA='%.2f' % float_round(tax.amount, 2), ImponibileImporto='%.2f' % float_round(tax_line.base, 2), Imposta='%.2f' % float_round(tax_line.amount, 2)) if tax.amount == 0.0: if not tax.kind_id: raise UserError( _("No 'nature' field for tax %s.") % tax.name) riepilogo.Natura = tax.kind_id.code if not tax.law_reference: raise UserError( _("No 'law reference' field for tax %s.") % tax.name) riepilogo.RiferimentoNormativo = encode_for_export( tax.law_reference, 100) if tax.payability: riepilogo.EsigibilitaIVA = tax.payability # TODO # el.remove(el.find('SpeseAccessorie')) # el.remove(el.find('Arrotondamento')) body.DatiBeniServizi.DatiRiepilogo.append(riepilogo) return True
def setDatiRiepilogo(self, invoice, body): for tax_line in invoice.tax_line_ids: tax = tax_line.tax_id riepilogo = DatiRiepilogoType(AliquotaIVA='%.2f' % tax.amount, ImponibileImporto='%.2f' % tax_line.base, Imposta='%.2f' % tax_line.amount) if tax.amount == 0.0: if not tax.kind_id: raise UserError( _("No 'nature' field for tax %s.") % tax.name) riepilogo.Natura = tax.kind_id.code if not tax.law_reference: raise UserError( _("No 'law reference' field for tax %s.") % tax.name) riepilogo.RiferimentoNormativo = tax.law_reference.encode( 'latin', 'ignore').decode('latin') if tax.payability: riepilogo.EsigibilitaIVA = tax.payability # TODO # el.remove(el.find('SpeseAccessorie')) # el.remove(el.find('Arrotondamento')) body.DatiBeniServizi.DatiRiepilogo.append(riepilogo) return True