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 59cc2ecb
authored
May 20, 2025
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Tambah pengenalan tabel gw_payment di BPHTB
1 parent
1c0d1eaa
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
48 deletions
CHANGES.txt
payment_report/bphtb/default.py
payment_report/models.py
payment_report/pbb/default.py
CHANGES.txt
View file @
59cc2ec
3.1.8 2025-05-
19
3.1.8 2025-05-
20
----------------
- Tambah pengenalan tabel gw_payment di PBB
- Tambah pengenalan tabel gw_payment di PBB
dan BPHTB
3.1.7 2025-02-27
----------------
...
...
payment_report/bphtb/default.py
View file @
59cc2ec
...
...
@@ -9,7 +9,8 @@ from sqlalchemy import (
DateTime
,
String
,
Text
,
Date
,
ForeignKey
,
Date
,
ForeignKey
,
UniqueConstraint
,
func
,
or_
,
...
...
@@ -48,6 +49,7 @@ from opensipkd.iso8583.bjb.bphtb.models import Log
from
..models
import
(
Base
,
Bphtb
,
ApiLog
,
)
from
..common
import
(
get_iso
,
...
...
@@ -58,6 +60,7 @@ from ..common import (
one_day
,
InvalidSource
,
BANK_NAMES
,
BIT_18_NAMES
,
)
...
...
@@ -165,6 +168,41 @@ def cartenz_invoice_id(pay):
pay
.
no_urut_bphtb
def
err_sspd_id
(
sspd_id
):
msg
=
f
'Field bphtb_bank.sspd_id {sspd_id} tidak ada di '
\
'field bphtb_sspd.id'
raise
InvalidSource
(
msg
)
def
err_kecamatan
(
kode
):
msg
=
f
'Field bphtb_sspd.kd_kecamatan {kode} '
\
'tidak ada di field ref_kecamatan.kd_kecamatan'
raise
InvalidSource
(
msg
)
def
err_kelurahan
(
kode
):
msg
=
f
'Field bphtb_sspd.kd_kelurahan {kode} '
\
'tidak ada di field ref_kelurahan.kd_kelurahan'
raise
InvalidSource
(
msg
)
def
err_config
():
raise
Exception
(
'Tidak ada h2h_db_url maupun api_db_url di konfigurasi.'
)
def
err_date
(
tgl_akhir
,
tgl_bayar
):
print
(
f
'DEBUG self.tgl_akhir {tgl_akhir}'
)
raise
Exception
(
f
'{tgl_bayar} adalah masa depan. Perbaiki script.'
)
def
get_invoice_id
(
inv
):
invoice_id
=
FixLength
(
INVOICE_ID
)
invoice_id
[
'Tahun'
]
=
inv
.
tahun
invoice_id
[
'Kode'
]
=
inv
.
kode
invoice_id
[
'SSPD No'
]
=
inv
.
no_sspd
return
invoice_id
.
get_raw
()
class
App
(
BaseApp
):
conf_name
=
'bphtb payment last date'
report_orm
=
Bphtb
...
...
@@ -189,7 +227,18 @@ class App(BaseApp):
except
DatabaseError
:
self
.
prod_session
.
rollback
()
self
.
set_cartenz_models
()
if
'h2h_db_url'
in
self
.
conf
:
factory
=
self
.
get_factory
(
'h2h_db_url'
)
self
.
h2h_session
=
factory
()
self
.
set_h2h_db
()
else
:
self
.
h2h_session
=
None
if
'api_db_url'
in
self
.
conf
:
factory
=
self
.
get_factory
(
'api_db_url'
)
self
.
api_session
=
factory
()
self
.
base_q_api
=
self
.
api_session
.
query
(
ApiLog
)
else
:
self
.
api_session
=
None
def
get_log_model
(
self
):
if
self
.
is_sukabumi_kota
:
...
...
@@ -218,11 +267,6 @@ class App(BaseApp):
return
q
.
filter_by
(
bit_003
=
PAYMENT_CODE
,
bit_039
=
'00'
)
def
set_h2h_db
(
self
):
if
'h2h_db_url'
in
self
.
conf
:
factory
=
self
.
get_factory
(
'h2h_db_url'
)
self
.
h2h_session
=
factory
()
else
:
self
.
h2h_session
=
self
.
prod_session
try
:
self
.
h2h_session
.
query
(
JsonLog
.
bits
)
.
first
()
self
.
is_json_log
=
True
...
...
@@ -374,8 +418,6 @@ class App(BaseApp):
return
channel_id
,
info
[
'channel'
],
iso
.
get_stan
(),
ntb
def
get_iso_v2
(
self
):
if
not
self
.
base_q_log
:
return
Log
=
self
.
get_log_model
()
if
self
.
is_json_log
:
q
=
self
.
base_q_log
.
filter
(
...
...
@@ -401,6 +443,15 @@ class App(BaseApp):
channel_name
=
get_channel_name_by_row
(
row
)
return
channel_id
,
channel_name
,
stan
,
ntb
def
get_api
(
self
,
psppt
):
q
=
self
.
base_q_api
.
filter_by
(
bit_059
=
'1'
,
bit_061
=
self
.
invoice_id
)
q
=
q
.
order_by
(
ApiLog
.
id
.
desc
())
row
=
q
.
first
()
if
not
row
:
return
channel_nama
=
BIT_18_NAMES
[
row
.
bit_018
]
return
row
.
bit_018
,
channel_nama
,
row
.
bit_011
,
row
.
bit_037
,
row
.
bit_032
def
get_invoice_cartenz
(
self
,
pay
):
if
pay
.
no_transaksi_byr
in
(
'KB'
,
'KBT'
):
if
pay
.
no_transaksi_byr
==
'KB'
:
...
...
@@ -513,32 +564,23 @@ class App(BaseApp):
if
self
.
is_cartenz
:
return
self
.
create_data_cartenz
(
pay
)
if
not
pay
.
sspd_id
:
msg
=
'Field bphtb_bank.sspd_id NULL'
raise
InvalidSource
(
msg
)
raise
InvalidSource
(
'Field bphtb_bank.sspd_id NULL'
)
inv
=
self
.
get_invoice
(
pay
)
if
not
inv
:
msg
=
f
'Field bphtb_bank.sspd_id {pay.sspd_id} tidak ada di '
\
'field bphtb_sspd.id'
raise
InvalidSource
(
msg
)
err_sspd_id
(
pay
.
sspd_id
)
cust
=
self
.
get_customer
(
inv
)
perolehan
=
self
.
get_perolehan
(
inv
)
kecamatan
=
self
.
get_kecamatan_nama
(
inv
)
if
not
kecamatan
:
msg
=
f
'Field bphtb_sspd.kd_kecamatan {inv.kd_kecamatan} '
\
'tidak ada di field ref_kecamatan.kd_kecamatan'
raise
InvalidSource
(
msg
)
err_kecamatan
(
inv
.
kd_kecamatan
)
kelurahan
=
self
.
get_kelurahan_nama
(
inv
)
if
not
kelurahan
:
msg
=
f
'Field bphtb_sspd.kd_kelurahan {inv.kd_kelurahan} '
\
'tidak ada di field ref_kelurahan.kd_kelurahan'
raise
InvalidSource
(
msg
)
invoice_id
=
FixLength
(
INVOICE_ID
)
invoice_id
[
'Tahun'
]
=
inv
.
tahun
invoice_id
[
'Kode'
]
=
inv
.
kode
invoice_id
[
'SSPD No'
]
=
inv
.
no_sspd
self
.
invoice_id
=
invoice_id
.
get_raw
()
err_kelurahan
(
inv
.
kd_kelurahan
)
self
.
invoice_id
=
get_invoice_id
(
inv
)
bank_id
=
stan
=
ntb
=
None
channel_id
=
'0000'
channel_nama
=
'MANUAL'
if
self
.
h2h_session
:
source
=
self
.
get_iso_v2
()
if
source
:
channel_id
,
channel_nama
,
stan
,
ntb
=
source
...
...
@@ -547,13 +589,15 @@ class App(BaseApp):
if
source
:
channel_id
,
channel_nama
,
stan
,
ntb
=
source
else
:
stan
=
ntb
=
None
channel_id
=
'0000'
channel_nama
=
self
.
get_va_channel
(
pay
.
tanggal
)
or
'MANUAL'
elif
self
.
api_session
:
source
=
self
.
get_api
(
pay
)
if
source
:
channel_id
,
channel_nama
,
stan
,
ntb
,
bank_id
=
source
else
:
err_config
()
if
pay
.
tanggal
>
date
.
today
():
print
(
f
'DEBUG self.tgl_akhir {self.tgl_akhir}'
)
raise
Exception
(
f
'{pay.tanggal} adalah masa depan. Perbaiki script.'
)
err_date
(
self
.
tgl_akhir
,
pay
.
tanggal
)
return
dict
(
id
=
pay
.
id
,
stan
=
stan
,
ntb
=
ntb
,
tgl
=
pay
.
tanggal
,
jam
=
pay
.
jam
,
invoice_id
=
self
.
invoice_id
,
nop
=
pay
.
nop
,
wp_nama
=
pay
.
wp_nama
,
...
...
@@ -562,4 +606,4 @@ class App(BaseApp):
nilai_bphtb
=
pay
.
bayar
,
jenis_perolehan
=
perolehan
.
nama
,
ppat
=
cust
.
nama
.
strip
(),
channel_id
=
channel_id
,
channel_nama
=
channel_nama
,
kecamatan_op
=
kecamatan
.
nm_kecamatan
,
kelurahan_op
=
kelurahan
.
nm_kelurahan
)
kelurahan_op
=
kelurahan
.
nm_kelurahan
,
bank_id
=
bank_id
)
payment_report/models.py
View file @
59cc2ec
...
...
@@ -4,6 +4,7 @@ from sqlalchemy import (
BigInteger
,
Float
,
String
,
Text
,
Date
,
Time
,
DateTime
,
...
...
@@ -147,6 +148,7 @@ class Bphtb(Base, Common):
kecamatan_op
=
Column
(
String
(
64
))
# pbb.ref_kelurahan.nm_kelurahan
kelurahan_op
=
Column
(
String
(
64
))
bank_id
=
Column
(
Integer
)
class
Pbb
(
Base
,
Common
):
...
...
@@ -266,3 +268,17 @@ class Pkb(Base, Common):
nama_kabupaten
=
Column
(
String
(
64
),
nullable
=
False
)
__table_args__
=
(
UniqueConstraint
(
waktu
,
no_polisi
),)
class
ApiLog
(
Base
):
__tablename__
=
'gw_payment'
id
=
Column
(
Integer
,
primary_key
=
True
)
tgl
=
Column
(
DateTime
(
timezone
=
True
),
nullable
=
True
)
bit_004
=
Column
(
Text
,
nullable
=
False
)
# Nilai transaksi
bit_011
=
Column
(
Text
,
nullable
=
False
)
# STAN
bit_018
=
Column
(
Text
,
nullable
=
False
)
# Channel
bit_032
=
Column
(
Text
,
nullable
=
False
)
# Bank
bit_037
=
Column
(
Text
,
nullable
=
False
)
# NTB
bit_047
=
Column
(
Text
,
nullable
=
False
)
# NTP
bit_059
=
Column
(
Text
,
nullable
=
False
)
# 1 BPHTB, 2 PJDL, 3 WEBR, 4 PBB
bit_061
=
Column
(
Text
,
nullable
=
False
)
# Invoice ID
payment_report/pbb/default.py
View file @
59cc2ec
...
...
@@ -7,7 +7,6 @@ from sqlalchemy import (
Integer
,
String
,
DateTime
,
Text
,
UniqueConstraint
,
func
,
)
...
...
@@ -25,6 +24,7 @@ from opensipkd.iso8583.bjb.models import Log as UniversalLog
from
..models
import
(
Pbb
,
Base
,
ApiLog
,
)
from
..common
import
(
get_iso
,
...
...
@@ -92,19 +92,6 @@ class JsonLog(Base):
dict
(
schema
=
'public'
))
class
ApiLog
(
Base
):
__tablename__
=
'gw_payment'
id
=
Column
(
Integer
,
primary_key
=
True
)
tgl
=
Column
(
DateTime
(
timezone
=
True
),
nullable
=
True
)
bit_004
=
Column
(
Text
,
nullable
=
False
)
# Nilai transaksi
bit_011
=
Column
(
Text
,
nullable
=
False
)
# STAN
bit_018
=
Column
(
Text
,
nullable
=
False
)
# Channel
bit_032
=
Column
(
Text
,
nullable
=
False
)
# Bank
bit_037
=
Column
(
Text
,
nullable
=
False
)
# NTB
bit_047
=
Column
(
Text
,
nullable
=
False
)
# NTP
bit_061
=
Column
(
Text
,
nullable
=
False
)
# Invoice ID
class
App
(
BaseApp
):
conf_name
=
'pbb payment last date'
report_orm
=
Pbb
...
...
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