Ejemplo n.º 1
0
 def __init__(self, parent):
     BaseResponse.__init__(self, parent)
     self.calc = CalculateInvoice(models, DBSession, self.invoice_id,
                                  persen_denda)
     module_conf = host[self.parent.conf['name']]
     self.parent.conf.update(module_conf)
     self.invoice_profile = FixLength(self.get_invoice_profile_structure())
Ejemplo n.º 2
0
 def __init__(self, parent):
     BaseResponse.__init__(self, parent)
     self.parent = parent
     self.calc = CalculateInvoice(models, DBSession,
                                  parent.from_iso.get_invoice_id(),
                                  persen_denda)
     module_conf = host[self.parent.conf['name']]
     self.parent.conf.update(module_conf)
Ejemplo n.º 3
0
 def get_invoice(self):
     invoice_id_raw = self.from_iso.get_invoice_id()
     self.invoice_id_raw = invoice_id_raw
     self.calc = CalculateInvoice(
                     other_models, OtherDBSession, self.invoice_id_raw)
     if not self.calc.invoice:
         return self.ack_not_available()
     self.set_invoice_profile()
     if self.calc.paid:
         return self.ack_already_paid()
     return self.calc.invoice
 def show(self, option):
     sample_count = int(option.sample_count)
     q = DBSession.query(models.Invoice).filter(models.Invoice.kode_bayar != None).\
               filter(models.Invoice.kode_bayar != '')
     if option.min:
         n = int(option.min)
         q = q.filter(models.Invoice.nominal >= n)
     if option.max:
         n = int(option.max)
         q = q.filter(models.Invoice.nominal <= n)
     q = q.order_by(models.Invoice.nominal)
     offset = -1
     count = 0
     print('START *************')
     while True:
         if count >= sample_count:
             break
         offset += 1
         row = q.offset(offset).first()
         if not row:
             break
         calc = CalculateInvoice(models, DBSession, row.kode_bayar)
         if calc.invoice and calc.paid:
             continue
         count += 1
         msg = '#{no}/{count} {id} Rp {total}'.format(no=count,
                 id=row.kode_bayar, total=calc.tagihan, count=sample_count)
         print(msg)
     print('SELESAI *************')
Ejemplo n.º 5
0
 def show(self, option):
     sample_count = int(option.sample_count)
     q = DBSession.query(models.Invoice).filter_by(status_bayar=0)
     if option.min:
         n = int(option.min)
         q = q.filter(models.Invoice.jml_tagihan >= n)
     if option.max:
         n = int(option.max)
         q = q.filter(models.Invoice.jml_tagihan <= n)
     q = q.order_by(models.Invoice.jml_tagihan)
     offset = -1
     count = 0
     while True:
         if count >= sample_count:
             break
         offset += 1
         row = q.offset(offset).first()
         if not row:
             break
         calc = CalculateInvoice(models, DBSession, row.no_tagihan)
         if calc.tagihan < 1:
             continue
         count += 1
         msg = '#{no}/{count} {id} Rp {total}'.format(no=count,
                                                      id=row.no_tagihan,
                                                      total=calc.tagihan,
                                                      count=sample_count)
         print(msg)
 def show(self, option):
     sample_count = int(option.sample_count)
     q = DBSession.query(
         models.Invoice).filter_by(status_pembayaran=0).filter(
             models.Invoice.bphtb_harus_dibayarkan > 0)
     offset = -1
     count = 0
     while True:
         if count >= sample_count:
             break
         offset += 1
         row = q.offset(offset).first()
         if not row:
             break
         invoice_id = FixLength(self.get_invoice_id_structure())
         invoice_id['Tahun'] = row.tahun
         invoice_id['Kode'] = row.kode
         invoice_id['SSPD No'] = row.no_sspd
         calc = CalculateInvoice(models, DBSession, invoice_id,
                                 persen_denda)
         if calc.total < 1:
             continue
         count += 1
         invoice_id_raw = invoice_id.get_raw()
         self.on_print(option, count, invoice_id_raw, calc)
Ejemplo n.º 7
0
 def show(self, option):
     sample_count = int(option.sample_count)
     q = DBSession.query(models.Invoice).filter_by(status_pembayaran=0)
     q = q.order_by(models.Invoice.bphtb_harus_dibayarkan)
     offset = -1
     count = 0
     while True:
         if count >= sample_count:
             break
         offset += 1
         row = q.offset(offset).first()
         if not row:
             break
         invoice_id = FixLength(self.get_invoice_id_structure())
         invoice_id['Tahun'] = row.tahun
         invoice_id['Kode'] = row.kode
         invoice_id['SSPD No'] = row.no_sspd
         calc = CalculateInvoice(models, DBSession, invoice_id,
                                 persen_denda)
         if calc.total < 1:
             continue
         count += 1
         msg = '#{no}/{count} {id} Rp {total}'.format(
             no=count,
             id=invoice_id.get_raw(),
             total=calc.total,
             count=sample_count)
         print(msg)
 def show(self, option):
     sample_count = int(option.sample_count)
     q = DBSession.query(models.Invoice.tahun, models.Invoice.sptno,
                         models.Rekening.rekeningnm,
                         models.Rekening.rekeningkd)
     q = q.filter(models.Invoice.pajak_id == models.Pajak.id)
     q = q.filter(models.Pajak.rekening_id == models.Rekening.id)
     q = q.filter(models.Invoice.status_pembayaran == 0)
     if option.jenis:
         pola = '%{nama}%'.format(nama=option.jenis)
         q = q.filter(models.Rekening.rekeningnm.ilike(pola))
     if option.berdenda:
         q = q.filter(models.Invoice.jatuhtempotgl < date.today())
     elif option.tanpa_denda:
         q = q.filter(models.Invoice.jatuhtempotgl >= date.today())
     q = q.filter(models.Invoice.pajak_terhutang > 0)
     q = q.order_by(models.Invoice.pajak_terhutang)
     #q = q.order_by(models.Invoice.tahun.desc(), models.Invoice.sptno.desc())
     offset = -1
     count = 0
     while True:
         if count >= sample_count:
             break
         offset += 1
         row = q.offset(offset).first()
         if not row:
             break
         invoice_id = FixLength(INVOICE_ID)
         invoice_id['Tahun'] = row.tahun
         invoice_id['SPT No'] = row.sptno
         invoice_id_raw = invoice_id.get_raw()
         calc = CalculateInvoice(models, DBSession, invoice_id_raw,
                                 persen_denda)
         if calc.total < 1:
             continue
         count += 1
         if calc.invoice.jatuhtempotgl:
             jatuh_tempo = calc.invoice.jatuhtempotgl.strftime('%d-%m-%Y')
         else:
             jatuh_tempo = 'tidak ada'
         msg = '#{no}/{count} {id} {nama_rek} {kode_rek} Rp {tagihan} + '\
               'Rp {denda} = Rp {total}, jatuh tempo {jatuh_tempo}'
         msg = msg.format(no=count,
                          id=invoice_id_raw,
                          nama_rek=row.rekeningnm,
                          kode_rek=row.rekeningkd,
                          tagihan=calc.tagihan,
                          denda=calc.denda,
                          total=calc.total,
                          count=sample_count,
                          jatuh_tempo=jatuh_tempo)
         print(msg)
 def show(self, option):
     sample_count = int(option.sample_count)
     q = DBSession.query(models.Invoice.tahun, models.Invoice.sptno,
                         models.Rekening.rekeningnm,
                         models.Rekening.rekeningkd)
     q = q.filter(models.Invoice.pajak_id == models.Pajak.id)
     q = q.filter(models.Pajak.rekening_id == models.Rekening.id)
     q = q.filter(models.Invoice.status_pembayaran == 0)
     if option.jenis:
         pola = '%{nama}%'.format(nama=option.jenis)
         q = q.filter(models.Rekening.rekeningnm.ilike(pola))
     if option.berdenda:
         q = q.filter(models.Invoice.jatuhtempotgl < date.today())
     elif option.tanpa_denda:
         q = q.filter(models.Invoice.jatuhtempotgl >= date.today())
     q = q.filter(models.Invoice.pajak_terhutang > 0)
     q = q.order_by(models.Invoice.pajak_terhutang)
     offset = -1
     count = 0
     while True:
         if count >= sample_count:
             break
         offset += 1
         row = q.offset(offset).first()
         if not row:
             break
         invoice_id = FixLength(INVOICE_ID)
         invoice_id['Tahun'] = row.tahun
         invoice_id['SPT No'] = row.sptno
         invoice_id_raw = invoice_id.get_raw()
         calc = CalculateInvoice(models, iso_models, DBSession,
                                 invoice_id_raw, persen_denda)
         if calc.total < 1:
             continue
         count += 1
         self.on_print(option, count, invoice_id_raw, row, calc)
Ejemplo n.º 10
0
 def show(self, option):
     sample_count = int(option.sample_count)
     q = DBSession.query(
         self.models.Invoice).filter_by(status_pembayaran_sppt='0')
     if option.min:
         n = int(option.min)
         q = q.filter(self.models.Invoice.pbb_yg_harus_dibayar_sppt >= n)
     if option.max:
         n = int(option.max)
         q = q.filter(self.models.Invoice.pbb_yg_harus_dibayar_sppt <= n)
     q = q.order_by(self.models.Invoice.thn_pajak_sppt.desc(),
                    self.models.Invoice.pbb_yg_harus_dibayar_sppt)
     offset = -1
     count = 0
     while True:
         if count >= sample_count:
             break
         offset += 1
         row = q.offset(offset).first()
         if not row:
             break
         calc = CalculateInvoice(self.models, DBSession, self.persen_denda,
                                 row.kd_propinsi, row.kd_dati2,
                                 row.kd_kecamatan, row.kd_kelurahan,
                                 row.kd_blok, row.no_urut, row.kd_jns_op,
                                 row.thn_pajak_sppt)
         if calc.total < 1:
             continue
         count += 1
         invoice_id_raw = sppt2nop(
             calc.invoice) + calc.invoice.thn_pajak_sppt
         msg = '#{no}/{count} {id} Rp {total}'.format(no=count,
                                                      id=invoice_id_raw,
                                                      total=calc.total,
                                                      count=sample_count)
         print(msg)
Ejemplo n.º 11
0
class DbTransaction(Transaction):
    def get_invoice(self):
        invoice_id_raw = self.from_iso.get_invoice_id()
        self.invoice_id_raw = invoice_id_raw
        self.calc = CalculateInvoice(
                        other_models, OtherDBSession, self.invoice_id_raw)
        if not self.calc.invoice:
            return self.ack_not_available()
        self.set_invoice_profile()
        if self.calc.paid:
            return self.ack_already_paid()
        return self.calc.invoice

    # Override
    def set_invoice_profile(self):
        invoice = self.calc.invoice
        izin = query.get_izin_by_name(invoice.initial)
        self.invoice_profile.from_dict({
            'No Bayar': re.sub(r'\D', '', invoice.kode_bayar),
            'Kode Izin': izin.id,
            'Nama Izin': izin.nama,
            # 'Nama Izin': invoice.n_perizinan,
            'Jenis Layanan': '-',
            'No Resi': '-',
            'Pemohon': invoice.nama_wp,
            'Lokasi': invoice.lokasi_izin,
            'Tagihan': self.calc.tagihan,
            'Denda': self.calc.denda,
            'Total': self.calc.total,
            'Pesan': '',
            })
        Transaction.set_invoice_profile(self, self.invoice_profile.get_raw())

    def _inquiry_request_handler(self):
        if self.get_invoice():
            self.set_amount(self.calc.total)
            self.ack()
        else:
            self.set_amount(0)

    # Override
    def inquiry_request_handler(self):
        try:
            self.save_request_log()
            self._inquiry_request_handler()
            self.save_response_log()
            DBSession.commit()
        except:
            self.ack_unknown()

    ###########
    # Payment #
    ###########
    def _payment_request_handler(self):
        inv = self.get_invoice()
        if not inv:
            return
        if self.calc.total != self.get_amount():
            return self.ack_insufficient_fund()
        s_channel_id = self.from_iso.get_channel_id()
        channel_id = int(s_channel_id)
        q = DBSession.query(models.Channel).filter_by(id=channel_id)
        channel = q.first()
        if channel:
            channel_name = channel.nama
        else:
            channel_name = s_channel_id
        pay = self.calc.query_payment(inv).first()
        pay.date_bayar = pay.time_bayar = self.from_iso.get_transaction_datetime()
        pay.cara_bayar = 'Transfer'
        pay.ref_bayar = self.from_iso.get_ntb()
        pay.nominal = self.calc.total - self.calc.denda
        pay.denda = self.calc.denda
        pay.jum_bayar = self.calc.total
        pay.denda_masaberlaku = self.calc.bulan
        pay.is_bayar = 1
        pay.status_pembayaran = 'Lunas'
        pay.pembayaran_melalui = channel_name
        OtherDBSession.add(pay)
        OtherDBSession.flush()
        self.save_iso_payment(pay)
        self.commit()

    # Override
    def payment_request_handler(self):
        try:
            self.save_request_log()
            self._payment_request_handler()
        except:
            self.ack_unknown()

    def save_iso_payment(self, pay):
        ntp = create_ntp()
        self.set_ntp(ntp)
        self.ack()
        self.save_response_log()
        self.update_conf()
        iso_pay = models.IsoPayment(id=self.request_log.id)
        iso_pay.response_id = self.response_log.id
        iso_pay.id_pendaftaran = pay.id
        iso_pay.no_bayar = pay.kode_bayar
        iso_pay.ntp = ntp
        iso_pay.ntb = self.get_ntb()
        iso_pay.tgl = self.from_iso.get_transaction_datetime()
        iso_pay.bank_id = self.conf['id']
        iso_pay.channel_id = self.get_channel_id()
        flush(DBSession, iso_pay)

    ############
    # Reversal #
    ############
    def is_transaction_owner(self, iso_pay):
        self.update_conf()
        return iso_pay.bank_id == self.conf['id']

    def _reversal_request_handler(self):
        invoice_id_raw = self.from_iso.get_invoice_id()
        self.invoice_id_raw = invoice_id_raw
        rev = Reversal(other_models, OtherDBSession, self.invoice_id_raw)
        if not rev.payment:
            return self.ack_payment_not_found()
        if not rev.paid:
            return self.parent.ack_invoice_open()
        iso_pay = query.get_iso_payment(rev.payment)
        if not iso_pay:
            return self.ack_iso_payment_not_found()
        if not self.is_transaction_owner(iso_pay):
            return self.ack_payment_owner()
        if iso_pay.ntb != self.get_ntb():
            return self.ack_ntb()
        self.ack()
        self.save_response_log()
        iso_rev = models.IsoReversal(id=iso_pay.id)
        iso_rev.request_id = self.request_log.id
        iso_rev.response_id = self.response_log.id
        rev.set_unpaid(iso_rev)
        flush(DBSession, iso_rev)
        self.commit()

    def reversal_request_handler(self):
        try:
            self.save_request_log()
            self._reversal_request_handler()
        except:
            self.ack_unknown()

    #######
    # Log #
    #######
    def save_log(self, iso, request_log=None):
        row = models.IsoLog()
        row.forwarder = self.conf['name']
        row.ip = self.get_bank_ip()
        row.mti = iso.getMTI()
        row.is_request = True
        row.raw = iso.getRawIso()
        if request_log:
            row.request_id = request_log.id
        d = dict()
        for bit in TRANSACTION_BITS:
            try:
                val = iso.get_value(bit)
            except BitNotSet:
                continue
            field = 'bit{b}'.format(b=str(bit).zfill(3))
            d[field] = val
        row.from_dict(d)
        flush(DBSession, row)
        return row

    def save_request_log(self):
        self.request_log = self.save_log(self.from_iso)

    def save_response_log(self):
        self.response_log = self.save_log(self, self.request_log)

    ##########
    # Others #
    ##########
    def commit(self):
        DBSession.commit()
        OtherDBSession.commit()

    def update_conf(self):
        bank_name = self.conf['name']
        self.conf.update(host[bank_name])
Ejemplo n.º 12
0
 def __init__(self, parent):
     BaseResponse.__init__(self, parent)
     self.calc = CalculateInvoice(models, DBSession, self.invoice_id_raw)
Ejemplo n.º 13
0
class Inquiry(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        self.calc = CalculateInvoice(models, DBSession, self.invoice_id_raw)

    def init_invoice_profile(self):
        self.invoice_profile = FixLength(INVOICE_PROFILE)
        self.invoice_profile.from_dict({
            'kode pajak': 'BPHTB', 
            'nama pajak': 'BEA PEROLEHAN HAK ATAS TANAH DAN BANGUNAN',
            })

    def set_invoice_profile(self):
        invoice = self.calc.invoice
        self.invoice_profile.from_dict({
            'npwpd': invoice.npwp_wp,
            'nama' : invoice.nama_wp,
            'alamat': invoice.alamat_wp,
            'tagihan': self.calc.tagihan,
            'jumlah': self.calc.tagihan,
            'jenis perolehan' : invoice.kd_bphtb,
            'nilai perolehan': invoice.npop_omset,
            'rt wp': invoice.rt_wp, 
            'rw wp': invoice.rw_wp, 
            'kelurahan wp': invoice.kelurahan_wp,
            'kecamatan wp': invoice.kecamatan_wp,
            'kota wp': invoice.kota_wp,
            'tahun pajak': invoice.tahun,
            #'nik': invoice.wp_identitas,
            'luas tanah': invoice.luas_bumi,
            'luas bangunan': invoice.luas_bng,
            'alamat op' : invoice.alamat_op,
            })
        self.set_jatuh_tempo()
        self.set_kode_pos_wp()
        self.set_kecamatan_op()
        self.set_kelurahan_op()
        self.set_notaris()
        self.set_invoice_profile_to_parent()

    def is_valid(self, is_need_invoice_profile=True):
        if not self.calc.invoice:
            is_need_invoice_profile and self.set_invoice_profile_to_parent()
            if self.calc.invoice is False:
                return self.parent.ack_invalid_number()
            return self.parent.ack_not_available()
        is_need_invoice_profile and self.set_invoice_profile()
        if self.calc.paid:
            return self.ack_already_paid()
        if self.calc.tagihan <= 0:
            return self.parent.ack_already_paid_2(self.calc.tagihan)
        return True

    def response(self):
        if not self.is_allowed():
            return
        self.init_invoice_profile()
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.tagihan)
        self.save()

    def set_jatuh_tempo(self):
        if self.calc.invoice.jatuh_tempo:
            self.set_invoice_profile_('jatuh tempo',
                self.calc.invoice.jatuh_tempo.strftime('%d%m%Y'))

    def set_kode_pos_wp(self):
        kode_pos = self.calc.invoice.kodepos_wp.strip()
        self.set_invoice_profile_('kode pos wp', kode_pos)

    def set_kecamatan_op(self):
        if self.calc.invoice.kecamatan_op: 
            self.set_invoice_profile_('kecamatan op',
                self.calc.invoice.kecamatan_op) 

    def set_kelurahan_op(self):
        if self.calc.invoice.kelurahan_op: 
            self.set_invoice_profile_('kelurahan op',
                self.calc.invoice.kelurahan_op)

    def set_notaris(self):
        if self.calc.invoice.nm_notaris: 
            self.set_invoice_profile_('notaris', self.calc.invoice.nm_notaris)

    def set_invoice_profile_(self, key, value):
        if value:
            self.invoice_profile.from_dict({key: value})

    def set_invoice_profile_to_parent(self):
        self.parent.set_invoice_profile(self.invoice_profile.get_raw())

    def ack_already_paid(self):
        iso_pay = self.calc.get_iso_payment()
        ntp = ''
        if iso_pay:
            pay = query.get_payment_from_iso(iso_pay)
            if pay.bank_id == self.parent.conf['id']:
                ntp = pay.ntp
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()

    def save(self):
        inq = models.IsoInquiry()
        inq.tgl = datetime.now()
        inq.invoice_id = self.calc.invoice.id
        inq.bank_id = self.parent.conf['id']
        inq.channel_id = self.parent.from_iso.get_channel()
        inq.stan = self.parent.from_iso.get_stan()
        inq.transmission = self.parent.from_iso.get_transmission()
        inq.settlement = self.parent.from_iso.get_settlement()
        DBSession.add(inq)
        DBSession.flush()
        self.commit()
Ejemplo n.º 14
0
class InquiryResponse(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        self.parent = parent
        self.calc = CalculateInvoice(models, DBSession,
                                     parent.from_iso.get_invoice_id(),
                                     persen_denda)
        module_conf = host[self.parent.conf['name']]
        self.parent.conf.update(module_conf)

    def init_invoice_profile(self):
        self.invoice_profile = FixLength(INVOICE_PROFILE)
        self.invoice_profile.from_dict({
            'kode pajak':
            'PADL',
            'nama pajak':
            'PENDAPATAN ASLI DAERAH LAINNYA',
        })

    def set_invoice_profile(self):
        invoice = self.calc.invoice
        op = self.calc.get_op()
        kel = self.calc.get_kelurahan(op.kelurahan_id)
        kec = self.calc.get_kecamatan(kel.kecamatan_id)
        wp = self.calc.get_wp(op)
        nama = self.get_nama_wp(op, wp)
        self.invoice_profile.from_dict({
            'npwpd': wp.npwpd,
            'nama': nama,
            'alamat': wp.alamat,
            'tagihan': self.calc.tagihan,
            'denda': self.calc.denda,
            'jumlah': self.calc.total,
            'alamat op': op.opalamat,
            'kelurahan op': kel.kelurahannm,
            'kecamatan op': kec.kecamatannm,
            'kode pos wp': wp.wpkodepos,
        })
        self.set_jatuh_tempo()
        self.set_invoice_profile_to_parent()

    def get_nama_wp(self, op, wp):
        nama_ = []
        if op.opnm:
            nama_.append(op.opnm)
        nama = self.calc.invoice.r_nama or wp.customernm
        if nama:
            nama_.append(nama)
        return ','.join(nama_)

    def is_valid(self, is_need_invoice_profile=True):
        if not self.calc.invoice:
            is_need_invoice_profile and self.set_invoice_profile_to_parent()
            return self.parent.ack_not_available()
        is_need_invoice_profile and self.set_invoice_profile()
        if self.calc.paid:
            return self.ack_already_paid()
        if self.calc.total <= 0:
            return self.parent.ack_already_paid_2(self.calc.total)
        return True

    def response(self):
        self.init_invoice_profile()
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.total)
        self.parent.ack()

    def set_jatuh_tempo(self):
        if self.calc.invoice.jatuhtempotgl:
            self.set_invoice_profile_(
                'jatuh tempo',
                self.calc.invoice.jatuhtempotgl.strftime('%d%m%Y'))

    def set_invoice_profile_(self, key, value):
        if value:
            self.invoice_profile.from_dict({key: value})

    def set_invoice_profile_to_parent(self):
        self.parent.set_invoice_profile(self.invoice_profile.get_raw())

    def ack_already_paid(self):
        iso_pay = self.calc.get_iso_payment()
        if iso_pay and iso_pay.bank_id == self.parent.conf['id']:
            ntp = iso_pay.ntp
        else:
            ntp = ''
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()
Ejemplo n.º 15
0
class Inquiry(object):
    def __init__(self, parent):
        self.parent = parent
        self.calc = CalculateInvoice(models, DBSession,
                        parent.from_iso.get_invoice_id(), persen_denda)
        module_conf = host[self.parent.conf['name']]
        self.parent.conf.update(module_conf)

    def init_invoice_profile(self):
        self.invoice_profile = FixLength(INVOICE_PROFILE)
        self.invoice_profile.from_dict({
            'kode pajak': 'PADL', 
            'nama pajak': 'PENDAPATAN ASLI DAERAH LAINNYA',
            })

    def set_invoice_profile(self):
        invoice = self.calc.invoice
        op = self.calc.get_op()
        kel = self.calc.get_kelurahan(op.kelurahan_id)
        kec = self.calc.get_kecamatan(kel.kecamatan_id)
        wp = self.calc.get_wp(op)
        nama = self.get_nama_wp(op, wp)
        self.invoice_profile.from_dict({
            'npwpd': wp.npwpd, 
            'nama' : nama,
            'alamat': wp.alamat, 
            'tagihan': self.calc.tagihan,
            'denda': self.calc.denda, 
            'jumlah': self.calc.total,
            'alamat op' : op.opalamat,
            'kelurahan op': kel.kelurahannm,
            'kecamatan op': kec.kecamatannm,
            'kode pos wp': wp.kodepos,
            'masa pajak': ' s.d '.join([invoice.masadari.strftime('%d-%m-%Y'),
                                        invoice.masasd.strftime('%d-%m-%Y')]),
            })
        self.set_jatuh_tempo()
        self.set_invoice_profile_to_parent()

    def get_nama_wp(self, op, wp):
        nama = self.calc.invoice.r_nama or wp.customernm
        nama_ = []
        if op.opnm:
            nama_.append(op.opnm) 
        if nama:
            nama_.append(nama)
        return ','.join(nama_)

    def is_valid(self, is_need_invoice_profile=True):
        if not self.calc.invoice:
            is_need_invoice_profile and self.set_invoice_profile_to_parent()
            return self.parent.ack_not_available()
        is_need_invoice_profile and self.set_invoice_profile()
        if self.calc.paid:
            return self.ack_already_paid()
        if self.calc.total <= 0:
            return self.parent.ack_already_paid_2(self.calc.total)
        return True

    def response(self):
        self.init_invoice_profile()
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.total)
        self.parent.ack()

    def set_jatuh_tempo(self):
        if self.calc.invoice.jatuhtempotgl:
            self.set_invoice_profile_('jatuh tempo',
                self.calc.invoice.jatuhtempotgl.strftime('%d%m%Y'))

    def set_invoice_profile_(self, key, value):
        if value:
            self.invoice_profile.from_dict({key: value})

    def set_invoice_profile_to_parent(self):
        self.parent.set_invoice_profile(self.invoice_profile.get_raw())

    def ack_already_paid(self):
        iso_pay = self.calc.get_iso_payment()
        if iso_pay and iso_pay.bank_id == self.parent.conf['id']:
            ntp = iso_pay.ntp
        else:
            ntp = ''
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()
Ejemplo n.º 16
0
class InquiryResponse(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        self.calc = CalculateInvoice(models, DBSession, self.invoice_id,
                                     persen_denda)
        module_conf = host[self.parent.conf['name']]
        self.parent.conf.update(module_conf)
        self.invoice_profile = FixLength(self.get_invoice_profile_structure())

    def get_invoice_id_structure(self):
        return INVOICE_ID

    def get_invoice_profile_structure(self):
        return INVOICE_PROFILE

    def init_invoice_profile(self):
        self.invoice_profile.from_dict({
            'kode pajak':
            'BPHTB',
            'nama pajak':
            'BEA PEROLEHAN HAK ATAS TANAH DAN BANGUNAN',
        })

    def set_invoice_profile(self):
        invoice = self.calc.invoice
        self.invoice_profile.from_dict({
            'npwpd': invoice.wp_npwp,
            'nama': invoice.wp_nama,
            'alamat': invoice.wp_alamat,
            'tagihan': self.calc.tagihan,
            'denda': self.calc.denda,
            'jumlah': self.calc.total,
            'jenis perolehan': invoice.perolehan_id,
            'nilai perolehan': invoice.npop,
            'rt wp': invoice.wp_rt,
            'rw wp': invoice.wp_rw,
            'kelurahan wp': invoice.wp_kelurahan,
            'kecamatan wp': invoice.wp_kecamatan,
            'kota wp': invoice.wp_kota,
            'tahun pajak': invoice.tahun,
            'nik': invoice.wp_identitas,
            'luas tanah': invoice.bumi_luas,
            'luas bangunan': invoice.bng_luas,
            'alamat op': invoice.op_alamat,
        })
        self.set_jatuh_tempo()
        self.set_kode_pos_wp()
        self.set_kecamatan_op()
        self.set_kelurahan_op()
        self.set_notaris()
        self.set_invoice_profile_to_parent()

    def is_valid(self, is_need_invoice_profile=True):
        if not self.calc.invoice:
            is_need_invoice_profile and self.set_invoice_profile_to_parent()
            if self.calc.invoice is False:
                return self.parent.ack_invalid_number()
            return self.parent.ack_not_available()
        is_need_invoice_profile and self.set_invoice_profile()
        if self.calc.paid:
            return self.ack_already_paid()
        if self.calc.total <= 0:
            return self.parent.ack_already_paid_2(self.calc.total)
        return True

    def response(self):
        self.init_invoice_profile()
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.total)
        self.parent.ack()

    def set_jatuh_tempo(self):
        if self.calc.invoice.tgl_jatuh_tempo:
            self.set_invoice_profile_(
                'jatuh tempo',
                self.calc.invoice.tgl_jatuh_tempo.strftime('%d%m%Y'))

    def set_kode_pos_wp(self):
        kode_pos = self.calc.invoice.wp_kdpos.strip()
        self.set_invoice_profile_('kode pos wp', kode_pos)

    def set_kecamatan_op(self):
        row = self.calc.get_kecamatan()
        if row:
            self.set_invoice_profile_('kecamatan op', row.nm_kecamatan)

    def set_kelurahan_op(self):
        row = self.calc.get_kelurahan()
        if row:
            self.set_invoice_profile_('kelurahan op', row.nm_kelurahan)

    def set_notaris(self):
        row = self.calc.get_customer()
        if row:
            self.set_invoice_profile_('notaris', row.nama)

    def set_invoice_profile_(self, key, value):
        if value:
            self.invoice_profile.from_dict({key: value})

    def set_invoice_profile_to_parent(self):
        self.parent.set_invoice_profile(self.invoice_profile.get_raw())

    def ack_already_paid(self):
        iso_pay = self.calc.get_iso_payment()
        if iso_pay and iso_pay.bank_id == self.parent.conf['id']:
            ntp = iso_pay.ntp
        else:
            ntp = ''
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()
Ejemplo n.º 17
0
 def __init__(self, parent):
     BaseResponse.__init__(self, parent)
     self.calc = CalculateInvoice(models, DBSession, self.invoice_id_raw)
Ejemplo n.º 18
0
class Inquiry(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        self.calc = CalculateInvoice(models, DBSession, self.invoice_id_raw)

    def init_invoice_profile(self):
        self.invoice_profile = FixLength(INVOICE_PROFILE)
        self.invoice_profile.from_dict({
            'kode pajak':
            'BPHTB',
            'nama pajak':
            'BEA PEROLEHAN HAK ATAS TANAH DAN BANGUNAN',
        })

    def set_invoice_profile(self):
        invoice = self.calc.invoice
        self.invoice_profile.from_dict({
            'npwpd': invoice.npwp_wp,
            'nama': invoice.nama_wp,
            'alamat': invoice.alamat_wp,
            'tagihan': self.calc.tagihan,
            'jumlah': self.calc.tagihan,
            'jenis perolehan': invoice.kd_bphtb,
            'nilai perolehan': invoice.npop_omset,
            'rt wp': invoice.rt_wp,
            'rw wp': invoice.rw_wp,
            'kelurahan wp': invoice.kelurahan_wp,
            'kecamatan wp': invoice.kecamatan_wp,
            'kota wp': invoice.kota_wp,
            'tahun pajak': invoice.tahun,
            #'nik': invoice.wp_identitas,
            'luas tanah': invoice.luas_bumi,
            'luas bangunan': invoice.luas_bng,
            'alamat op': invoice.alamat_op,
        })
        self.set_jatuh_tempo()
        self.set_kode_pos_wp()
        self.set_kecamatan_op()
        self.set_kelurahan_op()
        self.set_notaris()
        self.set_invoice_profile_to_parent()

    def is_valid(self, is_need_invoice_profile=True):
        if not self.calc.invoice:
            is_need_invoice_profile and self.set_invoice_profile_to_parent()
            if self.calc.invoice is False:
                return self.parent.ack_invalid_number()
            return self.parent.ack_not_available()
        is_need_invoice_profile and self.set_invoice_profile()
        if self.calc.paid:
            return self.ack_already_paid()
        if self.calc.tagihan <= 0:
            return self.parent.ack_already_paid_2(self.calc.tagihan)
        return True

    def response(self):
        if not self.is_allowed():
            return
        self.init_invoice_profile()
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.tagihan)
        self.save()

    def set_jatuh_tempo(self):
        if self.calc.invoice.jatuh_tempo:
            self.set_invoice_profile_(
                'jatuh tempo',
                self.calc.invoice.jatuh_tempo.strftime('%d%m%Y'))

    def set_kode_pos_wp(self):
        kode_pos = self.calc.invoice.kodepos_wp.strip()
        self.set_invoice_profile_('kode pos wp', kode_pos)

    def set_kecamatan_op(self):
        if self.calc.invoice.kecamatan_op:
            self.set_invoice_profile_('kecamatan op',
                                      self.calc.invoice.kecamatan_op)

    def set_kelurahan_op(self):
        if self.calc.invoice.kelurahan_op:
            self.set_invoice_profile_('kelurahan op',
                                      self.calc.invoice.kelurahan_op)

    def set_notaris(self):
        if self.calc.invoice.nm_notaris:
            self.set_invoice_profile_('notaris', self.calc.invoice.nm_notaris)

    def set_invoice_profile_(self, key, value):
        if value:
            self.invoice_profile.from_dict({key: value})

    def set_invoice_profile_to_parent(self):
        self.parent.set_invoice_profile(self.invoice_profile.get_raw())

    def ack_already_paid(self):
        iso_pay = self.calc.get_iso_payment()
        ntp = ''
        if iso_pay:
            pay = query.get_payment_from_iso(iso_pay)
            if pay.bank_id == self.parent.conf['id']:
                ntp = pay.ntp
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()

    def save(self):
        inq = models.IsoInquiry()
        inq.tgl = datetime.now()
        inq.invoice_id = self.calc.invoice.id
        inq.bank_id = self.parent.conf['id']
        inq.channel_id = self.parent.from_iso.get_channel()
        inq.stan = self.parent.from_iso.get_stan()
        inq.transmission = self.parent.from_iso.get_transmission()
        inq.settlement = self.parent.from_iso.get_settlement()
        DBSession.add(inq)
        DBSession.flush()
        self.commit()
Ejemplo n.º 19
0
 def __init__(self, parent):
     self.parent = parent
     self.calc = CalculateInvoice(models, DBSession,
                     parent.from_iso.get_invoice_id(), persen_denda)
     module_conf = host[self.parent.conf['name']]
     self.parent.conf.update(module_conf)