Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Project
/
import-sipkd-eis
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 34588be4
authored
Aug 25, 2017
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
pap
1 parent
78f5037a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
57 deletions
conf.py
import-pap.py
import-webr.py
conf.py
View file @
34588be
...
...
@@ -11,3 +11,5 @@ sipkd_url_master = sipkd_url
eis_url
=
"postgresql://aagusti:a@192.168.56.1/os"
webr_url
=
"postgresql://aagusti:a@192.168.56.1/webr"
pap_url
=
"informix://user:pass@db"
\ No newline at end of file
import-pap.py
View file @
34588be
from
models_sipkd
import
Realisasi
,
Base
,
DBSession
#kpusat19_svr
#database dbdapja
#user samsatjb
#pass samsatjb onsoctcp 1526
#v_rtimepap
#tg_pros_bayar
#pap
#den_pajak
#jumlah
#v_rtime
#vsts yesterday
#tg_pros_bayar
#pkb
#bbnkb1
#bbnkb2
#den_pajak
#jumlah
from
models_eis
import
(
ApPayment
as
EisApPayment
,
ByPayment
as
EisByPayment
,
Rekening
as
EisRekening
,
EisBase
,
EisDBSession
)
from
conf
import
sipkd
_url
from
conf
import
pap
_url
from
sqlalchemy
import
create_engine
,
literal_column
,
func
from
datetime
import
datetime
from
datetime
import
date
...
...
@@ -12,20 +30,29 @@ try:
except
:
from
urllib.parse
import
quote_plus
,
quote
from
conf
import
pap_url
as
url
data
=
url
.
split
(
'@'
)
db_name
=
data
[
1
]
data
=
data
[
0
]
.
split
(
'//'
)
data
=
data
[
1
]
.
split
(
':'
)
db_user
=
data
[
0
]
db_pass
=
data
[
1
]
engine
=
OtherEngine
(
db_name
,
db_user
,
db_pass
)
engine
=
create_engine
(
sipkd_url
)
DBSession
.
configure
(
bind
=
engine
)
Base
.
metadata
.
bind
=
engine
Base
.
metadata
.
create_all
(
engine
)
now
=
datetime
.
now
()
tanggal
=
now
.
date
()
tahun
=
now
.
strftime
(
'
%
Y'
)
def
calculate
(
tabel
,
all
=
Fals
e
):
def
calculate
(
tabel
,
all
=
None
,
kode
=
Non
e
):
query
=
EisDBSession
.
query
(
tabel
)
.
filter_by
(
tahun
=
str
(
tahun
))
.
\
order_by
(
tabel
.
departemen_kd
,
tabel
.
tanggal
,
tabel
.
kode
.
desc
())
if
not
all
:
query
=
query
.
filter_by
(
tanggal
=
tanggal
)
if
kode
:
query
=
query
.
filter_by
(
kode
=
kode
)
old_level
=
0
levels
=
{}
...
...
@@ -72,9 +99,11 @@ def validate_parent(tabel, departemen_kd, departemen_nm, rekening, tanggal):
if
not
row
.
kode
:
continue
induk
=
EisDBSession
.
query
(
tabel
)
.
\
filter_by
(
tahun
=
str
(
row
.
tahun
),
filter_by
(
tahun
=
str
(
row
.
tahun
),
kode
=
row
.
kode
.
strip
(),
departemen_kd
=
departemen_kd
.
strip
(),
tanggal
=
tanggal
,
)
.
first
()
if
not
induk
:
induk
=
tabel
()
...
...
@@ -88,63 +117,74 @@ def validate_parent(tabel, departemen_kd, departemen_nm, rekening, tanggal):
EisDBSession
.
add
(
induk
)
EisDBSession
.
flush
()
def
import_ap
(
all
=
False
):
query
=
DBSession
.
query
(
Realisasi
)
if
not
all
:
query
=
query
.
filter_by
(
tanggal
=
tanggal
)
query
=
query
.
filter
(
Realisasi
.
kd_rekening
.
like
(
'5.
%
'
))
for
row
in
query
.
all
():
eis
=
EisDBSession
.
query
(
EisApPayment
)
.
\
filter_by
(
tahun
=
str
(
row
.
tahun
),
kode
=
row
.
kd_rekening
.
strip
(),
departemen_kd
=
row
.
kd_opd
.
strip
(),
def
insert_data
(
row
,
kode
,
nama
,
dep_kode
,
dep_nama
):
# TODO
eis
=
EisDBSession
.
query
(
EisArPayment
)
.
\
filter_by
(
tahun
=
str
(
tahun
),
kode
=
kode
,
departemen_kd
=
dep_kode
,
tanggal
=
row
.
tanggal
,
)
.
first
()
if
not
eis
:
eis
=
EisAp
Payment
()
eis
.
tahun
=
str
(
row
.
tahun
)
eis
.
kode
=
row
.
kd_rekening
.
strip
()
eis
.
departemen_kd
=
row
.
kd_opd
.
strip
()
eis
.
tanggal
=
row
.
tanggal
eis
.
level_id
=
row
.
kd_rekening
.
count
(
'.'
)
eis
.
nama
=
row
.
nm_rekening
.
strip
()
eis
.
departemen_nm
=
row
.
nm_opd
.
strip
()
eis
.
jumlah
=
row
.
realisasi
eis
=
EisAr
Payment
()
eis
.
tahun
=
str
(
tahun
)
eis
.
kode
=
kode
eis
.
departemen_kd
=
dep_kode
eis
.
tanggal
=
tanggal
eis
.
level_id
=
kode
.
count
(
'.'
)
eis
.
nama
=
nama
eis
.
departemen_nm
=
dep_nama
eis
.
jumlah
=
row
.
denda
EisDBSession
.
add
(
eis
)
EisDBSession
.
flush
()
validate_parent
(
EisApPayment
,
eis
.
departemen_kd
,
eis
.
departemen_nm
,
eis
.
kode
,
eis
.
tanggal
)
EisDBSession
.
commit
()
validate_parent
(
EisArPayment
,
eis
.
departemen_kd
,
eis
.
departemen_nm
,
eis
.
kode
,
eis
.
tanggal
)
def
import_by
(
all
=
False
):
query
=
DBSession
.
query
(
Realisasi
)
def
import_pap
(
all
=
False
):
sql
=
"SELECT tg_pros_bayar as tanggal, pap as pokok, den_pajak as denda FROM v_rtimepap "
\
"WHERE TO_CHAR(tg_pros_bayar, 'YYYY') = '{tahun}' {where} "
\
"ORDER BY tg_pros_bayar"
if
not
all
:
query
=
query
.
filter_by
(
tanggal
=
tanggal
)
sql
=
sql
.
format
(
tahun
=
tahun
,
where
=
''
)
else
:
sql
=
sql
.
format
(
tahun
=
tahun
,
where
=
" tg_pros_bayar = '{tanggal}'"
.
\
format
(
tanggal
=
tanggal
.
strftime
(
'
%
d-
%
m-
%
Y'
)),)
for
row
in
query
.
filter
(
Realisasi
.
kd_rekening
.
like
(
'6.
%
'
))
.
all
():
eis
=
EisDBSession
.
query
(
EisByPayment
)
.
\
filter_by
(
tahun
=
str
(
row
.
tahun
),
kode
=
row
.
kd_rekening
.
strip
(),
departemen_kd
=
row
.
kd_opd
.
strip
(),
tanggal
=
tanggal
,
rows
=
engine
.
fetchall
(
sql
)
rek_kode
=
'4.1.1.06.01.'
rek_nama
=
'PAJAK AIR PERMUKAAN'
denda_kode
=
'4.1.4.07.03.'
denda_nama
=
'DENDA PAJAK AIR PERMUKAAN'
dep_kode
=
'3.03.02.'
dep_nama
=
'BADAN PENDAPATAN DAERAH'
for
row
in
query
.
all
():
eis
=
EisDBSession
.
query
(
EisApPayment
)
.
\
filter_by
(
tahun
=
str
(
tahun
),
kode
=
rek_kode
,
departemen_kd
=
dep_kode
,
tanggal
=
row
.
tanggal
,
)
.
first
()
if
not
eis
:
eis
=
Eis
By
Payment
()
eis
.
tahun
=
str
(
row
.
tahun
)
eis
.
kode
=
r
ow
.
kd_rekening
.
strip
()
eis
.
departemen_kd
=
row
.
kd_opd
.
strip
()
eis
.
tanggal
=
tanggal
eis
.
level_id
=
r
ow
.
kd_rekening
.
count
(
'.'
)
eis
.
nama
=
r
ow
.
nm_rekening
.
strip
()
eis
.
departemen_nm
=
row
.
nm_opd
.
strip
()
eis
.
jumlah
=
row
.
realisasi
eis
=
Eis
Ap
Payment
()
eis
.
tahun
=
str
(
tahun
)
eis
.
kode
=
r
ek_kode
eis
.
departemen_kd
=
dep_kode
eis
.
tanggal
=
row
.
tanggal
eis
.
level_id
=
r
ek_kode
.
count
(
'.'
)
eis
.
nama
=
r
ek_nama
eis
.
departemen_nm
=
dep_nama
eis
.
jumlah
=
row
.
pokok
EisDBSession
.
add
(
eis
)
EisDBSession
.
flush
()
validate_parent
(
EisByPayment
,
eis
.
departemen_kd
,
eis
.
departemen_nm
,
eis
.
kode
)
validate_parent
(
EisApPayment
,
eis
.
departemen_kd
,
eis
.
departemen_nm
,
eis
.
kode
,
eis
.
tanggal
)
if
row
.
denda
:
insert_data
(
row
,
denda_kode
,
denda_nama
,
dep_kode
,
dep_nama
)
EisDBSession
.
commit
()
EisDBSession
.
commit
()
#import_ap(True)
import_by
(
True
)
calculate
(
EisApPayment
,
True
)
calculate
(
EisByPayment
,
True
)
import_pap
(
True
)
calculate
(
EisArPayment
,
True
)
import-webr.py
View file @
34588be
...
...
@@ -21,12 +21,15 @@ now = datetime.now()
tanggal
=
now
.
date
()
tahun
=
now
.
strftime
(
'
%
Y'
)
def
calculate
(
tabel
,
all
=
Fals
e
):
def
calculate
(
tabel
,
all
=
None
,
kode
=
Non
e
):
query
=
EisDBSession
.
query
(
tabel
)
.
filter_by
(
tahun
=
str
(
tahun
))
.
\
order_by
(
tabel
.
departemen_kd
,
tabel
.
tanggal
,
tabel
.
kode
.
desc
())
if
not
all
:
query
=
query
.
filter_by
(
tanggal
=
tanggal
)
if
kode
:
query
=
query
.
filter_by
(
kode
=
kode
)
old_level
=
0
levels
=
{}
jumlahs
=
{}
...
...
@@ -134,6 +137,8 @@ def import_ar(all=False):
eis
.
departemen_nm
=
unit_nm
eis
.
jumlah
=
row
.
bayar
-
row
.
bunga
EisDBSession
.
add
(
eis
)
validate_parent
(
EisApPayment
,
eis
.
departemen_kd
,
eis
.
departemen_nm
,
eis
.
kode
,
eis
.
tanggal
)
EisDBSession
.
flush
()
if
row
.
bunga
and
row
.
denda_kode
:
# TODO
eis
=
EisDBSession
.
query
(
EisArPayment
)
.
\
...
...
@@ -153,10 +158,9 @@ def import_ar(all=False):
eis
.
departemen_nm
=
row
.
unit_nama
.
strip
()
eis
.
jumlah
=
row
.
bunga
EisDBSession
.
add
(
eis
)
EisDBSession
.
flush
()
validate_parent
(
EisArPayment
,
eis
.
departemen_kd
,
eis
.
departemen_nm
,
eis
.
kode
,
eis
.
tanggal
)
EisDBSession
.
commit
()
import_
ar
(
True
)
import_
pap
(
True
)
calculate
(
EisArPayment
,
True
)
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