Compare commits
1 Commits
master
...
update_fac
Author | SHA1 | Date |
---|---|---|
Alnus Tmp | be760dcb41 |
31
invoice.py
31
invoice.py
|
@ -34,8 +34,8 @@ class Party(metaclass=PoolMeta):
|
|||
|
||||
fe_identifier = fields.Function(fields.Many2One('account_invoice_facho.party.fe_identifier',
|
||||
'Fe Identifier'),
|
||||
'get_fe_identifier')
|
||||
|
||||
'get_fe_identifier2')
|
||||
#Cambiar relación
|
||||
fe_organization = fields.Function(fields.Many2One('account_invoice_facho.party.fe_organization',
|
||||
'Fe Organization'),
|
||||
'get_fe_organization')
|
||||
|
@ -53,13 +53,26 @@ class Party(metaclass=PoolMeta):
|
|||
return None
|
||||
|
||||
def tofacho(self):
|
||||
responsability = list()
|
||||
for identifier in self.fe_identifiers:
|
||||
responsability.append(identifier.code)
|
||||
|
||||
tax_identifier = self.tax_identifier
|
||||
if tax_identifier is None:
|
||||
tax_identifier = ''
|
||||
|
||||
return form.Party(
|
||||
name = self.name,
|
||||
ident = tax_identifier,
|
||||
responsability_code = self.fe_identifier.fe_code,
|
||||
#Agregar Ciudades y codigos a subdivision, mirar a country_subdivision_co
|
||||
address = form.Address(
|
||||
'','', form.City('05001', self.addresses[0].city),
|
||||
form.Country(self.addresses[0].country.code, self.addresses[0].country.name),
|
||||
form.CountrySubentity('05', self.addresses[0].subdivision.name)),
|
||||
#Agregar listas de responsabilidades
|
||||
responsability_code = form.Responsability(responsability),
|
||||
#Agregar lista régimen
|
||||
responsability_regime_code = '48',
|
||||
organization_code = self.fe_organization.fe_code,
|
||||
)
|
||||
|
||||
|
@ -151,8 +164,16 @@ class Invoice(metaclass=PoolMeta):
|
|||
for tax in taxes:
|
||||
if tax.type != 'percentage':
|
||||
raise UserError('Solo se soporta impuesto tipo porcentaje para producto')
|
||||
|
||||
#Construir métodos de pago
|
||||
facho_invoice = invoice.tofacho()
|
||||
payment_mean = form.PaymentMean(id = '1',
|
||||
code = '10',
|
||||
due_at = datetime.now(),
|
||||
payment_id = '1'
|
||||
)
|
||||
facho_invoice.invoice_payment_mean = payment_mean
|
||||
facho_invoice.invoice_issue = datetime.now()
|
||||
|
||||
validator = form.DianResolucion0001Validator()
|
||||
validator.validate(facho_invoice)
|
||||
for (model, field, error) in validator.errors:
|
||||
|
@ -165,6 +186,8 @@ class Invoice(metaclass=PoolMeta):
|
|||
inv.set_ident(self.number)
|
||||
inv.set_customer(self.party.tofacho())
|
||||
inv.set_supplier(self.company.party.tofacho())
|
||||
#Adicionar tipos de operación
|
||||
inv.set_operation_type('10')
|
||||
|
||||
for line in self.lines:
|
||||
inv.add_invoice_line(line.tofacho())
|
||||
|
|
Loading…
Reference in New Issue