Commit 78f5037a by aa.gusti

webr

1 parent 94225ecc
......@@ -7,7 +7,7 @@ except:
from urllib.parse import quote_plus, quote
from models_webr import (ARInvoice as Invoice, ARSspd as Realisasi,
WebrDBSession as DBSession)
WebrDBSession as DBSession, Rekening, Pajak, ObjekPajak)
from models_eis import (ArPayment as EisArPayment,
ByPayment as EisByPayment,
......@@ -92,12 +92,19 @@ def validate_parent(tabel, departemen_kd, departemen_nm, rekening, tanggal):
def import_ar(all=False):
query = DBSession.query(func.substring(Invoice.unit_kode,1,8).label('unit_kode'),
Invoice.rek_kode, Invoice.rek_nama,
Rekening.kode.label('denda_kode'),
Rekening.nama.label('denda_nama'),
func.to_char(Realisasi.tgl_bayar,'YYYY-MM-DD').label('tgl_bayar'),
func.sum(Realisasi.bunga).label('bunga'),
func.sum(Realisasi.bayar).label('bayar'),).\
join(Realisasi, (Realisasi.arinvoice_id == Invoice.id)).\
join(ObjekPajak, (Invoice.objek_pajak_id==ObjekPajak.id)).\
join(Pajak, (ObjekPajak.pajak_id==Pajak.id)).\
outerjoin(Rekening, (Rekening.id==Pajak.denda_rekening_id)).\
group_by(func.substring(Invoice.unit_kode,1,8),
Invoice.rek_kode, Invoice.rek_nama,
Rekening.kode,
Rekening.nama,
func.to_char(Realisasi.tgl_bayar,'YYYY-MM-DD'))
if not all:
query = query.filter(func.to_char(Realisasi.tgl_bayar,'YYYY-MM-DD') == tanggal.strftime('%Y-%m-%d'))
......@@ -109,7 +116,7 @@ def import_ar(all=False):
departemen_kd = row.unit_kode.strip(),
tanggal = row.tgl_bayar,
).first()
print(row.unit_kode)
print(row.unit_kode, row.rek_kode, row.denda_kode, row.bunga, row.bayar)
unit_nm = EisDBSession.query(EisOpd).\
filter_by(tahun = str(tahun),
kode = row.unit_kode.strip(),
......@@ -127,26 +134,25 @@ def import_ar(all=False):
eis.departemen_nm = unit_nm
eis.jumlah = row.bayar - row.bunga
EisDBSession.add(eis)
if row.bunga:
pass
if row.bunga and row.denda_kode:
# TODO
# eis = EisDBSession.query(EisArPayment).\
# filter_by(tahun = str(tahun),
# kode = row.rek_kode.strip(),
# departemen_kd = row.unit_kode.strip(),
# tanggal = row.tanggal.date(),
# ).first()
# if not eis:
# eis = EisArPayment()
# eis.tahun = str(row.tahun)
# eis.kode = row.rek_kode.strip()
# eis.departemen_kd = row.unit_kode.strip()
# eis.tanggal = row.tanggal.date()
# eis.level_id = row.kd_rekening.count('.')
# eis.nama = row.rek_nama.strip()
# eis.departemen_nm = row.unit_nama.strip()
# eis.jumlah = row.bayar - row.denda
# EisDBSession.add(eis)
eis = EisDBSession.query(EisArPayment).\
filter_by(tahun = str(tahun),
kode = row.denda_kode and row.denda_kode.strip() or '',
departemen_kd = row.unit_kode.strip(),
tanggal = row.tgl_bayar,
).first()
if not eis:
eis = EisArPayment()
eis.tahun = str(tahun)
eis.kode = row.denda_kode.strip()
eis.departemen_kd = row.unit_kode.strip()
eis.tanggal = row.tanggal.date()
eis.level_id = row.denda_kode.count('.')
eis.nama = row.denda_nama.strip()
eis.departemen_nm = row.unit_nama.strip()
eis.jumlah = row.bunga
EisDBSession.add(eis)
EisDBSession.flush()
validate_parent(EisArPayment, eis.departemen_kd, eis.departemen_nm, eis.kode, eis.tanggal)
......
......@@ -123,3 +123,25 @@ class ARSspd(CommonModel, WebrBase):
UniqueConstraint(arinvoice_id,pembayaran_ke,name='arsspd_uq')
UniqueConstraint(tahun_id,unit_id,name='arsspd_no_uq')
class Pajak(NamaModel, WebrBase):
__tablename__ = 'pajaks'
status = Column(Integer, default=1)
rekening_id = Column(Integer, ForeignKey("rekenings.id"))
tahun = Column(Integer, nullable=False, default=0)
tarif = Column(Float, nullable=False, default=0)
denda_rekening_id = Column(Integer, nullable=True, default=0)
UniqueConstraint('rekening_id','tahun', name='rekening_tahun')
class ObjekPajak(NamaModel, WebrBase):
__tablename__ = 'objekpajaks'
__table_args__ = (UniqueConstraint('subjekpajak_id', 'kode',
name='objekpajak_kode_uq'),)
status_grid = Column(SmallInteger, nullable=False, default=0) # 0 Biasa - 1 SPTPD
status = Column(Integer, default=1) # 0 Inaktif - 1 Aktif
alamat_1 = Column(String(128))
alamat_2 = Column(String(128))
wilayah_id = Column(Integer, ForeignKey("wilayahs.id"))
unit_id = Column(Integer, ForeignKey("units.id"))
pajak_id = Column(Integer, ForeignKey("pajaks.id"))
subjekpajak_id = Column(Integer, ForeignKey("subjekpajaks.id"))
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!