Commit 9ee94495 by Owo Sugiana

Bug fixed saat inquiry yang sudah lunas pada modul jabar

1 parent e4752c24
......@@ -66,6 +66,7 @@ def show(inq):
show_rp('Total Bayar', inq.total_bayar)
show_rp('Total Tagihan', inq.total)
show_field(inq.invoice, 'status')
show_field(inq.invoice, 'status_bayar')
if inq.total_bayar:
pay = inq.get_payment()
show_field(pay, 'tgl_bayar')
......
......@@ -38,7 +38,7 @@ class Inquiry:
payment_model = Payment
ntp_cls = NTP
def __init__(self, invoice_id, persen_denda=2, tgl_bayar=None):
def __init__(self, invoice_id, persen_denda=2, tgl_bayar=None, conf={}):
self.invoice_id = invoice_id
self.persen_denda = persen_denda
self.tgl_bayar = tgl_bayar or date.today()
......@@ -60,26 +60,31 @@ class Inquiry:
q = q.order_by(self.payment_model.pembayaran_ke.desc())
return q.first()
def get_total_payment(self):
DBSession = get_db_session()
q = DBSession.query(
func.sum(self.payment_model.bayar).label('jml'))
q = q.filter_by(arinvoice_id=self.invoice.id)
pay = q.first()
return pay and int(pay.jml or 0)
def hitung(self):
bunga = self.invoice.bunga or 0
bunga = round_up(bunga)
self.tagihan = self.invoice.jumlah - bunga
self.tagihan = round_up(self.tagihan)
DBSession = get_db_session()
q = DBSession.query(
func.sum(self.payment_model.bayar).label('jml'),
func.sum(self.payment_model.bunga).label('denda'))
q = q.filter_by(arinvoice_id=self.invoice.id)
pay = q.first()
self.total_bayar = pay.jml or 0
denda_lalu = pay.denda or 0
tagihan_lalu = self.total_bayar - denda_lalu
self.tagihan -= tagihan_lalu
if self.tagihan < 0:
self.tagihan = 0
else:
self.tagihan = round_up(self.tagihan)
bln, denda_waktu = hitung_denda(
self.tagihan, self.invoice.jatuh_tempo, self.persen_denda,
self.tgl_bayar)
self.denda = denda_waktu + bunga
self.denda = round_up(self.denda)
self.total = self.tagihan + self.denda
self.total_bayar = self.get_total_payment()
if self.total_bayar > 0:
self.total -= self.total_bayar
if self.total < 0:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!