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 c36625b1
authored
Aug 25, 2017
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
webr
1 parent
f8dbc008
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
32 deletions
conf.py
import-webr.py
models_default.py
models_webr.py
conf.py
View file @
c36625b
...
...
@@ -9,3 +9,5 @@ sipkd_url = 'mssql+pyodbc:///?odbc_connect={}'.format(quoted)
sipkd_url_master
=
sipkd_url
#pyodbc:///?odbc_connect=DRIVER%%3D%%7BFreeTDS%%7D%%3BServer%%3D192.168.56.1%%3BDatabase%%3DV%%40LID49V6_2015%%3BUID%%3Dsa%%3BPWD%%3Da%%3BPort%%3D1433%%3BTDS_Version%%3D8.0"
eis_url
=
"postgresql://aagusti:a@192.168.56.1/os"
webr_url
=
"postgresql://aagusti:a@192.168.56.1/webr"
import-webr.py
View file @
c36625b
from
models_webr
import
Realisasi
,
Base
as
WebrBase
,
DBSession
as
WebrDBSession
from
models_eis
import
(
ArPayment
as
EisArPayment
,
ByPayment
as
EisByPayment
,
Rekening
as
EisRekening
,
EisBase
,
EisDBSession
)
from
conf
import
webr_url
as
url
from
sqlalchemy
import
create_engine
,
literal_column
,
func
from
datetime
import
datetime
from
datetime
import
date
...
...
@@ -12,8 +6,15 @@ try:
except
:
from
urllib.parse
import
quote_plus
,
quote
from
models_webr
import
(
A
rInvoice
as
Invoice
,
Ar
Sspd
as
Realisasi
,
from
models_webr
import
(
A
RInvoice
as
Invoice
,
AR
Sspd
as
Realisasi
,
WebrDBSession
as
DBSession
)
from
models_eis
import
(
ArPayment
as
EisArPayment
,
ByPayment
as
EisByPayment
,
Rekening
as
EisRekening
,
EisBase
,
EisDBSession
)
from
conf
import
webr_url
as
url
now
=
datetime
.
now
()
tanggal
=
now
.
date
()
...
...
@@ -88,34 +89,36 @@ def validate_parent(tabel, departemen_kd, departemen_nm, rekening, tanggal):
def
import_ar
(
all
=
False
):
query
=
DBSession
.
query
(
Invoice
.
unit_kode
,
Invoice
.
unit_nama
,
Invoice
.
rek_kode
,
Invoice
.
rek_nama
,
Realisasi
.
tgl_bayar
,
func
.
sum
(
Realisasi
.
bunga
)
.
label
(
'bunga'
),
func
.
sum
(
Realisasi
.
bayar
)
.
label
(
'bayar'
),
)
.
\
join
(
Invoice
,
(
Realisasi
.
arinvoice_id
=
Invoice
.
id
))
Invoice
.
rek_kode
,
Invoice
.
rek_nama
,
func
.
to_char
(
Realisasi
.
tgl_bayar
,
'YYYY-MM-DD'
)
.
label
(
'tgl_bayar'
),
func
.
sum
(
Realisasi
.
bunga
)
.
label
(
'bunga'
),
func
.
sum
(
Realisasi
.
bayar
)
.
label
(
'bayar'
),)
.
\
join
(
Realisasi
,
(
Realisasi
.
arinvoice_id
==
Invoice
.
id
))
.
\
group_by
(
Invoice
.
unit_kode
,
Invoice
.
unit_nama
,
Invoice
.
rek_kode
,
Invoice
.
rek_nama
,
func
.
to_char
(
Realisasi
.
tgl_bayar
,
'YYYY-MM-DD'
))
if
not
all
:
query
=
query
.
filter
(
Realisasi
.
tgl_bayar
==
tanggal
)
query
=
query
.
filter
(
func
.
to_char
(
Realisasi
.
tgl_bayar
,
'YYYY-MM-DD'
)
==
tanggal
.
strftime
(
'
%
Y-
%
m-
%
d'
)
)
for
row
in
query
.
all
():
eis
=
EisDBSession
.
query
(
EisArPayment
)
.
\
filter_by
(
tahun
=
str
(
tahun
),
kode
=
row
.
rek_kode
.
strip
(),
departemen_kd
=
row
.
unit_kode
.
strip
(),
tanggal
=
row
.
t
anggal
.
date
()
,
tanggal
=
row
.
t
gl_bayar
,
)
.
first
()
if
not
eis
:
eis
=
EisArPayment
()
eis
.
tahun
=
str
(
row
.
tahun
)
eis
.
tahun
=
str
(
tahun
)
eis
.
kode
=
row
.
rek_kode
.
strip
()
eis
.
departemen_kd
=
row
.
unit_kode
.
strip
()
eis
.
tanggal
=
row
.
t
anggal
.
date
()
eis
.
level_id
=
row
.
kd_rekening
.
count
(
'.'
)
eis
.
tanggal
=
row
.
t
gl_bayar
eis
.
level_id
=
row
.
rek_kode
.
count
(
'.'
)
eis
.
nama
=
row
.
rek_nama
.
strip
()
eis
.
departemen_nm
=
row
.
unit_nama
.
strip
()
eis
.
jumlah
=
row
.
bayar
-
row
.
dend
a
eis
.
jumlah
=
row
.
bayar
-
row
.
bung
a
EisDBSession
.
add
(
eis
)
if
row
.
dend
a
:
if
row
.
bung
a
:
pass
# TODO
# eis = EisDBSession.query(EisArPayment).\
...
...
models_default.py
View file @
c36625b
...
...
@@ -12,7 +12,13 @@ from sqlalchemy import (
Index
,
create_engine
,
)
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.orm
import
(
scoped_session
,
sessionmaker
,
relationship
,
backref
)
Base
=
declarative_base
()
DBSession
=
scoped_session
(
sessionmaker
())
...
...
models_webr.py
View file @
c36625b
...
...
@@ -7,6 +7,8 @@ from sqlalchemy import (
Text
,
DateTime
,
String
,
Float
,
Date
,
UniqueConstraint
,
ForeignKey
,
Index
,
...
...
@@ -14,7 +16,6 @@ from sqlalchemy import (
)
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.orm.exc
import
NoResultFound
from
sqlalchemy.orm
import
(
scoped_session
,
sessionmaker
,
...
...
@@ -26,11 +27,11 @@ from conf import webr_url as url
WebrBase
=
declarative_base
()
WebrDBSession
=
scoped_session
(
sessionmaker
())
engine_webr
=
create_engine
(
url
,
echo
=
False
)
WebrDBSession
.
configure
(
bind
=
engine
)
WebrBase
.
metadata
.
bind
=
engine
WebrDBSession
.
configure
(
bind
=
engine
_webr
)
WebrBase
.
metadata
.
bind
=
engine
_webr
from
models_default
import
(
DefaultModel
as
BaseDefaultModel
,
NamaModel
)
NamaModel
,
CommonModel
)
class
DefaultModel
(
BaseDefaultModel
):
@classmethod
...
...
@@ -96,15 +97,10 @@ class ARInvoice(CommonModel, WebrBase):
update_uid
=
Column
(
Integer
)
create_date
=
Column
(
DateTime
(
timezone
=
True
))
update_date
=
Column
(
DateTime
(
timezone
=
True
))
subjekpajaks
=
relationship
(
"SubjekPajak"
,
backref
=
backref
(
'arinvoices'
))
objekpajaks
=
relationship
(
"ObjekPajak"
,
backref
=
backref
(
'arinvoices'
))
wilayahs
=
relationship
(
"Wilayah"
,
backref
=
backref
(
'arinvoices'
))
units
=
relationship
(
"Unit"
,
backref
=
backref
(
'arinvoices'
))
UniqueConstraint
(
tahun_id
,
unit_id
,
no_id
,
name
=
'arinvoice_uq'
)
class
ARSspd
(
CommonModel
,
WebrBase
):
class
ARSspd
(
CommonModel
,
WebrBase
):
__tablename__
=
'arsspds'
id
=
Column
(
Integer
,
primary_key
=
True
)
tahun_id
=
Column
(
Integer
)
...
...
@@ -124,7 +120,6 @@ class ARInvoice(CommonModel, WebrBase):
bank_id
=
Column
(
Integer
)
channel_id
=
Column
(
Integer
)
arinvoices
=
relationship
(
"ARInvoice"
,
backref
=
backref
(
'arsspds'
))
units
=
relationship
(
"Unit"
,
backref
=
backref
(
'arsspds'
))
UniqueConstraint
(
arinvoice_id
,
pembayaran_ke
,
name
=
'arsspd_uq'
)
UniqueConstraint
(
tahun_id
,
unit_id
,
name
=
'arsspd_no_uq'
)
\ No newline at end of file
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