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 7773626b
authored
Dec 06, 2022
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Tambah BPHTB Kota Sukabumi
1 parent
5dd39a07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
29 deletions
CHANGES.txt
payment_report/scripts/bphtb.py
CHANGES.txt
View file @
7773626
2.4 2022-12-06
--------------
- Penambahan BPHTB Kota Sukabumi
2.3 2022-10-17
2.3 2022-10-17
--------------
--------------
- Penambahan field status pada webr_report sebagai filter pembayaran
- Penambahan field status pada webr_report sebagai filter pembayaran
...
...
payment_report/scripts/bphtb.py
View file @
7773626
import
sys
import
sys
from
datetime
import
datetime
import
pdb
from
datetime
import
datetime
,
timedelta
from
sqlalchemy
import
(
from
sqlalchemy
import
(
Column
,
Column
,
Integer
,
Integer
,
DateTime
,
DateTime
,
String
,
String
,
Date
,
Text
,
ForeignKey
,
Date
,
ForeignKey
,
UniqueConstraint
,
UniqueConstraint
,
func
,
func
,
)
)
from
sqlalchemy.ext.declarative
import
declared_attr
from
sqlalchemy.ext.declarative
import
declared_attr
from
sqlalchemy.exc
import
ProgrammingError
from
sqlalchemy.exc
import
(
ProgrammingError
,
OperationalError
,
)
from
opensipkd.string
import
FixLength
from
opensipkd.string
import
FixLength
from
opensipkd.waktu
import
dmyhms
from
opensipkd.waktu
import
dmyhms
from
opensipkd.bphtb.models.customer
import
CustomerMixin
from
opensipkd.bphtb.models.customer
import
CustomerMixin
...
@@ -91,6 +95,23 @@ class IsoPayment(Base):
...
@@ -91,6 +95,23 @@ class IsoPayment(Base):
bank_ip
=
Column
(
String
(
15
),
nullable
=
False
)
bank_ip
=
Column
(
String
(
15
),
nullable
=
False
)
class
SukabumiKotaLog
(
Base
):
__tablename__
=
'iso_log'
id
=
Column
(
Integer
,
primary_key
=
True
)
created
=
Column
(
DateTime
(
timezone
=
True
),
nullable
=
False
)
mti
=
Column
(
String
(
4
),
nullable
=
False
)
bit_003
=
Column
(
Text
)
bit_011
=
Column
(
Text
)
bit_018
=
Column
(
Text
)
bit_032
=
Column
(
Text
)
bit_039
=
Column
(
Text
)
bit_041
=
Column
(
Text
)
bit_042
=
Column
(
Text
)
bit_043
=
Column
(
Text
)
bit_058
=
Column
(
Text
)
bit_062
=
Column
(
Text
)
class
App
(
BaseApp
):
class
App
(
BaseApp
):
conf_name
=
'bphtb payment last date'
conf_name
=
'bphtb payment last date'
report_orm
=
Bphtb
report_orm
=
Bphtb
...
@@ -101,36 +122,75 @@ class App(BaseApp):
...
@@ -101,36 +122,75 @@ class App(BaseApp):
if
not
self
.
pid
:
if
not
self
.
pid
:
return
return
self
.
base_q_func
=
self
.
prod_session
.
query
(
func
.
count
())
self
.
base_q_func
=
self
.
prod_session
.
query
(
func
.
count
())
self
.
base_q_inv
=
self
.
prod_session
.
query
(
Invoice
)
self
.
is_sukabumi_kota
=
False
try
:
try
:
self
.
base_q_inv
.
first
()
self
.
set_default_models
()
self
.
Customer
=
Customer
except
(
ProgrammingError
,
OperationalError
):
self
.
Perolehan
=
Perolehan
self
.
Invoice
=
Invoice
self
.
Payment
=
Payment
self
.
base_q_cust
=
self
.
prod_session
.
query
(
self
.
Customer
)
self
.
base_q_perolehan
=
self
.
prod_session
.
query
(
self
.
Perolehan
)
self
.
base_q_pay
=
self
.
prod_session
.
query
(
self
.
Payment
)
except
ProgrammingError
:
self
.
prod_session
.
rollback
()
self
.
prod_session
.
rollback
()
self
.
Customer
=
AlternativeCustomer
try
:
self
.
Perolehan
=
AlternativePerolehan
self
.
set_alternative_models
()
self
.
Invoice
=
AlternativeInvoice
except
(
ProgrammingError
,
OperationalError
):
self
.
Payment
=
AlternativePayment
self
.
set_sukabumi_kota_models
()
self
.
base_q_inv
=
self
.
prod_session
.
query
(
AlternativeInvoice
)
self
.
set_h2h_db
()
self
.
base_q_cust
=
self
.
prod_session
.
query
(
AlternativeCustomer
)
self
.
base_q_perolehan
=
self
.
prod_session
.
query
(
def
get_log_model
(
self
):
AlternativePerolehan
)
if
self
.
is_sukabumi_kota
:
self
.
base_q_pay
=
self
.
prod_session
.
query
(
AlternativePayment
)
return
SukabumiKotaLog
self
.
base_q_log
=
self
.
prod_session
.
query
(
Log
)
.
filter_by
(
return
Log
mti
=
'0210'
,
bit_003
=
PAYMENT_CODE
,
bit_039
=
'00'
)
def
get_base_q_log
(
self
):
Log
=
self
.
get_log_model
()
return
self
.
h2h_session
.
query
(
Log
)
.
filter_by
(
mti
=
'0210'
,
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
self
.
base_q_log
=
self
.
get_base_q_log
()
try
:
try
:
self
.
base_q_log
.
first
()
self
.
base_q_log
.
first
()
except
ProgrammingError
:
except
ProgrammingError
:
self
.
prod_session
.
rollback
()
self
.
h2h_session
.
rollback
()
# Berarti Log ISO8583 masih di tabel versi 1
self
.
base_q_log
=
None
self
.
base_q_log
=
None
def
set_default_models
(
self
):
self
.
base_q_inv
=
self
.
prod_session
.
query
(
Invoice
)
self
.
base_q_inv
.
first
()
self
.
Customer
=
Customer
self
.
Perolehan
=
Perolehan
self
.
Invoice
=
Invoice
self
.
Payment
=
Payment
self
.
base_q_cust
=
self
.
prod_session
.
query
(
self
.
Customer
)
self
.
base_q_perolehan
=
self
.
prod_session
.
query
(
self
.
Perolehan
)
self
.
base_q_pay
=
self
.
prod_session
.
query
(
self
.
Payment
)
def
set_alternative_models
(
self
):
self
.
base_q_inv
=
self
.
prod_session
.
query
(
AlternativeInvoice
)
self
.
base_q_inv
.
first
()
self
.
Customer
=
AlternativeCustomer
self
.
Perolehan
=
AlternativePerolehan
self
.
Invoice
=
AlternativeInvoice
self
.
Payment
=
AlternativePayment
self
.
base_q_cust
=
self
.
prod_session
.
query
(
AlternativeCustomer
)
self
.
base_q_perolehan
=
self
.
prod_session
.
query
(
AlternativePerolehan
)
self
.
base_q_pay
=
self
.
prod_session
.
query
(
AlternativePayment
)
def
set_sukabumi_kota_models
(
self
):
from
opensipkd.bphtb.models.sukabumi_kota
import
Invoice
,
Payment
self
.
is_sukabumi_kota
=
True
self
.
Invoice
=
Invoice
self
.
Payment
=
Payment
self
.
base_q_inv
=
self
.
prod_session
.
query
(
self
.
Invoice
)
self
.
base_q_pay
=
self
.
prod_session
.
query
(
self
.
Payment
)
def
get_last_time
(
self
):
# Override
def
get_last_time
(
self
):
# Override
if
self
.
is_sukabumi_kota
:
return
self
.
last_pay
.
tgl_rekam
.
strftime
(
'
%
d-
%
m-
%
Y
%
H:
%
M:
%
S'
)
s_tgl
=
self
.
last_pay
.
tanggal
.
strftime
(
'
%
d-
%
m-
%
Y'
)
s_tgl
=
self
.
last_pay
.
tanggal
.
strftime
(
'
%
d-
%
m-
%
Y'
)
s_jam
=
self
.
last_pay
.
jam
.
strftime
(
'
%
H:
%
M:
%
S'
)
s_jam
=
self
.
last_pay
.
jam
.
strftime
(
'
%
H:
%
M:
%
S'
)
return
f
'{s_tgl} {s_jam}'
return
f
'{s_tgl} {s_jam}'
...
@@ -145,11 +205,22 @@ class App(BaseApp):
...
@@ -145,11 +205,22 @@ class App(BaseApp):
self
.
Payment
.
tanggal
>=
self
.
tgl_awal
,
self
.
Payment
.
tanggal
>=
self
.
tgl_awal
,
self
.
Payment
.
tanggal
<
self
.
tgl_akhir
+
one_day
)
self
.
Payment
.
tanggal
<
self
.
tgl_akhir
+
one_day
)
def
get_filter_query_sukabumi_kota
(
self
,
q
):
return
q
.
filter
(
self
.
Payment
.
tgl_pembayaran
>=
self
.
tgl_awal
,
self
.
Payment
.
tgl_pembayaran
<
self
.
tgl_akhir
+
one_day
)
def
get_count
(
self
)
->
int
:
# Override
def
get_count
(
self
)
->
int
:
# Override
q
=
self
.
get_filter_query
(
self
.
base_q_func
)
if
self
.
is_sukabumi_kota
:
q
=
self
.
get_filter_query_sukabumi_kota
(
self
.
base_q_func
)
else
:
q
=
self
.
get_filter_query
(
self
.
base_q_func
)
return
q
.
scalar
()
return
q
.
scalar
()
def
get_payment_query
(
self
):
# Override
def
get_payment_query
(
self
):
# Override
if
self
.
is_sukabumi_kota
:
q
=
self
.
get_filter_query_sukabumi_kota
(
self
.
base_q_pay
)
return
q
.
order_by
(
self
.
Payment
.
tgl_pembayaran
,
self
.
Payment
.
id
)
q
=
self
.
get_filter_query
(
self
.
base_q_pay
)
q
=
self
.
get_filter_query
(
self
.
base_q_pay
)
return
q
.
order_by
(
self
.
Payment
.
tanggal
,
self
.
Payment
.
jam
)
return
q
.
order_by
(
self
.
Payment
.
tanggal
,
self
.
Payment
.
jam
)
...
@@ -169,6 +240,7 @@ class App(BaseApp):
...
@@ -169,6 +240,7 @@ class App(BaseApp):
def
get_iso_v2
(
self
):
def
get_iso_v2
(
self
):
if
not
self
.
base_q_log
:
if
not
self
.
base_q_log
:
return
return
Log
=
self
.
get_log_model
()
q
=
self
.
base_q_log
.
filter
(
func
.
trim
(
Log
.
bit_062
)
==
self
.
invoice_id
)
q
=
self
.
base_q_log
.
filter
(
func
.
trim
(
Log
.
bit_062
)
==
self
.
invoice_id
)
q
=
q
.
order_by
(
Log
.
id
.
desc
())
q
=
q
.
order_by
(
Log
.
id
.
desc
())
row
=
q
.
first
()
row
=
q
.
first
()
...
@@ -179,7 +251,10 @@ class App(BaseApp):
...
@@ -179,7 +251,10 @@ class App(BaseApp):
return
channel_id
,
channel_nama
,
row
.
bit_011
,
row
.
bit_058
.
strip
()
return
channel_id
,
channel_nama
,
row
.
bit_011
,
row
.
bit_058
.
strip
()
def
get_invoice
(
self
,
pay
):
def
get_invoice
(
self
,
pay
):
q
=
self
.
base_q_inv
.
filter_by
(
id
=
pay
.
sspd_id
)
if
self
.
is_sukabumi_kota
:
q
=
self
.
base_q_inv
.
filter_by
(
id
=
pay
.
id_tagihan
)
else
:
q
=
self
.
base_q_inv
.
filter_by
(
id
=
pay
.
sspd_id
)
return
q
.
first
()
return
q
.
first
()
def
get_customer
(
self
,
inv
):
def
get_customer
(
self
,
inv
):
...
@@ -190,14 +265,39 @@ class App(BaseApp):
...
@@ -190,14 +265,39 @@ class App(BaseApp):
q
=
self
.
base_q_perolehan
.
filter_by
(
id
=
inv
.
perolehan_id
)
q
=
self
.
base_q_perolehan
.
filter_by
(
id
=
inv
.
perolehan_id
)
return
q
.
first
()
return
q
.
first
()
def
create_data_sukabumi_kota
(
self
,
pay
):
inv
=
self
.
get_invoice
(
pay
)
if
not
inv
:
msg
=
f
'Invoice ID {pay.id_tagihan} tidak ditemukan di '
\
'tabel tagihan_bphtb'
raise
InvalidSource
(
msg
)
self
.
invoice_id
=
str
(
inv
.
no_tagihan
)
source
=
self
.
get_iso_v2
()
if
source
:
channel_id
,
channel_nama
,
stan
,
ntb
=
source
else
:
stan
=
ntb
=
None
channel_id
=
'0000'
channel_nama
=
'MANUAL'
return
dict
(
id
=
pay
.
id
,
stan
=
stan
,
ntb
=
ntb
,
tgl
=
pay
.
tgl_pembayaran
.
date
(),
jam
=
pay
.
tgl_pembayaran
.
time
(),
invoice_id
=
self
.
invoice_id
,
nop
=
inv
.
nop
,
wp_nama
=
inv
.
nama_wp
.
strip
(),
wp_alamat
=
inv
.
alamat_wp
,
op_alamat
=
inv
.
alamat_op
,
npop
=
inv
.
npop
,
bumi_luas
=
inv
.
luas_tanah
,
bng_luas
=
inv
.
luas_bangunan
,
nilai_bphtb
=
pay
.
jumlah_yg_dibayar
,
jenis_perolehan
=
str
(
inv
.
jns_perolehan_hak
),
ppat
=
inv
.
nama_notaris
,
channel_id
=
channel_id
,
channel_nama
=
channel_nama
)
def
create_data
(
self
,
pay
):
# Override
def
create_data
(
self
,
pay
):
# Override
if
self
.
is_sukabumi_kota
:
return
self
.
create_data_sukabumi_kota
(
pay
)
if
not
pay
.
sspd_id
:
if
not
pay
.
sspd_id
:
msg
=
'Field bphtb_bank.sspd_id NULL'
msg
=
'Field bphtb_bank.sspd_id NULL'
raise
InvalidSource
(
msg
)
raise
InvalidSource
(
msg
)
inv
=
self
.
get_invoice
(
pay
)
inv
=
self
.
get_invoice
(
pay
)
if
not
inv
:
if
not
inv
:
msg
=
f
'Field bphtb_bank.sspd_id {pay.sspd_id} tidak ada di '
\
msg
=
f
'Field bphtb_bank.sspd_id {pay.sspd_id} tidak ada di '
\
'field bphtb_sspd.id'
'field bphtb_sspd.id'
raise
InvalidSource
(
msg
)
raise
InvalidSource
(
msg
)
cust
=
self
.
get_customer
(
inv
)
cust
=
self
.
get_customer
(
inv
)
perolehan
=
self
.
get_perolehan
(
inv
)
perolehan
=
self
.
get_perolehan
(
inv
)
...
...
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