Commit d03bc5f1 by Owo Sugiana

Bug fixed available_invoice.py

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