payment_report.py
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
from datetime import (
datetime,
date,
)
from argparse import ArgumentParser
from configparser import ConfigParser
from pprint import pprint
from cirebon_kota_payment_report import WebClient
from .logger import setup_logging
def main(argv=sys.argv[1:]):
pajak = ['pbb', 'bphtb', 'pad']
tgl = date.today().strftime('%d-%m-%Y')
help_tgl = f'default {tgl}'
pars = ArgumentParser()
pars.add_argument('conf')
pars.add_argument('pajak', choices=pajak)
pars.add_argument('--tgl', default=tgl, help=help_tgl)
option = pars.parse_args(argv)
setup_logging(option.conf)
t = option.tgl.split(',')
tgl_awal = t[0]
if t[1:]:
tgl_akhir = t[1]
else:
tgl_akhir = tgl_awal
tgl_awal = datetime.strptime(tgl_awal, '%d-%m-%Y')
tgl_akhir = datetime.strptime(tgl_akhir, '%d-%m-%Y')
tgl_awal = tgl_awal.date()
tgl_akhir = tgl_akhir.date()
conf = ConfigParser()
conf.read(option.conf)
cf = dict(conf.items('main'))
client = WebClient()
r = client.login(cf['username'], cf['password'])
r = client.send(option.pajak, tgl_awal, tgl_akhir)
pprint(r)
count = len(r)
print(f'Ada {count} transaksi.')