Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Taufik Yulianto
/
esipkd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 539dc6c7
authored
Mar 13, 2023
by
taufikyu
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
penambahan create_va dan create_qris
1 parent
ab792de3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
188 additions
and
4 deletions
esipkd/views/arinvoice.py
esipkd/views/rpc.py
esipkd/views/arinvoice.py
View file @
539dc6c
...
...
@@ -16,7 +16,7 @@ from deform import (
widget
,
ValidationFailure
,
)
from
..tools
import
_DTnumberformat
,
multi_dict_values
from
..tools
import
_DTnumberformat
,
multi_dict_values
,
get_settings
from
..models
import
DBSession
from
..models.isipkd
import
(
Pegawai
,
ObjekPajak
,
SubjekPajak
,
ARInvoice
,
...
...
@@ -28,6 +28,8 @@ from datatables import (
ColumnDT
,
DataTables
)
from
..security
import
group_finder
,
group_in
from
..models.bjb_va
import
BJBVA
from
..models.bjb_qris
import
BJBQRIS
SESS_ADD_FAILED
=
'Gagal tambah Tagihan'
SESS_EDIT_FAILED
=
'Gagal edit Tagihan'
...
...
@@ -536,6 +538,21 @@ def save_request5(request, row5=None):
row5
=
Sptpd
()
return
row5
def
remove_vaqris
(
row
):
parameter
=
dict
(
bjbqris_url
=
get_settings
()[
'bjbqris_url'
]
and
get_settings
()[
'bjbqris_url'
]
.
strip
(
'/'
)
or
''
,
bjbqris_user
=
get_settings
()[
'bjbqris_user'
]
and
get_settings
()[
'bjbqris_user'
]
.
strip
()
or
''
,
bjbqris_key
=
get_settings
()[
'bjbqris_key'
]
and
get_settings
()[
'bjbqris_key'
]
.
strip
()
or
''
)
#remove va
cekva
=
BJBVA
.
query
()
.
filter_by
(
invoice_no
=
row
.
kode
)
.
first
()
if
cekva
:
BJBVA
.
cancel_va
(
dict
(
va_number
=
cekva
.
va_number
),
parameter
)
#remove qris ???
# cekqris = BJBQRIS.query().filter_by(invoice_no=row.kode).first()
# if cekqris:
# BJBQRIS.cancel_va(dict(va_number=cekva.va_number), parameter)
##########
# Delete #
##########
...
...
@@ -586,6 +603,7 @@ def view_delete(request):
q
.
delete
()
DBSession
.
flush
()
request
.
session
.
flash
(
msg
)
remove_vaqris
(
row
)
return
route_list
(
request
)
return
dict
(
row
=
row
,
form
=
form
.
render
())
...
...
esipkd/views/rpc.py
View file @
539dc6c
...
...
@@ -5,10 +5,10 @@ import hmac
import
hashlib
import
base64
from
datetime
import
datetime
,
time
,
date
from
sqlalchemy
import
not_
,
func
,
between
,
and_
from
sqlalchemy
import
not_
,
func
,
between
,
and_
,
literal_column
from
pyramid_rpc.jsonrpc
import
jsonrpc_method
from
pyramid_rpc.jsonrpc
import
JsonRpcError
from
..tools
import
(
date_from_str
,
dict_to_str
,
to_str
,
get_settings
)
from
..tools
import
(
date_from_str
,
dict_to_str
,
to_str
,
get_settings
,
ymdhms
)
##MODEL
from
..models.isipkd
import
(
DBSession
,
ARInvoice
,
ARSspd
,
User
,
Unit
,
ObjekPajak
,
SubjekPajak
,
Rekening
,
Wilayah
)
...
...
@@ -18,6 +18,8 @@ from ..models.rpc import (DepartemenRoute, auth_from_rpc, auth_from_rpc, json_rp
from
..models.rpc
import
(
JsonRpcBillNotFoundError
,
JsonRpcPaymentNotFoundError
,
JsonRpcBillAllreadyPaidError
,
JsonRpcInvalidDataError
,
JsonRpcInvalidLoginError
,
custom_error
)
from
.bjb_qris
import
(
BJBQRIS
,
cekqris
,
calculate_tagihan
,
rpc_params
as
rpc_qris
)
from
.bjb_va
import
(
BJBVA
,
cekva
,
calculate_tagihan
,
rpc_params
as
rpc_va
)
import
logging
log
=
logging
.
getLogger
(
'RPC ESIPKD'
)
...
...
@@ -268,4 +270,168 @@ def send_payment(request, data):
return
dict
(
code
=
0
,
message
=
"Send Payment Success"
,
data
=
datar
,
)
\ No newline at end of file
)
@jsonrpc_method
(
method
=
'create_qris'
,
endpoint
=
'api-webr'
)
def
create_qris
(
request
,
data
):
"""
Digunakan untuk menambahkan create qris
:param request:
:param data:
- kd_bayar
- unit_kode
:return:
-
"""
auth_from_rpc
(
request
)
get_mandatory
(
data
,
[
'kd_bayar'
,
'unit_kode'
])
log
.
error
(
'CREATE QRIS BJBQRIS'
)
log
.
error
(
data
)
cekQr
=
DBSession
.
query
(
BJBQRIS
)
.
filter
(
BJBQRIS
.
invoice_no
==
data
[
'kd_bayar'
])
.
first
()
if
cekQr
and
cekQr
.
expired_date
>
datetime
.
now
():
dt_qris
=
dict
(
client_type
=
cekQr
.
client_type
,
product_code
=
cekQr
.
product_code
,
invoice_no
=
cekQr
.
invoice_no
,
description
=
cekQr
.
description
,
customer_name
=
cekQr
.
customer_name
,
customer_email
=
cekQr
.
customer_email
and
cekQr
.
customer_email
or
'-'
,
customer_phone
=
cekQr
.
customer_phone
and
cekQr
.
customer_phone
or
'-'
,
expired_date
=
ymdhms
(
datetime
.
combine
(
cekQr
.
expired_date
,
time
(
23
,
59
,
59
))),
amount
=
cekQr
.
amount
,
qrcode
=
cekQr
.
qrcode
)
return
dict
(
code
=
0
,
message
=
"Success Create Qris"
,
data
=
dt_qris
)
row
=
DBSession
.
query
(
ARInvoice
.
id
.
label
(
'id'
),
ARInvoice
.
jumlah
.
label
(
'jumlah'
),
ARInvoice
.
kode
.
label
(
'kode'
),
ARInvoice
.
jatuh_tempo
.
label
(
'jatuh_tempo'
),
func
.
concat
(
ARInvoice
.
no_skrd
,
literal_column
(
"' Tgl:'"
)
,
func
.
to_char
(
ARInvoice
.
tgl_tetap
,
'DD/MM/YYYY'
)
,
literal_column
(
"' Tgl:'"
)
,
func
.
to_char
(
ARInvoice
.
jatuh_tempo
,
'DD/MM/YYYY'
)
,
literal_column
(
"' '"
)
,
ARInvoice
.
keterangan
)
.
label
(
'description'
),
ARInvoice
.
wp_nama
.
label
(
'wp_nama'
),
SubjekPajak
.
email
.
label
(
'subjek_email'
),
ARInvoice
.
status_bayar
.
label
(
'status'
))
.
\
filter
(
func
.
trim
(
ARInvoice
.
kode
)
==
data
[
'kd_bayar'
]
.
strip
(),
func
.
trim
(
ARInvoice
.
unit_kode
)
==
data
[
'unit_kode'
]
.
strip
())
.
\
outerjoin
(
SubjekPajak
,
SubjekPajak
.
id
==
ARInvoice
.
subjek_pajak_id
)
.
first
()
if
not
hasattr
(
row
,
'status'
)
or
row
.
status
!=
0
:
return
dict
(
code
=-
1
,
message
=
"No bayar tidak ditemukan / Sudah dibayar"
)
pokok
,
denda
=
calculate_tagihan
(
dict
(
pokok
=
row
.
jumlah
,
jatuh_tempo
=
row
.
jatuh_tempo
))
if
row
.
jatuh_tempo
<
date
.
today
():
jatuh_tempo
=
ymdhms
(
datetime
.
combine
(
date
.
today
(),
time
(
23
,
59
,
59
)))
else
:
jatuh_tempo
=
ymdhms
(
datetime
.
combine
(
row
.
jatuh_tempo
,
time
(
23
,
59
,
59
)))
expired_date
=
jatuh_tempo
dt_qris
=
dict
(
client_type
=
"3"
,
product_code
=
"30"
,
invoice_no
=
row
.
kode
,
description
=
row
.
description
,
customer_name
=
row
.
wp_nama
,
customer_email
=
row
.
subjek_email
and
row
.
subjek_email
or
'-'
,
customer_phone
=
'-'
,
expired_date
=
expired_date
,
amount
=
(
pokok
+
denda
))
cekqris
(
dt_qris
,
request
)
val
=
dt_qris
val
[
'amount'
]
=
(
pokok
+
denda
)
row_qris
=
BJBQRIS
.
create_va
(
val
,
rpc_qris
())
log
.
error
(
row_qris
)
Qqris
=
DBSession
.
query
(
BJBQRIS
)
.
filter
(
BJBQRIS
.
invoice_no
==
data
[
'kd_bayar'
])
.
first
()
dt_qris
[
'qrcode'
]
=
Qqris
.
qrcode
if
row_qris
:
return
dict
(
code
=
0
,
message
=
"Success Create Qris"
,
data
=
dt_qris
)
else
:
return
dict
(
code
=-
1
,
message
=
"Failed Create Qris"
)
@jsonrpc_method
(
method
=
'create_va'
,
endpoint
=
'api-webr'
)
def
create_va
(
request
,
data
):
"""
Digunakan untuk menambahkan create va
:param request:
:param data:
- kd_bayar
- unit_kode
:return:
-
"""
auth_from_rpc
(
request
)
get_mandatory
(
data
,
[
'kd_bayar'
,
'unit_kode'
])
log
.
error
(
'CREATE VA BJBVA'
)
log
.
error
(
data
)
cekVa
=
DBSession
.
query
(
BJBVA
)
.
filter
(
BJBVA
.
invoice_no
==
data
[
'kd_bayar'
])
.
first
()
if
cekVa
and
cekVa
.
expired_date
>
datetime
.
now
():
dt_va
=
dict
(
client_type
=
cekVa
.
client_type
,
product_code
=
cekVa
.
product_code
,
invoice_no
=
cekVa
.
invoice_no
,
description
=
cekVa
.
description
,
customer_name
=
cekVa
.
customer_name
,
customer_email
=
cekVa
.
customer_email
and
cekVa
.
customer_email
or
'-'
,
customer_phone
=
cekVa
.
customer_phone
and
cekVa
.
customer_phone
or
'-'
,
expired_date
=
ymdhms
(
datetime
.
combine
(
cekVa
.
expired_date
,
time
(
23
,
59
,
59
))),
amount
=
cekVa
.
amount
,
va_number
=
cekVa
.
va_number
)
return
dict
(
code
=
0
,
message
=
"Success Create Va"
,
data
=
dt_va
)
row
=
DBSession
.
query
(
ARInvoice
.
id
.
label
(
'id'
),
ARInvoice
.
jumlah
.
label
(
'jumlah'
),
ARInvoice
.
kode
.
label
(
'kode'
),
ARInvoice
.
jatuh_tempo
.
label
(
'jatuh_tempo'
),
func
.
concat
(
ARInvoice
.
no_skrd
,
literal_column
(
"' Tgl:'"
)
,
func
.
to_char
(
ARInvoice
.
tgl_tetap
,
'DD/MM/YYYY'
)
,
literal_column
(
"' Tgl:'"
)
,
func
.
to_char
(
ARInvoice
.
jatuh_tempo
,
'DD/MM/YYYY'
)
,
literal_column
(
"' '"
)
,
ARInvoice
.
keterangan
)
.
label
(
'description'
),
ARInvoice
.
wp_nama
.
label
(
'wp_nama'
),
SubjekPajak
.
email
.
label
(
'subjek_email'
),
ARInvoice
.
status_bayar
.
label
(
'status'
))
.
\
filter
(
func
.
trim
(
ARInvoice
.
kode
)
==
data
[
'kd_bayar'
]
.
strip
(),
func
.
trim
(
ARInvoice
.
unit_kode
)
==
data
[
'unit_kode'
]
.
strip
())
.
\
outerjoin
(
SubjekPajak
,
SubjekPajak
.
id
==
ARInvoice
.
subjek_pajak_id
)
.
first
()
if
not
hasattr
(
row
,
'status'
)
or
row
.
status
!=
0
:
return
dict
(
code
=-
1
,
message
=
"No bayar tidak ditemukan / Sudah dibayar"
)
pokok
,
denda
=
calculate_tagihan
(
dict
(
pokok
=
row
.
jumlah
,
jatuh_tempo
=
row
.
jatuh_tempo
))
if
row
.
jatuh_tempo
<
date
.
today
():
jatuh_tempo
=
ymdhms
(
datetime
.
combine
(
date
.
today
(),
time
(
23
,
59
,
59
)))
else
:
jatuh_tempo
=
ymdhms
(
datetime
.
combine
(
row
.
jatuh_tempo
,
time
(
23
,
59
,
59
)))
expired_date
=
jatuh_tempo
dt_va
=
dict
(
client_type
=
"3"
,
product_code
=
"30"
,
invoice_no
=
row
.
kode
,
description
=
row
.
description
,
customer_name
=
row
.
wp_nama
,
customer_email
=
row
.
subjek_email
and
row
.
subjek_email
or
'-'
,
customer_phone
=
'-'
,
expired_date
=
expired_date
,
amount
=
(
pokok
+
denda
))
cekva
(
dt_va
,
request
)
val
=
dt_va
val
[
'amount'
]
=
(
pokok
+
denda
)
row_va
=
BJBVA
.
create_va
(
val
,
rpc_va
())
log
.
error
(
row_va
)
Qva
=
DBSession
.
query
(
BJBVA
)
.
filter
(
BJBVA
.
invoice_no
==
data
[
'kd_bayar'
])
.
first
()
dt_va
[
'va_number'
]
=
Qva
.
va_number
if
row_va
:
return
dict
(
code
=
0
,
message
=
"Success Create Va"
,
data
=
dt_va
)
else
:
return
dict
(
code
=-
1
,
message
=
"Failed Create Va"
)
\ 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