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 9e9fd199
authored
Aug 25, 2017
by
aagusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
production
1 parent
79bd0e90
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
258 additions
and
8 deletions
import-sipkd-anggaran.py
import-sipkd-master.py
import-sipkd.py
models_eis.py
models_sipkd.py
models_sipkd_master.py
import-sipkd-anggaran.py
View file @
9e9fd19
from
sipkd_models
import
Anggaran
,
Realisasi
,
Base
,
DBSession
from
models_sipkd
import
Anggaran
,
Realisasi
,
Base
,
DBSession
from
eis_model
s
import
(
Anggaran
as
EisAnggaran
,
ApPayment
as
EisApPayment
,
from
models_ei
s
import
(
Anggaran
as
EisAnggaran
,
ApPayment
as
EisApPayment
,
ArPayment
as
EisArPayment
,
ByPayment
as
EisByPayment
,
ArPayment
as
EisArPayment
,
ByPayment
as
EisByPayment
,
Rekening
as
EisRekening
,
Rekening
as
EisRekening
,
EisBase
,
EisDBSession
)
EisBase
,
EisDBSession
)
...
...
import-sipkd-master.py
View file @
9e9fd19
from
sipkd_master_models
import
RekPendapatan
,
RekBelanja
,
RekBiaya
,
SipkdDBSession
,
SipkdBase
from
models_sipkd_master
import
RekPendapatan
,
RekBelanja
,
RekBiaya
,
SipkdDBSession
,
SipkdBase
from
eis_model
s
import
Rekening
as
EisRekening
,
EisBase
,
EisDBSession
from
models_ei
s
import
Rekening
as
EisRekening
,
EisBase
,
EisDBSession
from
conf
import
sipkd_url
,
sipkd_url_master
from
conf
import
sipkd_url
,
sipkd_url_master
from
sqlalchemy
import
create_engine
from
sqlalchemy
import
create_engine
...
@@ -35,4 +35,4 @@ def import_rekening(tabel):
...
@@ -35,4 +35,4 @@ def import_rekening(tabel):
import_rekening
(
RekPendapatan
)
import_rekening
(
RekPendapatan
)
import_rekening
(
RekBelanja
)
import_rekening
(
RekBelanja
)
import_rekening
(
RekBiaya
)
import_rekening
(
RekBiaya
)
\ No newline at end of file
\ No newline at end of file
import-sipkd.py
View file @
9e9fd19
from
sipkd_models
import
Realisasi
,
Base
,
DBSession
from
models_sipkd
import
Realisasi
,
Base
,
DBSession
from
eis_model
s
import
(
ApPayment
as
EisApPayment
,
from
models_ei
s
import
(
ApPayment
as
EisApPayment
,
ByPayment
as
EisByPayment
,
ByPayment
as
EisByPayment
,
Rekening
as
EisRekening
,
Rekening
as
EisRekening
,
EisBase
,
EisDBSession
)
EisBase
,
EisDBSession
)
...
@@ -147,4 +147,4 @@ EisDBSession.commit()
...
@@ -147,4 +147,4 @@ EisDBSession.commit()
#import_ap(True)
#import_ap(True)
import_by
(
True
)
import_by
(
True
)
calculate
(
EisApPayment
,
True
)
calculate
(
EisApPayment
,
True
)
calculate
(
EisByPayment
,
True
)
\ No newline at end of file
\ No newline at end of file
calculate
(
EisByPayment
,
True
)
models_eis.py
0 → 100644
View file @
9e9fd19
from
datetime
import
datetime
from
sqlalchemy
import
(
Column
,
Integer
,
BigInteger
,
SmallInteger
,
Text
,
DateTime
,
String
,
UniqueConstraint
,
ForeignKey
,
Index
,
create_engine
,
)
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.orm.exc
import
NoResultFound
from
sqlalchemy.orm
import
(
scoped_session
,
sessionmaker
,
relationship
,
backref
)
from
conf
import
eis_url
EisBase
=
declarative_base
()
EisDBSession
=
scoped_session
(
sessionmaker
())
engine
=
create_engine
(
eis_url
,
echo
=
False
)
EisDBSession
.
configure
(
bind
=
engine
)
EisBase
.
metadata
.
bind
=
engine
TABLE_ARGS
=
{
'extend_existing'
:
True
,
'schema'
:
'eis'
}
class
CommonModel
(
object
):
def
to_dict
(
self
):
# Elixir like
values
=
{}
for
column
in
self
.
__table__
.
columns
:
values
[
column
.
name
]
=
getattr
(
self
,
column
.
name
)
return
values
def
from_dict
(
self
,
values
):
for
column
in
self
.
__table__
.
columns
:
if
column
.
name
in
values
:
setattr
(
self
,
column
.
name
,
values
[
column
.
name
])
def
as_timezone
(
self
,
fieldname
):
date_
=
getattr
(
self
,
fieldname
)
return
date_
and
as_timezone
(
date_
)
or
None
class
DefaultModel
(
CommonModel
):
id
=
Column
(
Integer
,
primary_key
=
True
)
@classmethod
def
query
(
cls
):
return
EisDBSession
.
query
(
cls
)
@classmethod
def
query_id
(
cls
,
id
):
return
cls
.
query
()
.
filter_by
(
id
=
id
)
@classmethod
def
delete
(
cls
,
id
):
cls
.
query_id
(
id
)
.
delete
()
@classmethod
def
count
(
cls
):
return
EisDBSession
.
query
(
func
.
count
(
'id'
))
.
scalar
()
class
KodeModel
(
DefaultModel
):
kode
=
Column
(
String
(
32
))
status
=
Column
(
SmallInteger
,
nullable
=
False
,
default
=
0
)
created
=
Column
(
DateTime
,
nullable
=
True
,
default
=
datetime
.
utcnow
)
updated
=
Column
(
DateTime
,
nullable
=
True
)
create_uid
=
Column
(
Integer
,
nullable
=
True
,
default
=
1
)
update_uid
=
Column
(
Integer
,
nullable
=
True
)
@classmethod
def
query_kode
(
cls
,
kode
):
return
cls
.
query
()
.
filter_by
(
kode
=
kode
)
@classmethod
def
get_active
(
cls
):
return
cls
.
query
()
.
filter_by
(
status
=
1
)
.
all
()
class
NamaModel
(
KodeModel
):
nama
=
Column
(
String
(
128
))
@classmethod
def
query_nama
(
cls
,
nama
):
return
cls
.
query
()
.
filter_by
(
nama
=
nama
)
class
Anggaran
(
NamaModel
,
EisBase
):
__tablename__
=
'sipkd_anggaran'
tahun
=
Column
(
String
(
4
))
departemen_kd
=
Column
(
String
(
16
))
departemen_nm
=
Column
(
String
(
255
))
jumlah
=
Column
(
BigInteger
)
murni
=
Column
(
BigInteger
)
perubahan
=
Column
(
BigInteger
)
level_id
=
Column
(
Integer
)
__table_args__
=
(
UniqueConstraint
(
'tahun'
,
'kode'
,
'departemen_kd'
),
TABLE_ARGS
)
class
ArPayment
(
NamaModel
,
EisBase
):
__tablename__
=
'sipkd_ar_payment'
tanggal
=
Column
(
DateTime
(
timezone
=
False
))
departemen_kd
=
Column
(
String
(
16
))
departemen_nm
=
Column
(
String
(
255
))
jumlah
=
Column
(
BigInteger
)
level_id
=
Column
(
Integer
)
tahun
=
Column
(
String
(
4
))
__table_args__
=
(
UniqueConstraint
(
'tanggal'
,
'departemen_kd'
,
'kode'
),
TABLE_ARGS
)
class
ApPayment
(
NamaModel
,
EisBase
):
__tablename__
=
'sipkd_ap_payment'
tanggal
=
Column
(
DateTime
(
timezone
=
False
))
tanggal
=
Column
(
DateTime
(
timezone
=
False
))
departemen_kd
=
Column
(
String
(
16
))
departemen_nm
=
Column
(
String
(
255
))
jumlah
=
Column
(
BigInteger
)
level_id
=
Column
(
Integer
)
tahun
=
Column
(
String
(
4
))
__table_args__
=
(
UniqueConstraint
(
'tanggal'
,
'departemen_kd'
,
'kode'
),
TABLE_ARGS
)
class
ByPayment
(
NamaModel
,
EisBase
):
__tablename__
=
'sipkd_pb_payment'
tanggal
=
Column
(
DateTime
(
timezone
=
False
))
tanggal
=
Column
(
DateTime
(
timezone
=
False
))
departemen_kd
=
Column
(
String
(
16
))
departemen_nm
=
Column
(
String
(
255
))
jumlah
=
Column
(
BigInteger
)
level_id
=
Column
(
Integer
)
tahun
=
Column
(
String
(
4
))
__table_args__
=
(
UniqueConstraint
(
'tanggal'
,
'departemen_kd'
,
'kode'
),
TABLE_ARGS
)
class
Rekening
(
NamaModel
,
EisBase
):
__tablename__
=
'sipkd_rekening'
tahun
=
Column
(
Integer
)
level_id
=
Column
(
SmallInteger
,
default
=
1
)
parent_id
=
Column
(
Integer
,
ForeignKey
(
'eis.sipkd_rekening.id'
),)
status
=
Column
(
SmallInteger
,
default
=
1
)
defsign
=
Column
(
SmallInteger
,
default
=
1
)
children
=
relationship
(
"Rekening"
,
backref
=
backref
(
'parent'
,
remote_side
=
'Rekening.id'
))
__table_args__
=
(
UniqueConstraint
(
'kode'
,
'tahun'
,
name
=
'rekening_uq'
),
#ForeignKeyConstraint(['parent_id'], ForeignKey('rekening.id')),
TABLE_ARGS
)
EisBase
.
metadata
.
create_all
(
engine
)
\ No newline at end of file
\ No newline at end of file
models_sipkd.py
0 → 100644
View file @
9e9fd19
from
datetime
import
datetime
from
sqlalchemy
import
(
Column
,
Integer
,
Text
,
DateTime
,
ForeignKey
,
UniqueConstraint
,
String
,
SmallInteger
,
BigInteger
)
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.orm.exc
import
NoResultFound
from
sqlalchemy.orm
import
(
scoped_session
,
sessionmaker
,
relationship
,
backref
)
Base
=
declarative_base
()
DBSession
=
scoped_session
(
sessionmaker
())
class
Anggaran
(
Base
):
__tablename__
=
"Tabel_Anggaran"
tahun
=
Column
(
String
(
4
),
primary_key
=
True
)
kd_opd
=
Column
(
String
(
32
),
primary_key
=
True
)
nm_opd
=
Column
(
String
(
254
))
kd_rekening
=
Column
(
String
(
32
),
primary_key
=
True
)
nm_rekening
=
Column
(
String
(
254
))
ang_murni
=
Column
(
BigInteger
)
ang_perubahan
=
Column
(
BigInteger
)
class
Realisasi
(
Base
):
__tablename__
=
"Tabel_Realisasi"
tahun
=
Column
(
String
(
4
),
primary_key
=
True
)
kd_opd
=
Column
(
String
(
32
),
primary_key
=
True
)
nm_opd
=
Column
(
String
(
254
))
kd_rekening
=
Column
(
String
(
32
),
primary_key
=
True
)
nm_rekening
=
Column
(
String
(
254
))
tanggal
=
Column
(
DateTime
(
timezone
=
False
),
primary_key
=
True
)
realisasi
=
Column
(
BigInteger
)
models_sipkd_master.py
0 → 100644
View file @
9e9fd19
from
datetime
import
datetime
from
sqlalchemy
import
(
Column
,
Integer
,
Text
,
DateTime
,
ForeignKey
,
UniqueConstraint
,
String
,
SmallInteger
,
BigInteger
)
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.orm.exc
import
NoResultFound
from
sqlalchemy.orm
import
(
scoped_session
,
sessionmaker
,
relationship
,
backref
)
TABLE_ARGS
=
{
'extend_existing'
:
True
,
#'schema':'sipkd'
}
SipkdBase
=
declarative_base
()
SipkdDBSession
=
scoped_session
(
sessionmaker
())
class
RekBiaya
(
SipkdBase
):
__tablename__
=
'matangb'
mtgkey
=
Column
(
String
(
10
),
primary_key
=
True
)
kdper
=
Column
(
String
(
30
))
nmper
=
Column
(
String
(
200
))
mtglevel
=
Column
(
String
(
2
))
kdkhusus
=
Column
(
String
(
1
))
type
=
Column
(
String
(
2
))
__table_args__
=
TABLE_ARGS
class
RekPendapatan
(
SipkdBase
):
__tablename__
=
'matangd'
mtgkey
=
Column
(
String
(
10
),
primary_key
=
True
)
kdper
=
Column
(
String
(
30
))
nmper
=
Column
(
String
(
200
))
mtglevel
=
Column
(
String
(
2
))
kdkhusus
=
Column
(
String
(
1
))
type
=
Column
(
String
(
2
))
__table_args__
=
TABLE_ARGS
class
RekBelanja
(
SipkdBase
):
__tablename__
=
'matangr'
mtgkey
=
Column
(
String
(
10
),
primary_key
=
True
)
kdper
=
Column
(
String
(
30
))
nmper
=
Column
(
String
(
200
))
mtglevel
=
Column
(
String
(
2
))
kdkhusus
=
Column
(
String
(
1
))
type
=
Column
(
String
(
2
))
__table_args__
=
TABLE_ARGS
\ No newline at end of file
\ 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