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 3734a84e
authored
Aug 25, 2017
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
grafik
1 parent
bcf95ccc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
179 additions
and
1 deletions
__init__.py
models_eis.py
proses-harian.py
__init__.py
View file @
3734a84
#
\ No newline at end of file
\ No newline at end of file
#package
models_eis.py
View file @
3734a84
...
@@ -116,4 +116,41 @@ class Opd(NamaModel, EisBase):
...
@@ -116,4 +116,41 @@ class Opd(NamaModel, EisBase):
)
)
EisBase
.
metadata
.
create_all
(
engine
)
EisBase
.
metadata
.
create_all
(
engine
)
class
Chart
(
NamaModel
,
EisBase
):
__tablename__
=
'charts'
chart_type
=
Column
(
String
(
16
))
label
=
Column
(
String
(
128
))
#digunakan jika chart membutuhkan label
devider
=
Column
(
BigInteger
,
default
=
1
)
status
=
Column
(
SmallInteger
,
default
=
0
)
__table_args__
=
(
UniqueConstraint
(
'kode'
),
TABLE_ARGS
)
class
ChartItem
(
NamaModel
,
EisBase
):
__tablename__
=
'chart_items'
value_1
=
Column
(
BigInteger
,
default
=
0
)
value_2
=
Column
(
BigInteger
,
default
=
0
)
value_3
=
Column
(
BigInteger
,
default
=
0
)
value_4
=
Column
(
BigInteger
,
default
=
0
)
value_5
=
Column
(
BigInteger
,
default
=
0
)
value_6
=
Column
(
BigInteger
,
default
=
0
)
value_7
=
Column
(
BigInteger
,
default
=
0
)
value_8
=
Column
(
BigInteger
,
default
=
0
)
value_9
=
Column
(
BigInteger
,
default
=
0
)
value10
=
Column
(
BigInteger
,
default
=
0
)
value11
=
Column
(
BigInteger
,
default
=
0
)
value12
=
Column
(
BigInteger
,
default
=
0
)
chart_id
=
Column
(
Integer
,
ForeignKey
(
'eis.charts.id'
))
source_type
=
Column
(
String
(
32
),
default
=
'realisasi'
)
rekening_kd
=
Column
(
String
(
128
))
color
=
Column
(
String
(
6
))
highlight
=
Column
(
String
(
6
))
is_sum
=
Column
(
SmallInteger
,
default
=
0
)
updated
=
Column
(
DateTime
)
created
=
Column
(
DateTime
)
create_uid
=
Column
(
Integer
)
update_uid
=
Column
(
Integer
)
chart
=
relationship
(
"Chart"
)
status
=
Column
(
SmallInteger
,
default
=
0
)
__table_args__
=
(
UniqueConstraint
(
'kode'
),
TABLE_ARGS
)
\ No newline at end of file
\ No newline at end of file
proses-harian.py
0 → 100644
View file @
3734a84
import
sys
import
transaction
from
sqlalchemy
import
(
engine_from_config
,
or_
)
from
sqlalchemy
import
func
from
pyramid.paster
import
(
get_appsettings
,
setup_logging
,)
from
opensipkd.models
import
DBSession
,
Base
from
opensipkd.eis.models
import
Chart
,
ChartItem
from
opensipkd.eis_sipkd.models
import
(
EisSipkdArPayment
as
SipkdArPayment
,
EisSipkdApPayment
as
SipkdApPayment
,)
from
datetime
import
datetime
now
=
datetime
.
now
()
tahun
=
now
.
strftime
(
'
%
Y'
)
print
(
'start'
)
def
process_pie
():
print
(
'PIE'
)
charts
=
DBSession
.
query
(
Chart
)
.
\
filter_by
(
status
=
1
,
chart_type
=
'pie'
)
for
chart
in
charts
.
all
():
chart_items
=
DBSession
.
query
(
ChartItem
)
.
\
filter
(
ChartItem
.
chart_id
==
chart
.
id
)
.
\
order_by
(
ChartItem
.
rekening_kd
,
ChartItem
.
source_type
)
for
chart_item
in
chart_items
.
all
():
rekening_kd
=
chart_item
.
rekening_kd
if
rekening_kd
[:
1
]
==
'4'
:
data_items
=
DBSession
.
query
(
func
.
sum
(
SipkdArPayment
.
jumlah
))
elif
rekening_kd
[:
1
]
==
'5'
:
data_items
=
DBSession
.
query
(
func
.
sum
(
SipkdApPayment
.
jumlah
))
data_items
=
data_items
.
filter_by
(
kode
=
rekening_kd
,
tahun
=
tahun
)
chart_item
.
value_1
=
data_items
.
scalar
()
or
0
DBSession
.
add
(
chart_item
)
DBSession
.
flush
()
def
process_barline
():
print
(
'BAR LINE'
)
charts
=
DBSession
.
query
(
Chart
)
.
\
filter
(
Chart
.
status
==
1
,
or_
(
Chart
.
chart_type
==
'bar'
,
Chart
.
chart_type
==
'line'
))
for
chart
in
charts
.
all
():
chart_items
=
DBSession
.
query
(
ChartItem
)
.
\
filter
(
ChartItem
.
chart_id
==
chart
.
id
)
.
\
order_by
(
ChartItem
.
rekening_kd
,
ChartItem
.
source_type
)
for
chart_item
in
chart_items
.
all
():
rekening_kd
=
chart_item
.
rekening_kd
if
not
rekening_kd
or
rekening_kd
==
'None'
:
continue
if
rekening_kd
[:
1
]
==
'4'
:
bulan
=
func
.
to_char
(
SipkdArPayment
.
tanggal
,
'MM'
)
data_items
=
DBSession
.
query
(
bulan
.
label
(
'bulan'
),
func
.
sum
(
SipkdArPayment
.
jumlah
)
.
label
(
'jumlah'
))
elif
rekening_kd
[:
1
]
==
'5'
:
bulan
=
func
.
to_char
(
SipkdArPayment
.
tanggal
,
'MM'
)
data_items
=
DBSession
.
query
(
bulan
.
label
(
'bulan'
),
func
.
sum
(
SipkdApPayment
.
jumlah
)
.
label
(
'jumlah'
))
data_items
=
data_items
.
group_by
(
bulan
)
.
\
filter_by
(
kode
=
rekening_kd
,
tahun
=
tahun
)
.
\
order_by
(
bulan
)
values
=
{}
for
i
in
range
(
1
,
13
):
field
=
'value'
+
str
(
i
)
.
rjust
(
2
,
'_'
)
values
[
field
]
=
0
for
data_item
in
data_items
.
all
():
field
=
'value_'
+
str
(
int
(
data_item
.
bulan
))
values
[
field
]
=
data_item
.
jumlah
or
0
if
chart
.
chart_type
==
'line'
:
for
i
in
range
(
2
,
13
):
field
=
'value'
+
str
(
i
)
.
rjust
(
2
,
'_'
)
values
[
field
]
=
values
[
field
]
+
values
[
'value'
+
str
(
i
-
1
)
.
rjust
(
2
,
'_'
)]
print
(
'************'
,
chart_item
.
nama
,
chart
.
chart_type
,
values
)
chart_item
.
from_dict
(
values
)
print
(
'************'
,
chart_item
.
to_dict
())
DBSession
.
add
(
chart_item
)
DBSession
.
flush
()
#conf_file = 'conf.py'
#conf_table = None
#pars = OptionParser()
#pars.add_option('-c', '--conf', default=conf_file,
# help='configuration file, default: ' + conf_file)
#pars.add_option('', '--debug', action='store_true')
#pars.add_option('-t', '--tahun', default=tahun)
#
#option, remain = pars.parse_args(sys.argv[1:])
#
#debug = option.debug
#
#conf_file = option.conf
#conf = imp.load_source('conf', conf_file)
#
#locale.setlocale(locale.LC_ALL, conf.locale_format)
def
main
(
argv
=
sys
.
argv
):
print
(
'A'
)
def
alembic_run
(
ini_file
,
url
):
s
=
read_file
(
ini_file
)
s
=
s
.
replace
(
'{{db_url}}'
,
url
)
f
=
open
(
'alembic.ini'
,
'w'
)
f
.
write
(
s
)
f
.
close
()
subprocess
.
call
(
command
)
os
.
remove
(
'alembic.ini'
)
if
len
(
argv
)
!=
2
:
usage
(
argv
)
config_uri
=
argv
[
1
]
setup_logging
(
config_uri
)
settings
=
get_appsettings
(
config_uri
)
# Create Ziggurat tables
# bin_path = os.path.split(sys.executable)[0]
# alembic_bin = os.path.join(bin_path, 'alembic')
# command = (alembic_bin, 'upgrade', 'head')
# alembic_run('alembic.ini.tpl', settings['sqlalchemy.url'])
# alembic_run('alembic_upgrade.ini.tpl', settings['sqlalchemy.url'])
# Insert data
engine
=
engine_from_config
(
settings
,
'sqlalchemy.'
)
DBSession
.
configure
(
bind
=
engine
)
#init_model()
#create_schemas(engine)
# Base.metadata.create_all(engine)
# initial_data.insert()
process_pie
()
process_barline
()
transaction
.
commit
()
#call modules script
main
()
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