available_invoice.py
1.31 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
import sys
from configparser import ConfigParser
from argparse import ArgumentParser
from optparse import OptionParser
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
def get_option(argv):
default_count = 10
help_count = 'default {}'.format(default_count)
pars = ArgumentParser()
pars.add_argument('conf')
pars.add_argument('--tahun', type=int)
pars.add_argument('--belum-jatuh-tempo', action='store_true')
pars.add_argument('--lewat-jatuh-tempo', action='store_true')
pars.add_argument(
'--count', type=int, default=default_count, help=help_count)
return pars.parse_args(argv)
def main(argv=sys.argv):
option = get_option(argv[1:])
conf = ConfigParser()
conf.read(option.conf)
module_name = conf.get('main', 'module')
module = __import__('opensipkd.bphtb.' + module_name + '.services')
area_module = getattr(module.bphtb, module_name)
services_module = getattr(area_module, 'services')
AvailableInvoice = services_module.AvailableInvoice
db_url = conf.get('main', 'db_url')
persen_denda = conf.getfloat('main', 'persen_denda')
engine = create_engine(db_url)
session_factory = sessionmaker(bind=engine)
services_module.DBSession = session_factory()
a = AvailableInvoice(persen_denda, option)
a.show()