Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Owo Sugiana
/
payment-report
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 e9bd1443
authored
Aug 15, 2024
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
WEBR menggunakan tgl_bayar ketimbang created
1 parent
d9695e33
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
11 deletions
contrib/sync_ar_payment.sql
contrib/trigger_ar_payment.sql
contrib/webr_checksum.py
contrib/webr_update_deleted_payment.py
payment_report/models.py
payment_report/webr/default.py
contrib/sync_ar_payment.sql
View file @
e9bd144
CREATE
TABLE
sync_ar_payment
(
id
serial
primary
key
,
created
timestamptz
NOT
NULL
DEFAULT
now
(),
tgl_bayar
timestamptz
NOT
NULL
,
invoice_id
integer
NOT
NULL
,
payment_id
integer
NOT
NULL
)
contrib/trigger_ar_payment.sql
View file @
e9bd144
...
...
@@ -3,7 +3,8 @@ LANGUAGE plpgsql
AS
$$
BEGIN
INSERT
INTO
sync_ar_payment
(
invoice_id
,
payment_id
)
VALUES
(
NEW
.
ar_invoice_id
,
NEW
.
id
);
INSERT
INTO
sync_ar_payment
(
invoice_id
,
payment_id
,
tgl_bayar
)
VALUES
(
NEW
.
ar_invoice_id
,
NEW
.
id
,
NEW
.
tgl_bayar
);
RETURN
NEW
;
END
$$
;
...
...
@@ -13,7 +14,8 @@ LANGUAGE plpgsql
AS
$$
BEGIN
INSERT
INTO
sync_ar_payment
(
invoice_id
,
payment_id
)
VALUES
(
OLD
.
ar_invoice_id
,
OLD
.
id
);
INSERT
INTO
sync_ar_payment
(
invoice_id
,
payment_id
,
tgl_bayar
)
VALUES
(
OLD
.
ar_invoice_id
,
OLD
.
id
,
OLD
.
tgl_bayar
);
RETURN
OLD
;
END
$$
;
...
...
contrib/webr_checksum.py
0 → 100644
View file @
e9bd144
import
sys
from
argparse
import
ArgumentParser
from
configparser
import
ConfigParser
from
datetime
import
(
date
,
datetime
,
timedelta
,
)
from
sqlalchemy
import
(
create_engine
,
func
,
)
from
sqlalchemy.orm
import
sessionmaker
from
opensipkd.waktu
import
dmy
from
opensipkd.webr.models.default
import
Payment
from
payment_report.models
import
Webr
default_tgl
=
dmy
(
date
.
today
())
help_tgl
=
f
'default {default_tgl}'
pars
=
ArgumentParser
()
pars
.
add_argument
(
'conf'
)
pars
.
add_argument
(
'--tgl'
,
default
=
default_tgl
,
help
=
help_tgl
)
option
=
pars
.
parse_args
(
sys
.
argv
[
1
:])
conf
=
ConfigParser
()
conf
.
read
(
option
.
conf
)
cf
=
dict
(
conf
.
items
(
'main'
))
t
=
option
.
tgl
.
split
(
','
)
tgl_awal
=
datetime
.
strptime
(
t
[
0
],
'
%
d-
%
m-
%
Y'
)
tgl_awal
=
tgl_awal
.
date
()
if
t
[
1
:]:
tgl_akhir
=
datetime
.
strptime
(
t
[
1
],
'
%
d-
%
m-
%
Y'
)
tgl_akhir
=
tgl_akhir
.
date
()
else
:
tgl_akhir
=
tgl_awal
one_day
=
timedelta
(
1
)
engine_prod
=
create_engine
(
cf
[
'db_url'
])
engine_rpt
=
create_engine
(
cf
[
'report_db_url'
])
factory_prod
=
sessionmaker
(
bind
=
engine_prod
)
factory_rpt
=
sessionmaker
(
bind
=
engine_rpt
)
db_session_prod
=
factory_prod
()
db_session_rpt
=
factory_rpt
()
awal
=
tgl_awal
while
True
:
q_rpt
=
db_session_rpt
.
query
(
func
.
sum
(
Webr
.
jml_bayar
))
.
filter
(
Webr
.
tgl
==
awal
)
rpt_sum
=
q_rpt
.
scalar
()
or
0
rpt_sum
=
int
(
rpt_sum
)
q_prod
=
db_session_prod
.
query
(
func
.
sum
(
Payment
.
bayar
))
.
filter
(
Payment
.
tgl_bayar
>=
awal
,
Payment
.
tgl_bayar
<
awal
+
one_day
)
prod_sum
=
q_prod
.
scalar
()
or
0
if
rpt_sum
==
prod_sum
:
status
=
'Sama'
else
:
status
=
'Beda'
rpt_s
=
'{0:,}'
.
format
(
rpt_sum
)
prod_s
=
'{0:,}'
.
format
(
prod_sum
)
print
(
f
'{dmy(awal)}, Report {rpt_s}, Production {prod_s}, {status}'
)
if
awal
==
tgl_akhir
:
break
awal
+=
one_day
contrib/webr_update_deleted_payment.py
View file @
e9bd144
...
...
@@ -25,7 +25,7 @@ db_session_prod = factory_prod()
db_session_rpt
=
factory_rpt
()
q_rpt
=
db_session_rpt
.
query
(
Webr
)
q_rpt
=
q_rpt
.
filter
(
Webr
.
id
>=
17739
)
q_rpt
=
q_rpt
.
filter
(
Webr
.
id
)
for
rpt
in
q_rpt
.
order_by
(
Webr
.
id
):
q_prod
=
db_session_prod
.
query
(
Payment
)
.
filter_by
(
id
=
rpt
.
id
)
prod
=
q_prod
.
first
()
...
...
payment_report/models.py
View file @
e9bd144
...
...
@@ -80,6 +80,8 @@ class SyncWebr(Base, Common):
payment_id
=
Column
(
Integer
,
nullable
=
False
)
# webr.ar_payment.ar_invoice_id
invoice_id
=
Column
(
Integer
,
nullable
=
False
)
# webr.ar_payment.tgl_bayar
tgl_bayar
=
Column
(
DateTime
(
timezone
=
True
),
nullable
=
False
)
class
Webr
(
Base
,
Common
):
...
...
payment_report/webr/default.py
View file @
e9bd144
...
...
@@ -104,7 +104,7 @@ class App(BaseApp):
channel_name
=
'VA'
else
:
channel_id
=
'0000'
tgl
=
pay
.
created
.
date
()
tgl
=
pay
.
tgl_bayar
.
date
()
channel_name
=
self
.
get_va_channel
(
tgl
)
or
'MANUAL'
stan
=
iso
and
iso
.
bit_011
or
None
ntb
=
pay
.
ntb
and
pay
.
ntb
.
strip
()
or
None
...
...
@@ -135,11 +135,13 @@ class App(BaseApp):
def
get_filter_query
(
self
,
q
):
if
self
.
base_q_sync
:
orm
=
SyncWebr
f
=
orm
.
tgl_bayar
else
:
orm
=
self
.
base_q_pay
and
Payment
or
self
.
IsoLog
orm
=
self
.
IsoLog
f
=
orm
.
created
return
q
.
filter
(
orm
.
created
>=
self
.
tgl_awal
,
orm
.
created
<
self
.
tgl_akhir
+
one_day
)
f
>=
self
.
tgl_awal
,
f
<
self
.
tgl_akhir
+
one_day
)
def
get_count
(
self
):
# Override
q
=
self
.
prod_session
.
query
(
func
.
count
())
...
...
@@ -150,11 +152,10 @@ class App(BaseApp):
if
self
.
base_q_sync
:
q
=
self
.
base_q_sync
orm
=
SyncWebr
elif
self
.
base_q_pay
:
q
=
self
.
base_q_pay
orm
=
Payment
f
=
orm
.
tgl_bayar
else
:
q
=
self
.
base_q_iso
orm
=
self
.
IsoLog
f
=
orm
.
created
q
=
self
.
get_filter_query
(
q
)
return
q
.
order_by
(
orm
.
created
)
return
q
.
order_by
(
f
)
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