def generate_presentations(self, data): purchase_builder = presentation.Presentation('ventasCompras', 'comprasCbte') purchase_iva_builder = presentation.Presentation('ventasCompras', 'comprasAlicuotas') purchase_import_builder = presentation.Presentation('ventasCompras', 'comprasImportaciones') sale_builder = presentation.Presentation('ventasCompras', 'ventasCbte') sale_iva_builder = presentation.Presentation('ventasCompras', 'ventasAlicuotas') self.purchase_presentation = PurchaseInvoicePresentation( data=data, builder=purchase_builder, with_prorate=self.with_prorate ) self.purchase_iva_presentation = PurchaseIvaPresentation( data=data, builder=purchase_iva_builder ) self.purchase_import_presentation = PurchaseImportationPresentation( data=data, builder=purchase_import_builder ) self.sale_presentation = SaleInvoicePresentation( data=data, builder=sale_builder ) self.sale_iva_presentation = SaleVatInvoicePresentation( data=data, builder=sale_iva_builder )
def create_perception(self): self.perception_sifere = self.env['perception.sifere'].create({ 'name': "Percepcion SIFERE", 'date_from': datetime.now() - timedelta(days=1), 'date_to': datetime.now() + timedelta(days=1), }) self.perception_line = self.env['account.invoice.perception'].create({ 'name': "Linea Percepcion", 'invoice_id': self.invoice.id, 'perception_id': self.perception.id, 'amount': 400.5, 'jurisdiction': 'nacional', 'create_date': date.today() }) self.lines = presentation.Presentation("sifere", "percepciones") self.code = self.perception_sifere.get_code(self.perception_line)
def create_retention(self): self.retention_sicore = self.env['retention.sicore'].create({ 'name': 'SICORE Ret', 'date_from': date.today() - timedelta(days=1), 'date_to': date.today() + timedelta(days=1), }) self.retention_line = self.env['account.payment.retention'].create({ 'name': 'Linea con retencion en pago', 'payment_id': self.payment.id, 'retention_id': self.env.ref( 'l10n_ar_retentions.retention_retention_ganancias_efectuada'). id, 'jurisdiction': self.env.ref( 'l10n_ar_retentions.retention_retention_ganancias_efectuada'). jurisdiction, 'activity_id': self.env.ref('l10n_ar_retentions.ret_act_19').id, 'base': 1400, 'amount': 400, 'create_date': date.today(), 'certificate_no': '00022', }) self.lines = presentation.Presentation("sicore", "retenciones")
def generate_header_file(self): """ Se genera el archivo de cabecera. Utiliza la API de presentaciones y tools para poder crear los archivos y formatear los datos. :return: objeto de la api (generator), con las lineas de la presentacion creadas. """ self.validate_header() cabecera = presentation_builder.Presentation("ventasCompras", "cabecera") line = cabecera.create_line() line.cuit = self.company_id.vat line.periodo = self.get_period() line.secuencia = self.sequence line.sinMovimiento = 'S' if self.with_prorate: line.prorratearCFC = 'S' line.cFCGlobal = '1' else: line.prorratearCFC = 'N' line.cFCGlobal = '2' line.importeCFCG = 0 line.importeCFCAD = 0 line.importeCFCP = 0 line.importeCFnCG = 0 line.cFCSSyOC = 0 line.cFCCSSyOC = 0 return cabecera
def create_retention(self): self.retention_sifere = self.env['retention.sifere'].create({ 'name': "Retencion SIFERE", 'date_from': datetime.now() - timedelta(days=1), 'date_to': datetime.now() + timedelta(days=1), }) self.retention_line = self.env['account.payment.retention'].create({ 'name': "Linea Retencion", 'payment_id': self.payment.id, 'retention_id': self.retention.id, 'amount': 400.5, 'jurisdiction': 'nacional', 'create_date': date.today(), 'certificate_no': "10", }) self.lines = presentation.Presentation("sifere", "retenciones") self.code = self.retention_sifere.get_code(self.retention_line)
def generate_file(self): presentation_arba = presentation.Presentation("arba", "retenciones") retentions = self.env['account.payment.retention'].search([ ('payment_id.payment_date', '>=', self.date_from), ('payment_id.payment_date', '<=', self.date_to), ('retention_id.type', '=', 'gross_income'), ('retention_id.state_id', '=', self._get_state_b()), ('payment_id.state', '=', 'posted'), ('retention_id.type_tax_use', '=', 'purchase') ]).sorted(key=lambda r: (r.payment_id.payment_date, r.id)) missing_vats = set() invalid_doctypes = set() invalid_vats = set() for r in retentions: vat = r.payment_id.partner_id.vat if not vat: missing_vats.add(r.payment_id.name_get()[0][1]) elif len(vat) < 11: invalid_vats.add(r.payment_id.name_get()[0][1]) if self.partner_document_type_not_cuit(r.payment_id.partner_id): invalid_doctypes.add(r.payment_id.name_get()[0][1]) # si ya encontro algun error, que no siga con el resto del loop porque el archivo no va a salir # pero que siga revisando las retenciones por si hay mas errores, para mostrarlos todos juntos if missing_vats or invalid_doctypes or invalid_vats: continue self.create_line(presentation_arba, r) if missing_vats or invalid_doctypes or invalid_vats: errors = [] if missing_vats: errors.append( "Los partners de los siguientes pagos no poseen numero de CUIT:" ) errors.extend(missing_vats) if invalid_doctypes: errors.append( "El tipo de documento de los partners de los siguientes pagos no es CUIT:" ) errors.extend(invalid_doctypes) if invalid_vats: errors.append( "Los partners de los siguientes pagos poseen numero de CUIT erroneo:" ) errors.extend(invalid_vats) raise Warning("\n".join(errors)) else: self.file = presentation_arba.get_encoded_string() self.filename = 'AR-{vat}-{period}{fortnight}-{activity}-LOTE{lot}.TXT'.format( vat=self.company_id.vat, period=datetime.strptime(self.date_from, '%Y-%m-%d').strftime('%Y%m'), fortnight=self.fortnight, activity=self.activity, lot=self.lot, )
def generate_fiscal_credit_service_import_file(self): """ Se genera el archivo de credito fiscal de servicios. No se encuentra implementado. """ fiscal_credit_file = presentation_builder.Presentation( "ventasCompras", "creditoFiscalImportacionServ") return fiscal_credit_file
def generate_file(self): lines = presentation.Presentation("sifere", "retenciones") retentions = self.env['account.payment.retention'].search([ ('create_date', '>=', self.date_from), ('create_date', '<=', self.date_to), ('retention_id.type', '=', 'gross_income'), ('payment_id.state', '=', 'posted'), ('payment_id.payment_type', '=', 'inbound') ]).sorted(key=lambda r: (r.create_date, r.id)) missing_vats = set() invalid_doctypes = set() invalid_vats = set() missing_codes = set() for r in retentions: code = self.get_code(r) vat = r.payment_id.partner_id.vat if not vat: missing_vats.add(r.payment_id.name_get()[0][1]) elif len(vat) < 11: invalid_vats.add(r.payment_id.name_get()[0][1]) if self.partner_document_type_not_cuit(r.payment_id.partner_id): invalid_doctypes.add(r.payment_id.name_get()[0][1]) if not code: missing_codes.add(r.retention_id.state_id.name) # si ya encontro algun error, que no siga con el resto del loop porque el archivo no va a salir # pero que siga revisando las retenciones por si hay mas errores, para mostrarlos todos juntos if missing_vats or invalid_doctypes or invalid_vats or missing_codes: continue self.create_line(code, lines, r) if missing_vats or invalid_doctypes or invalid_vats or missing_codes: errors = [] if missing_vats: errors.append("Los partners de los siguientes pagos no poseen numero de CUIT:") errors.extend(missing_vats) if invalid_doctypes: errors.append("El tipo de documento de los partners de los siguientes pagos no es CUIT:") errors.extend(invalid_doctypes) if invalid_vats: errors.append("Los partners de los siguientes pagos poseen numero de CUIT erroneo:") errors.extend(invalid_vats) if missing_codes: errors.append("Las siguientes jurisdicciones no poseen codigo:") errors.extend(missing_codes) raise Warning("\n".join(errors)) else: self.file = lines.get_encoded_string() self.filename = 'ret_iibb_{}_{}.txt'.format( str(self.date_from).replace('-', ''), str(self.date_to).replace('-', ''), )
def generate_file(self): lines = presentation.Presentation("sicore", "retenciones") retentions = self.search_retentions() errors = [] for r in retentions: errors = self.validate_fields(r) if errors: continue self.create_line(lines, r) if errors: raise ValidationError("\n".join(errors)) else: self.file = lines.get_encoded_string() self.filename = 'ret_gan_{}_{}.txt'.format( str(self.date_from).replace('-', ''), str(self.date_to).replace('-', ''))