Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Owo Sugiana
/
linkaja-models
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 84a3bb67
authored
Oct 31, 2021
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Tambah tabel linkaja_pbb sebagai konfigurasi
1 parent
eebbf1c5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
1 deletions
.gitignore
CHANGES.txt
linkaja/__init__.py
linkaja/models.py
linkaja/scripts/data/pbb.csv
linkaja/scripts/init_db.py
.gitignore
View file @
84a3bb6
test*
dist
*egg-info
build
__pycache__
CHANGES.txt
View file @
84a3bb6
0.2 29-10-2021
--------------
- Penggunaan pkgutil agar fleksibel saat pip install -e
- Penambahan tabel linkaja_pbb sebagai pengganti konfigurasi untuk bit 60
ISO8583 BJB di file konfigurasi serta judul tagihan di tabel conf.
0.1.2 26-11-2020
----------------
- Field resp_mesg butuh 200 karakter sebagai batas maksimum dari LinkAja
...
...
linkaja/__init__.py
View file @
84a3bb6
__path__
=
__import__
(
'pkgutil'
)
.
extend_path
(
__path__
,
__name__
)
linkaja/models.py
View file @
84a3bb6
...
...
@@ -65,3 +65,14 @@ class Bank(Base):
conf_name
=
Column
(
String
(
16
),
nullable
=
False
)
request
=
Column
(
JSON
,
nullable
=
False
)
response
=
Column
(
JSON
)
class
Pbb
(
Base
):
__tablename__
=
'linkaja_pbb'
# Nilai untuk BJB bit 60
id
=
Column
(
String
(
4
),
primary_key
=
True
)
# Nama terminal request dari LinkAja
name
=
Column
(
String
(
64
),
nullable
=
False
,
unique
=
True
)
# Nama tagihan response ke LinkAja
display_name
=
Column
(
String
(
64
),
nullable
=
False
,
unique
=
True
)
prefix_nop
=
Column
(
String
(
4
),
nullable
=
False
)
linkaja/scripts/data/pbb.csv
0 → 100644
View file @
84a3bb6
display_name,name,prefix_nop,id
PBB Kabupaten Bekasi,pbb_kab_bekasi,3218,134
PBB Kabupaten Cianjur,pbb_kab_cianjur,3205,124
PBB Kabupaten Bandung,pbb_kab_bdg,3206,131
PBB Kabupaten Bandung Barat,pbb_kab_bdg_brt,3206,141
PBB Kabupaten Tangerang,pbb_kab_tangerang,3619,145
PBB Kota Bandung,pbb_kota_bdg,3273,135
PBB Kota Bekasi,pbb_kota_bekasi,3275,120
PBB Kota Bogor,pbb_kota_bogor,3271,123
PBB Kota Depok,pbb_kota_depok,3278,133
PBB Kota Kendari,pbb_kota_kendari,7471,1000
PBB Kota Serang,pbb_kota_serang,3604,144
PBB Kota Tangerang,pbb_kota_tangerang,3675,122
PBB Kota Tangerang Selatan,pbb_kota_tangsel,3676,142
linkaja/scripts/init_db.py
View file @
84a3bb6
import
sys
import
os
import
csv
from
configparser
import
ConfigParser
from
sqlalchemy
import
create_engine
from
..models
import
Base
from
sqlalchemy.orm
import
sessionmaker
import
transaction
from
zope.sqlalchemy
import
register
from
..models
import
(
Base
,
Pbb
,
)
my_registry
=
dict
()
def
get_file
(
filename
):
base_dir
=
os
.
path
.
split
(
__file__
)[
0
]
fullpath
=
os
.
path
.
join
(
base_dir
,
'data'
,
filename
)
return
open
(
fullpath
)
def
append_csv
(
table
,
filename
,
keys
):
db_session
=
my_registry
[
'db_session'
]
with
get_file
(
filename
)
as
f
:
reader
=
csv
.
DictReader
(
f
)
filter_
=
dict
()
for
cf
in
reader
:
for
key
in
keys
:
filter_
[
key
]
=
cf
[
key
]
q
=
db_session
.
query
(
table
)
.
filter_by
(
**
filter_
)
found
=
q
.
first
()
if
found
:
continue
row
=
table
()
for
fieldname
in
cf
:
val
=
cf
[
fieldname
]
if
not
val
:
continue
setattr
(
row
,
fieldname
,
val
)
db_session
.
add
(
row
)
def
main
(
argv
=
sys
.
argv
[
1
:]):
...
...
@@ -12,3 +50,8 @@ def main(argv=sys.argv[1:]):
engine
=
create_engine
(
db_url
)
engine
.
echo
=
True
Base
.
metadata
.
create_all
(
engine
)
session_factory
=
sessionmaker
(
bind
=
engine
)
my_registry
[
'db_session'
]
=
db_session
=
session_factory
()
register
(
db_session
)
with
transaction
.
manager
:
append_csv
(
Pbb
,
'pbb.csv'
,
[
'id'
])
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment