Пример #1
0
    def read_tax(self):
        self.ensure_one()

        conf = self
        token, sign = conf.wsaa_ticket_id.get_token_sign()

        _wsfe = wsfe(conf.cuit, token, sign, conf.url)
        res = _wsfe.fe_param_get_tipos_iva()

        wsfe_tax_obj = self.env['wsfe.tax.codes']

        # Chequeamos los errores
        msg = self.check_errors(res, raise_exception=False)
        if msg:
            # TODO: Hacer un wrapping de los errores, porque algunos son
            # largos y se imprimen muy mal en pantalla
            raise osv.except_osv(_('Error reading taxes'), msg)

        #~ Armo un lista con los codigos de los Impuestos
        for r in res['response']:
            res_c = wsfe_tax_obj.search([('code', '=', r.Id)])

            #~ Si tengo no los codigos de esos Impuestos en la db, los creo
            if not len(res_c):
                fd = datetime.strptime(r.FchDesde, '%Y%m%d')
                try:
                    td = datetime.strptime(r.FchHasta, '%Y%m%d')
                except ValueError:
                    td = False

                wsfe_tax_obj.create({
                    'code': r.Id,
                    'name': r.Desc,
                    'to_date': td,
                    'from_date': fd,
                    'wsfe_config_id': self.id,
                    'from_afip': True
                })
            #~ Si los codigos estan en la db los modifico
            else:
                fd = datetime.strptime(r.FchDesde, '%Y%m%d')
                #'NULL' ?? viene asi de fe_param_get_tipos_iva():
                try:
                    td = datetime.strptime(r.FchHasta, '%Y%m%d')
                except ValueError:
                    td = False

                res_c.write({
                    'code': r.Id,
                    'name': r.Desc,
                    'to_date': td,
                    'from_date': fd,
                    'wsfe_config_id': self.id,
                    'from_afip': True
                })

        return True
Пример #2
0
    def get_invoice_CAE(self, pos, voucher_type, details):
        self.ensure_one()

        conf = self
        token, sign = conf.wsaa_ticket_id.get_token_sign()

        _wsfe = wsfe(conf.cuit, token, sign, conf.url)
        res = _wsfe.fe_CAE_solicitar(pos, voucher_type, details)

        return res
Пример #3
0
    def get_invoice_CAE(self, pos, voucher_type, details):
        self.ensure_one()

        conf = self
        token, sign = conf.wsaa_ticket_id.get_token_sign()

        _wsfe = wsfe(conf.cuit, token, sign, conf.url)
        res = _wsfe.fe_CAE_solicitar(pos, voucher_type, details)

        return res
Пример #4
0
    def get_last_voucher(self, pos, voucher_type):
        self.ensure_one()

        conf = self
        token, sign = conf.wsaa_ticket_id.get_token_sign()

        _wsfe = wsfe(conf.cuit, token, sign, conf.url)
        res = _wsfe.fe_comp_ultimo_autorizado(pos, voucher_type)

        self.check_errors(res)
        self.check_observations(res)
        last = res['response'].CbteNro
        return last
Пример #5
0
    def get_last_voucher(self, pos, voucher_type):
        self.ensure_one()

        conf = self
        token, sign = conf.wsaa_ticket_id.get_token_sign()

        _wsfe = wsfe(conf.cuit, token, sign, conf.url)
        res = _wsfe.fe_comp_ultimo_autorizado(pos, voucher_type)

        self.check_errors(res)
        self.check_observations(res)
        last = res['response'].CbteNro
        return last
Пример #6
0
    def get_voucher_info(self,
                         cr,
                         uid,
                         ids,
                         pos,
                         voucher_type,
                         number,
                         context={}):
        conf = self.browse(cr, uid, ids, context=context)
        token, sign = conf.wsaa_ticket_id.get_token_sign()

        _wsfe = wsfe(conf.cuit, token, sign, conf.url)
        res = _wsfe.fe_comp_consultar(pos, voucher_type, number)

        # Chequeamos si hay errores
        self.check_errors(cr, uid, res)
        res = res['response']

        result = {
            'DocTipo': res[0].DocTipo,
            'DocNro': res[0].DocNro,
            'CbteDesde': res[0].CbteDesde,
            'CbteHasta': res[0].CbteHasta,
            'CbteFch': res[0].CbteFch,
            'ImpTotal': res[0].ImpTotal,
            'ImpTotConc': res[0].ImpTotConc,
            'ImpNeto': res[0].ImpNeto,
            'ImpOpEx': res[0].ImpOpEx,
            'ImpTrib': res[0].ImpTrib,
            'ImpIVA': res[0].ImpIVA,
            'FchServDesde': res[0].FchServDesde,
            'FchServHasta': res[0].FchServHasta,
            'FchVtoPago': res[0].FchVtoPago,
            'MonId': res[0].MonId,
            'MonCotiz': res[0].MonCotiz,
            'Resultado': res[0].Resultado,
            'CodAutorizacion': res[0].CodAutorizacion,
            'EmisionTipo': res[0].EmisionTipo,
            'FchVto': res[0].FchVto,
            'FchProceso': res[0].FchProceso,
            'PtoVta': res[0].PtoVta,
            'CbteTipo': res[0].CbteTipo,
        }

        return result
Пример #7
0
    def read_tax(self):
        self.ensure_one()

        conf = self
        token, sign = conf.wsaa_ticket_id.get_token_sign()

        _wsfe = wsfe(conf.cuit, token, sign, conf.url)
        res = _wsfe.fe_param_get_tipos_iva()

        wsfe_tax_obj = self.env['wsfe.tax.codes']

        # Chequeamos los errores
        msg = self.check_errors(res, raise_exception=False)
        if msg:
            # TODO: Hacer un wrapping de los errores, porque algunos son
            # largos y se imprimen muy mal en pantalla
            raise osv.except_osv(_('Error reading taxes'), msg)

        #~ Armo un lista con los codigos de los Impuestos
        for r in res['response']:
            res_c = wsfe_tax_obj.search([('code', '=', r.Id)])

            #~ Si tengo no los codigos de esos Impuestos en la db, los creo
            if not len(res_c):
                fd = datetime.strptime(r.FchDesde, '%Y%m%d')
                try:
                    td = datetime.strptime(r.FchHasta, '%Y%m%d')
                except ValueError:
                    td = False

                wsfe_tax_obj.create({'code': r.Id, 'name': r.Desc, 'to_date': td,
                                              'from_date': fd, 'wsfe_config_id': self.id, 'from_afip': True})
            #~ Si los codigos estan en la db los modifico
            else:
                fd = datetime.strptime(r.FchDesde, '%Y%m%d')
                #'NULL' ?? viene asi de fe_param_get_tipos_iva():
                try:
                    td = datetime.strptime(r.FchHasta, '%Y%m%d')
                except ValueError:
                    td = False

                res_c.write({'code': r.Id, 'name': r.Desc, 'to_date': td,
                                                       'from_date': fd, 'wsfe_config_id': self.id, 'from_afip': True})

        return True
Пример #8
0
    def get_voucher_info(self, cr, uid, ids, pos, voucher_type, number, context={}):
        self.ensure_one()

        conf = self
        token, sign = conf.wsaa_ticket_id.get_token_sign()

        _wsfe = wsfe(conf.cuit, token, sign, conf.url)
        res = _wsfe.fe_comp_consultar(pos, voucher_type, number)

        self.check_errors(res)
        self.check_observations(res)
        #last = res['response'].CbteNro

        res = res['response']

        result = {
            'DocTipo': res[0].DocTipo,
            'DocNro': res[0].DocNro,
            'CbteDesde': res[0].CbteDesde,
            'CbteHasta': res[0].CbteHasta,
            'CbteFch': res[0].CbteFch,
            'ImpTotal': res[0].ImpTotal,
            'ImpTotConc': res[0].ImpTotConc,
            'ImpNeto': res[0].ImpNeto,
            'ImpOpEx': res[0].ImpOpEx,
            'ImpTrib': res[0].ImpTrib,
            'ImpIVA': res[0].ImpIVA,
            'FchServDesde': res[0].FchServDesde,
            'FchServHasta': res[0].FchServHasta,
            'FchVtoPago': res[0].FchVtoPago,
            'MonId': res[0].MonId,
            'MonCotiz': res[0].MonCotiz,
            'Resultado': res[0].Resultado,
            'CodAutorizacion': res[0].CodAutorizacion,
            'EmisionTipo': res[0].EmisionTipo,
            'FchVto': res[0].FchVto,
            'FchProceso': res[0].FchProceso,
            'PtoVta': res[0].PtoVta,
            'CbteTipo': res[0].CbteTipo,
        }

        return result