Commit d9695e33 by Owo Sugiana

Penerapan timezone pada command line argument

1 parent b657f5f9
...@@ -5,7 +5,6 @@ db_url = postgresql://user:pass@localhost/db ...@@ -5,7 +5,6 @@ db_url = postgresql://user:pass@localhost/db
#va_db_url = postgresql://user:pass@localhost/db #va_db_url = postgresql://user:pass@localhost/db
report_db_url = postgresql://user:pass@localhost/db report_db_url = postgresql://user:pass@localhost/db
pid_file = /home/sugiana/tmp/bphtb-report.pid pid_file = /home/sugiana/tmp/bphtb-report.pid
log_file = /home/sugiana/log/bphtb-report.log
[formatter_generic] [formatter_generic]
format = %(asctime)s %(levelname)s %(name)s %(message)s format = %(asctime)s %(levelname)s %(name)s %(message)s
......
import sys
from argparse import ArgumentParser
from configparser import ConfigParser
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from opensipkd.webr.models.default import Payment
from payment_report.models import Webr
pars = ArgumentParser()
pars.add_argument('conf')
option = pars.parse_args(sys.argv[1:])
conf = ConfigParser()
conf.read(option.conf)
cf = dict(conf.items('main'))
engine_prod = create_engine(cf['db_url'])
engine_rpt = create_engine(cf['report_db_url'])
factory_prod = sessionmaker(bind=engine_prod)
factory_rpt = sessionmaker(bind=engine_rpt)
db_session_prod = factory_prod()
db_session_rpt = factory_rpt()
q_rpt = db_session_rpt.query(Webr)
q_rpt = q_rpt.filter(Webr.id >= 17739)
for rpt in q_rpt.order_by(Webr.id):
q_prod = db_session_prod.query(Payment).filter_by(id=rpt.id)
prod = q_prod.first()
if prod:
continue
print(f'webr.ar_payment.id = {rpt.id} sudah tidak ada')
rpt.pokok = rpt.denda = rpt.jml_bayar = 0
db_session_rpt.add(rpt)
db_session_rpt.flush()
db_session_rpt.commit()
...@@ -6,7 +6,6 @@ db_url = postgresql://user:pass@localhost/db ...@@ -6,7 +6,6 @@ db_url = postgresql://user:pass@localhost/db
#va_db_url = postgresql://user:pass@localhost/db #va_db_url = postgresql://user:pass@localhost/db
report_db_url = postgresql://user:pass@localhost/db report_db_url = postgresql://user:pass@localhost/db
pid_file = /home/sugiana/tmp/pad-report.pid pid_file = /home/sugiana/tmp/pad-report.pid
log_file = /home/sugiana/log/pad-report.log
[formatter_generic] [formatter_generic]
format = %(asctime)s %(levelname)s %(name)s %(message)s format = %(asctime)s %(levelname)s %(name)s %(message)s
......
...@@ -22,6 +22,10 @@ from sqlalchemy import ( ...@@ -22,6 +22,10 @@ from sqlalchemy import (
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
import transaction import transaction
from zope.sqlalchemy import register from zope.sqlalchemy import register
from opensipkd.waktu import (
as_timezone,
create_now,
)
from opensipkd.views.models import Conf as BaseConf from opensipkd.views.models import Conf as BaseConf
from opensipkd.iso8583.bjb.scripts.common import get_module_object from opensipkd.iso8583.bjb.scripts.common import get_module_object
from .models import Base from .models import Base
...@@ -387,7 +391,11 @@ class BaseApp: ...@@ -387,7 +391,11 @@ class BaseApp:
if 'tgl_akhir' in self.conf: if 'tgl_akhir' in self.conf:
self.tgl_akhir = self.conf['tgl_akhir'] self.tgl_akhir = self.conf['tgl_akhir']
else: else:
self.tgl_akhir = date.today() self.tgl_akhir = create_now()
self.tgl_awal = as_timezone(self.tgl_awal)
self.tgl_akhir = as_timezone(self.tgl_akhir)
print(self.tgl_awal)
print(self.tgl_akhir)
def run(self): def run(self):
self.last_pay = self.last = None self.last_pay = self.last = None
......
...@@ -109,8 +109,8 @@ class App(BaseApp): ...@@ -109,8 +109,8 @@ class App(BaseApp):
stan = iso and iso.bit_011 or None stan = iso and iso.bit_011 or None
ntb = pay.ntb and pay.ntb.strip() or None ntb = pay.ntb and pay.ntb.strip() or None
return dict( return dict(
id=pay.id, stan=stan, ntb=ntb, tgl=pay.created.date(), id=pay.id, stan=stan, ntb=ntb, tgl=pay.tgl_bayar.date(),
jam=pay.created.time(), nomor_bayar=self.invoice_id, jam=pay.tgl_bayar.time(), nomor_bayar=self.invoice_id,
nama_wp=inv.subjek_nama, pokok=inv.jumlah-inv.bunga, nama_wp=inv.subjek_nama, pokok=inv.jumlah-inv.bunga,
denda=pay.bunga, jml_bayar=pay.bayar, channel_id=channel_id, denda=pay.bunga, jml_bayar=pay.bayar, channel_id=channel_id,
channel_name=channel_name, status=pay.status, channel_name=channel_name, status=pay.status,
......
...@@ -4,7 +4,6 @@ db_url = postgresql://user:pass@localhost/db ...@@ -4,7 +4,6 @@ db_url = postgresql://user:pass@localhost/db
#va_db_url = postgresql://user:pass@localhost/db #va_db_url = postgresql://user:pass@localhost/db
report_db_url = postgresql://user:pass@localhost/db report_db_url = postgresql://user:pass@localhost/db
pid_file = /home/sugiana/tmp/webr-report.pid pid_file = /home/sugiana/tmp/webr-report.pid
log_file = /home/sugiana/log/webr-report.log
[formatter_generic] [formatter_generic]
format = %(asctime)s %(levelname)s %(name)s %(message)s format = %(asctime)s %(levelname)s %(name)s %(message)s
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!