Commit d03bc5f1 by Owo Sugiana

Bug fixed available_invoice.py

1 parent f983816b
......@@ -27,35 +27,32 @@ class AvailableInvoice:
self.count = count
def run(self):
q_inv = DBSession.query(Spt).filter(Spt.t_totalspt > 0).\
order_by(Spt.t_periodespt.desc(), Spt.t_totalspt, Spt.t_idspt)
q_pay = DBSession.query(Pembayaran).\
filter(Pembayaran.t_statusbayarspt == None).\
order_by(Pembayaran.t_idpembayaranspt.desc())
offset = -1
self.no = 0
awal = time()
while True:
offset += 1
inv = q_inv.offset(offset).limit(1).first()
if not inv:
pay = q_pay.offset(offset).limit(1).first()
if not pay:
break
self.row_handler(inv)
self.row_handler(pay)
if time() - awal > 10:
break
if self.no == self.count:
break
def row_handler(self, inv):
q = DBSession.query(Pembayaran).filter_by(t_idspt=inv.t_idspt)
pay = q.first()
def row_handler(self, pay):
inq = Inquiry(pay.t_kodebayarbanksppt, registry['persen_denda'])
if not inq.total:
return
self.no += 1
nominal = thousand(inq.total)
q = DBSession.query(DetailSpt).filter_by(t_idspt=inv.t_idspt)
op = q.first()
msg = '#{} {} {} {} {} Rp {}'.format(
self.no, pay.t_kodebayarbanksppt, inv.t_periodespt, inv.t_nopbphtbsppt,
op.t_namawppembeli, nominal)
self.no, inq.invoice_id, inq.get_tahun(), inq.get_nop(),
inq.get_nama(), nominal)
print(msg)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!