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()
class InquiryResponse(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        self.invoice_profile = FixLength(INVOICE_PROFILE)
        self.invoice_profile.from_dict({
            'Propinsi': self.invoice_id['Propinsi'],
            'Kabupaten': self.invoice_id['Kabupaten'],
            'Kecamatan': self.invoice_id['Kecamatan'],
            'Kelurahan': self.invoice_id['Kelurahan'],
            'Blok': self.invoice_id['Blok'],
            'Urut': self.invoice_id['Urut'],
            'Jenis': self.invoice_id['Jenis'],
            'Tahun Pajak': self.invoice_id['Tahun Pajak'],
            'Nama Kelurahan': nama_kelurahan(self.invoice_id),
            'Nama Kecamatan': nama_kecamatan(self.invoice_id),
            'Nama Propinsi': nama_propinsi(self.invoice_id)})
        try:
            int(self.invoice_id_raw)
        except ValueError:
            self.calc = None
            return
        self.calc = CalculateInvoice(models, DBSession, persen_denda,
            self.invoice_id['Propinsi'], self.invoice_id['Kabupaten'],
            self.invoice_id['Kecamatan'], self.invoice_id['Kelurahan'],
            self.invoice_id['Blok'], self.invoice_id['Urut'],
            self.invoice_id['Jenis'], self.invoice_id['Tahun Pajak'])

    def set_invoice_profile(self):
        inv = self.calc.invoice
        self.parent.set_amount(self.calc.total)
        self.invoice_profile.from_dict({
            'Nama': inv.nm_wp_sppt,
            'Luas Tanah': int(inv.luas_bumi_sppt),
            'Luas Bangunan': int(inv.luas_bng_sppt),
            'Lokasi': inv.jln_wp_sppt,
            'Jatuh Tempo': inv.tgl_jatuh_tempo_sppt.strftime('%Y%m%d'),
            'Tagihan': self.calc.tagihan,
            'Denda': self.calc.denda,
            'Total Bayar': self.calc.total})
        self.set_invoice_profile_to_parent()

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

    def is_valid(self, is_need_invoice_profile=True):
        if not self.calc:
            return self.parent.ack_invalid_number()
        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 ack_already_paid(self):
        pay = self.calc.invoice2payment()
        if pay and self.is_transaction_owner(pay):
            ntp = pay.id
        else:
            ntp = ''
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()

    def response(self):
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.total)
        query.create_inquiry(self.calc, self.parent.from_iso, persen_denda)
        self.commit()
class InquiryResponse(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        self.invoice_profile = FixLength(INVOICE_PROFILE)
        self.invoice_profile.from_dict({
            'Invoice ID': self.invoice_id_raw,
            'Alamat Objek Pajak': nama_kelurahan(self.invoice_id),
            'Kecamatan': nama_kecamatan(self.invoice_id),
            })
        try:
            int(self.invoice_id_raw)
        except ValueError:
            self.calc = None
            return
        self.calc = CalculateInvoice(models, DBSession, persen_denda,
            self.invoice_id['Propinsi'], self.invoice_id['Kabupaten'],
            self.invoice_id['Kecamatan'], self.invoice_id['Kelurahan'],
            self.invoice_id['Blok'], self.invoice_id['Urut'],
            self.invoice_id['Jenis'], self.invoice_id['Tahun Pajak'])

    def set_invoice_profile(self):
        self.parent.set_amount(self.calc.total)
        self.set_invoice_profile_to_parent()

    def set_invoice_profile_to_parent(self):
        if self.calc.invoice:
            self.invoice_profile.from_dict({
                'Nama Wajib Pajak': self.calc.invoice.nm_wp_sppt,
                'Tagihan Pokok': self.calc.tagihan,
                'Denda': self.calc.denda,
                'Total Tagihan': self.calc.total})
        self.parent.set_invoice_profile(self.invoice_profile.get_raw())

    def is_valid(self, is_need_invoice_profile=True):
        if not self.calc:
            return self.parent.ack_invalid_number()
        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.parent.ack_already_paid()
        if self.calc.total <= 0:
            return self.parent.ack_already_paid_2(self.calc.total)
        return True

    def ack_already_paid(self):
        pay = self.calc.invoice2payment()
        ntp = ''
        if pay and self.is_transaction_owner(pay):
            calc = self.calc
            q = DBSession.query(models.Payment).filter_by(
                    propinsi=calc.propinsi,
                    kabupaten=calc.kabupaten,
                    kecamatan=calc.kecamatan,
                    kelurahan=calc.kelurahan,
                    blok=calc.blok,
                    urut=calc.urut,
                    jenis=calc.jenis,
                    tahun=calc.tahun).order_by(
                    models.Payment.ke.desc())
            iso_pay = q.first()
            if iso_pay:
                ntp = iso_pay.id
        self.set_ntp(ntp)
        return self.parent.ack_already_paid()

    def set_ntp(self, ntp):
        self.invoice_profile.from_dict({'NTP': ntp})

    def response(self):
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.total)
        query.create_inquiry(self.calc, self.parent.from_iso, persen_denda)
        self.commit()
Exemple #4
0
class InquiryResponse(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        q_cls = self.get_query_cls()
        self.query = q_cls(models, DBSession)
        inv_struct = self.get_invoice_profile_structure()
        self.invoice_profile = FixLength(inv_struct)
        nama_kelurahan = self.nama_kelurahan()
        nama_kecamatan = self.nama_kecamatan()
        nama_propinsi = self.nama_propinsi()
        self.invoice_profile.from_dict({
            'Propinsi':
            self.invoice_id['Propinsi'],
            'Kabupaten':
            self.invoice_id['Kabupaten'],
            'Kecamatan':
            self.invoice_id['Kecamatan'],
            'Kelurahan':
            self.invoice_id['Kelurahan'],
            'Blok':
            self.invoice_id['Blok'],
            'Urut':
            self.invoice_id['Urut'],
            'Jenis':
            self.invoice_id['Jenis'],
            'Tahun Pajak':
            self.invoice_id['Tahun Pajak'],
            'Nama Kelurahan':
            nama_kelurahan,
            'Nama Kecamatan':
            nama_kecamatan,
            'Nama Propinsi':
            nama_propinsi
        })
        self.calc = self.get_calc()

    def get_query_cls(self):
        return Inquiry

    def get_calc_cls(self):
        return CalculateInvoice

    def get_invoice_profile_structure(self):
        return INVOICE_PROFILE

    def get_calc(self):
        try:
            int(self.invoice_id_raw)
        except ValueError:
            return
        cls = self.get_calc_cls()
        return cls(models, DBSession, persen_denda,
                   self.invoice_id['Propinsi'], self.invoice_id['Kabupaten'],
                   self.invoice_id['Kecamatan'], self.invoice_id['Kelurahan'],
                   self.invoice_id['Blok'], self.invoice_id['Urut'],
                   self.invoice_id['Jenis'], self.invoice_id['Tahun Pajak'])

    def set_invoice_profile(self):
        self.parent.set_amount(self.calc.total)
        nama_jalan = self.nama_jalan()
        inv = self.calc.invoice
        self.invoice_profile.from_dict({
            'Nama':
            inv.nm_wp_sppt,
            'Luas Tanah':
            int(inv.luas_bumi_sppt),
            'Luas Bangunan':
            int(inv.luas_bng_sppt),
            'Lokasi':
            nama_jalan,
            'Jatuh Tempo':
            inv.tgl_jatuh_tempo_sppt.strftime('%Y%m%d'),
            'Tagihan':
            self.calc.tagihan,
            'Denda':
            self.calc.denda,
            'Total Bayar':
            self.calc.total
        })

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

    def nama_jalan(self):
        return self.calc.invoice.jln_wp_sppt

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

    def ack_already_paid(self):
        pay = self.calc.invoice2payment()
        ntp = ''
        if pay and self.is_transaction_owner(pay):
            calc = self.calc
            q = DBSession.query(models.Payment).filter_by(
                propinsi=calc.propinsi,
                kabupaten=calc.kabupaten,
                kecamatan=calc.kecamatan,
                kelurahan=calc.kelurahan,
                blok=calc.blok,
                urut=calc.urut,
                jenis=calc.jenis,
                tahun=calc.tahun).order_by(models.Payment.ke.desc())
            iso_pay = q.first()
            if iso_pay:
                ntp = iso_pay.id
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()

    def response(self):
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.total)
        self.query.create_inquiry(self.calc, self.parent.from_iso,
                                  persen_denda)
        self.commit()
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)

    def set_invoice_profile(self):
        invoice = self.calc.invoice
        self.invoice_profile.from_dict({
            'Kode': invoice.kode,
            'Nama Penyetor': invoice.objek_nama,
            'Alamat 1': invoice.objek_alamat_1,
            'Alamat 2': invoice.objek_alamat_2,
            'Tagihan': self.calc.tagihan,
            'Denda': self.calc.denda,
            'Total': self.calc.total,
            'Kode Rekening': invoice.rekening_kode,
            'Nama Rekening': invoice.rekening_nama,
            'Kode SKPD': invoice.departemen_kode,
            'Nama SKPD': invoice.departemen_nama,
            'Additional 1': pesan1,
            'Additional 2': pesan2,})
        self.set_invoice_profile_to_parent()
        print_debug('Invoice Profile', self.invoice_profile.to_dict())

    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_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):
        pay = self.calc.get_payment()
        if pay and pay.bank_id == self.parent.conf['id']:
            ntp = pay.kode
        else:
            ntp = ''
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()
Exemple #6
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()
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()
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)

    def set_invoice_profile(self):
        invoice = self.calc.invoice
        self.invoice_profile.from_dict({
            'Kode': invoice.kode,
            'Nama Penyetor': invoice.objek_nama,
            'Alamat 1': invoice.objek_alamat_1,
            'Alamat 2': invoice.objek_alamat_2,
            'Tagihan': self.calc.tagihan,
            'Denda': self.calc.denda,
            'Total': self.calc.total,
            'Kode Rekening': invoice.rekening_kode,
            'Nama Rekening': invoice.rekening_nama,
            'Kode SKPD': invoice.departemen_kode,
            'Nama SKPD': invoice.departemen_nama,
            'Additional 1': pesan1,
            'Additional 2': pesan2,
        })
        self.set_invoice_profile_to_parent()
        print_debug('Invoice Profile', self.invoice_profile.to_dict())

    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_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):
        pay = self.calc.get_payment()
        if pay and pay.bank_id == self.parent.conf['id']:
            ntp = pay.kode
        else:
            ntp = ''
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()
Exemple #9
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()
Exemple #10
0
class CalculateInvoice(Invoice):
    def __init__(self, models, DBSession, invoice_id, persen_denda):
        Invoice.__init__(self, models, DBSession, invoice_id)
        if not self.invoice:
            return
        self.persen_denda = persen_denda
        self.nop = FixLength(NOP)
        self.nop.from_dict({
            'Propinsi': self.invoice.kd_propinsi,
            'Kabupaten': self.invoice.kd_dati2,
            'Kecamatan': self.invoice.kd_kecamatan,
            'Kelurahan': self.invoice.kd_kelurahan,
            'Blok': self.invoice.kd_blok,
            'Urut': self.invoice.no_urut,
            'Jenis': self.invoice.kd_jns_op,
            })
        self.hitung()
        self.paid = self.is_paid() or self.total < 1
        if self.paid:
            self.payment = self.get_payment()

    def hitung(self):
        self.tagihan = round_up(self.invoice.bphtb_harus_dibayarkan)
        bln, self.denda = hitung_denda(self.tagihan,
            self.invoice.tgl_jatuh_tempo.date(), self.persen_denda)
        self.denda = round_up(self.denda)
        self.total = self.tagihan + self.denda

    def get_iso_payment(self):
        if not self.invoice or not self.paid or not self.payment:
            return
        return Query.get_iso_payment(self, self.payment)

    def get_nop(self):
        return self.invoice and self.nop.get_raw() or ''

    def get_customer(self):
        q = self.DBSession.query(self.models.Customer).filter_by(
                id=self.invoice.ppat_id)
        return q.first()

    def get_kecamatan(self):
        q = self.DBSession.query(self.models.Kecamatan).filter_by(
                kd_propinsi = self.invoice.kd_propinsi,
                kd_dati2 = self.invoice.kd_dati2,
                kd_kecamatan = self.invoice.kd_kecamatan)
        return q.first()

    def get_kelurahan(self):
        q = self.DBSession.query(self.models.Kelurahan).filter_by(
                kd_propinsi = self.invoice.kd_propinsi,
                kd_dati2 = self.invoice.kd_dati2,
                kd_kecamatan = self.invoice.kd_kecamatan,
                kd_kelurahan = self.invoice.kd_kelurahan)
        return q.first()

    def get_pay_seq(self):
        q = self.DBSession.query(self.models.Payment).filter_by(
                sspd_id=self.invoice.id)
        pay = q.first()
        if pay:
            return pay.pembayaran_ke + 1
        return 1

    def set_paid(self):
        self.invoice.status_pembayaran = 1
        self.DBSession.add(self.invoice)
class InquiryResponse(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        self.parent = parent
        cls = self.get_calc_cls()
        invoice_id_raw = parent.from_iso.get_invoice_id()
        self.calc = cls(self.models, DBSession, invoice_id_raw, persen_denda)
        module_conf = host[self.parent.conf['name']]
        self.parent.conf.update(module_conf)

    def get_calc_cls(self):
        return CalculateInvoice

    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):
        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.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()
class InquiryResponse(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        cls = self.get_calc_cls()
        raw = parent.from_iso.get_invoice_id()
        self.calc = cls(models, DBSession, raw, 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_calc_cls(self):
        return CalculateInvoice

    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):
        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.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.get_bank_id():
            ntp = iso_pay.ntp
        else:
            ntp = ''
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()
class InquiryResponse(BaseResponse):
    def __init__(self, parent):
        BaseResponse.__init__(self, parent)
        self.invoice_profile = FixLength(INVOICE_PROFILE)
        self.invoice_profile.from_dict({
            'Propinsi': self.invoice_id['Propinsi'],
            'Kabupaten': self.invoice_id['Kabupaten'],
            'Kecamatan': self.invoice_id['Kecamatan'],
            'Kelurahan': self.invoice_id['Kelurahan'],
            'Blok': self.invoice_id['Blok'],
            'Urut': self.invoice_id['Urut'],
            'Jenis': self.invoice_id['Jenis'],
            'Tahun Pajak': self.invoice_id['Tahun Pajak'],
            'Nama Kelurahan': nama_kelurahan(self.invoice_id),
            'Nama Kecamatan': nama_kecamatan(self.invoice_id),
            'Nama Propinsi': nama_propinsi(self.invoice_id)})
        try:
            int(self.invoice_id_raw)
        except ValueError:
            self.calc = None
            return
        self.calc = CalculateInvoice(models, DBSession, persen_denda,
            self.invoice_id['Propinsi'], self.invoice_id['Kabupaten'],
            self.invoice_id['Kecamatan'], self.invoice_id['Kelurahan'],
            self.invoice_id['Blok'], self.invoice_id['Urut'],
            self.invoice_id['Jenis'], self.invoice_id['Tahun Pajak'])

    def set_invoice_profile(self):
        inv = self.calc.invoice
        self.parent.set_amount(self.calc.total)
        self.invoice_profile.from_dict({
            'Nama': inv.nm_wp_sppt,
            'Luas Tanah': int(inv.luas_bumi_sppt),
            'Luas Bangunan': int(inv.luas_bng_sppt),
            'Lokasi': inv.jln_wp_sppt,
            'Jatuh Tempo': inv.tgl_jatuh_tempo_sppt.strftime('%Y%m%d'),
            'Tagihan': self.calc.tagihan,
            'Denda': self.calc.denda,
            'Total Bayar': self.calc.total})
        self.set_invoice_profile_to_parent()

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

    def is_valid(self, is_need_invoice_profile=True):
        if not self.calc:
            return self.parent.ack_invalid_number()
        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 ack_already_paid(self):
        pay = self.calc.invoice2payment()
        if pay and self.is_transaction_owner(pay):
            ntp = pay.id
        else:
            ntp = ''
        self.parent.set_ntp(ntp)
        return self.parent.ack_already_paid()

    def response(self):
        if not self.is_valid():
            return self.parent.set_amount(0)
        self.parent.set_amount(self.calc.total)
        query.create_inquiry(self.calc, self.parent.from_iso, persen_denda)
        self.commit()