Commit d1acbfee by taufikyu

Merge branch 'master' of http://git.opensipkd.com/taufik/esipkd

2 parents 242e2bde fd8774fd
...@@ -313,4 +313,4 @@ def clear_null_value(values): ...@@ -313,4 +313,4 @@ def clear_null_value(values):
return values return values
def ymd(tgl): def ymd(tgl):
return tgl.strftime('%Y-%m-%d')
\ No newline at end of file \ No newline at end of file
return tgl.strftime('%Y-%m-%d')
...@@ -52,7 +52,7 @@ class AddSchema(colander.Schema): ...@@ -52,7 +52,7 @@ class AddSchema(colander.Schema):
product_code = colander.SchemaNode( product_code = colander.SchemaNode(
colander.String(), colander.String(),
widget = widget.HiddenWidget(), widget = widget.HiddenWidget(),
default = 30, default = "01", #30,
oid = "product_code", oid = "product_code",
title="") title="")
invoice_no = colander.SchemaNode( invoice_no = colander.SchemaNode(
...@@ -475,4 +475,4 @@ def q_inv(kode): ...@@ -475,4 +475,4 @@ def q_inv(kode):
def calculate_tagihan(values): def calculate_tagihan(values):
pokok = int(values['pokok']) pokok = int(values['pokok'])
denda = hitung_bunga(pokok,values['jatuh_tempo']) denda = hitung_bunga(pokok,values['jatuh_tempo'])
return pokok, denda
\ No newline at end of file \ No newline at end of file
return pokok, denda
...@@ -555,4 +555,4 @@ def q_inv(kode): ...@@ -555,4 +555,4 @@ def q_inv(kode):
def calculate_tagihan(values): def calculate_tagihan(values):
pokok = int(values['pokok']) pokok = int(values['pokok'])
denda = hitung_bunga(pokok,values['jatuh_tempo']) denda = hitung_bunga(pokok,values['jatuh_tempo'])
return pokok, denda
\ No newline at end of file \ No newline at end of file
return pokok, denda
import os
import json
import ast
import uuid
import colander
from datetime import datetime, date, timedelta, time
from sqlalchemy.orm import aliased
from pyramid.view import view_config
from sqlalchemy import not_, func, between, and_, literal_column, case, literal
from pyramid.httpexceptions import HTTPFound
from deform import Form, widget, ValidationFailure
from ..views import ColumnDT, DataTables
from ..models.isipkd import (ARInvoice as ArInvoice, ARSspd as ArPayment, SubjekPajak as Subjek, Unit as Departemen)
from ..models import DBSession
from ..models.bjb_va import BJBVA
from ..tools import (dmy, get_settings, date_from_str,
odt_export, thousand, get_settings, datetime_from_str)
from ..models.rpc import auth_from_rpc
from ..tools import ymd, dmy, ymdhms, dmyhms, dmy_to_date
from pyramid_rpc.jsonrpc import jsonrpc_method
from daftar import hitung_bunga
from arsspd import save as save_payment
SESS_ADD_FAILED = 'Gagal tambah BJBVA'
SESS_EDIT_FAILED = 'Gagal edit BJBVA'
import logging
log = logging.getLogger('BJBVA LOG')
from pyramid.renderers import render_to_response
from sqlalchemy.sql.expression import cast
from sqlalchemy import Integer
def rpc_params():
parameter = dict(
bjbva_url = get_settings()['bjbva_url'] and get_settings()['bjbva_url'].strip('/') or '',
bjbva_user = get_settings()['bjbva_user'] and get_settings()['bjbva_user'].strip() or '',
bjbva_key = get_settings()['bjbva_key'] and get_settings()['bjbva_key'].strip() or ''
)
return parameter
class Item(object):
pass
class AddSchema(colander.Schema):
client_type = colander.SchemaNode(
colander.Integer(),
widget = widget.HiddenWidget(),
default = 3,
oid = "client_type",
title="")
product_code = colander.SchemaNode(
colander.String(),
widget = widget.HiddenWidget(),
default = "9", #30,
oid = "product_code",
title="")
invoice_no = colander.SchemaNode(
colander.String(),
widget=widget.SelectWidget(),
validator=colander.Length(max=16),
oid = "invoice_no",
title="Kode Bayar")
description = colander.SchemaNode(
colander.String(),
widget=widget.TextAreaWidget(rows=6),
validator=colander.Length(max=128),
oid = "description",)
customer_name = colander.SchemaNode(
colander.String(),
validator=colander.Length(max=64),
oid = "customer_name",
title="Customer Name")
customer_email = colander.SchemaNode(
colander.String(),
validator=colander.Length(max=128),
oid = "customer_email",
title="Customer Email")
customer_phone = colander.SchemaNode(
colander.String(),
validator=colander.Length(max=32),
oid = "customer_phone",
title="Customer Phone")
expired_date = colander.SchemaNode(
colander.String(),
widget=widget.TextInputWidget(css_class="input-date"),
oid = "expired_date",
default = ymdhms(datetime.now()),
title="Expired Date")
amount = colander.SchemaNode(
colander.Integer(),
oid = "amount",
title="Amount")
class EditSchema(AddSchema):
invoice_no = colander.SchemaNode(
colander.String(),
validator=colander.Length(max=16),
oid = "invoice_no",
title="Kode Bayar")
billing_type = colander.SchemaNode(
colander.String(),
missing=colander.drop,
validator=colander.Length(max=1),
oid = "billing_type",
title="Billing Type")
va_type = colander.SchemaNode(
colander.String(),
missing=colander.drop,
validator=colander.Length(max=1),
oid = "va_type",
title="VA Type")
va_number = colander.SchemaNode(
colander.String(),
missing=colander.drop,
validator=colander.Length(max=32),
oid = "va_number",
title="VA Number")
currency = colander.SchemaNode(
colander.String(),
missing=colander.drop,
validator=colander.Length(max=32),
oid = "currency",
title="Currency")
customer_id = colander.SchemaNode(
colander.String(),
missing=colander.drop,
validator=colander.Length(max=32),
oid = "customer_id",
title="Customer ID")
status = colander.SchemaNode(
colander.String(),
missing=colander.drop,
oid = "status",
title="Status")
cin = colander.SchemaNode(
colander.String(),
missing=colander.drop,
validator=colander.Length(max=4),
oid = "cin",
title="cin")
response_code = colander.SchemaNode(
colander.String(),
missing=colander.drop,
validator=colander.Length(max=4),
oid = "response_code",
title="response_code")
response_message = colander.SchemaNode(
colander.String(),
missing=colander.drop,
validator=colander.Length(max=128),
oid = "response_message",
title="response_message")
id = colander.SchemaNode(
colander.Integer(),
missing=colander.drop,
oid='id',
widget=widget.HiddenWidget(readonly=True)
)
def get_form(request, class_form):
schema = class_form()
schema.request = request
return Form(schema, buttons=('simpan','batal'))
def route_list(request):
return HTTPFound(location=request.route_url('bjbva'))
def session_failed(request, session_name):
r = dict(form=request.session[session_name])
del request.session[session_name]
return r
def query_id(request):
return DBSession.query(BJBVA).join(ArInvoice, ArInvoice.kode==BJBVA.invoice_no).\
filter(BJBVA.id==request.matchdict['id'])
# ArInvoice.departemen_id==request.session['departemen_id'])
def id_not_found(request):
msg = 'BJBVA ID %s not found.' % request.matchdict['id']
request.session.flash(msg, 'error')
return route_list(request)
def id_paid(request):
msg = 'BJBVA ID %s sudah terbayar.' % request.matchdict['id']
request.session.flash(msg, 'error')
return route_list(request)
def id_expired(request):
msg = 'BJBVA ID %s expired.' % request.matchdict['id']
request.session.flash(msg, 'error')
return route_list(request)
def cekva(values,request):
cekva = DBSession.query(BJBVA).\
filter(BJBVA.invoice_no==values['invoice_no'],BJBVA.expired_date>datetime.now()).first()
if cekva:
msg = 'BJBVA No. VA %s sudah ada.' % cekva.va_number
request.session.flash(msg, 'error')
raise route_list(request)
###########
# List #
###########
class view(object):
def __init__(self, request):
now = datetime.now()
self.req = request
self.ses = self.req.session
self.params = self.req.params
self.awal = 'awal' in self.ses and self.ses['awal'] or dmy(now)
awal = 'awal' in self.params and self.params['awal'] or self.awal
try:
self.dt_awal = dmy_to_date(awal)
self.awal = awal
except:
self.dt_awal = dmy_to_date(self.awal)
self.ses['awal'] = self.awal
self.ses['dt_awal'] = self.dt_awal
self.akhir = 'akhir' in self.ses and self.ses['akhir'] or dmy(now)
akhir = 'akhir' in self.params and self.params['akhir'] or self.akhir
try:
self.dt_akhir = dmy_to_date(akhir)
self.akhir = akhir
except:
self.dt_akhir = dmy_to_date(self.akhir)
self.ses['akhir'] = self.akhir
self.ses['dt_akhir'] = self.dt_akhir
self.tahun = 'tahun' in self.ses and self.ses['tahun'] or datetime.now().strftime('%Y')
self.tahun = 'tahun' in self.params and self.params['tahun'] or self.tahun
self.ses['tahun'] = self.tahun
@view_config(route_name='bjbva', renderer='templates/bjbva/list.pt')
def view_list(self):
return dict()
#########
# Add #
#########
@view_config(route_name='bjbva-add', renderer='templates/bjbva/add-edit.pt', permission='read')
def view_add(self):
request = self.req
form = get_form(request, AddSchema)
if request.POST:
if 'simpan' in request.POST:
controls = request.POST.items()
try:
controls = form.validate(controls)
except ValidationFailure as e:
return dict(form=form)
cekva(dict(controls),request)
val = dict(controls)
inv = q_inv(val['invoice_no']).first()
pokok, denda = calculate_tagihan(dict(pokok = inv.jumlah,jatuh_tempo=inv.jatuh_tempo))
val['amount'] = (pokok+denda)
print ("=======================")
print(val)
row = BJBVA.create_va(val, rpc_params())
if row:
request.session.flash('BJBVA No. %s sudah ditambahkan.' % row.va_number)
else:
request.session.flash('BJBVA gagal ditambahkan.')
return route_list(request)
return route_list(request)
elif SESS_ADD_FAILED in request.session:
return session_failed(request, SESS_ADD_FAILED)
values = {}
form.set_appstruct(values)
return dict(form=form)
########
# Edit #
########
@view_config(route_name='bjbva-edt', renderer='templates/bjbva/add-edit.pt', permission='edit')
def view_edit(self):
request = self.req
form = get_form(request, EditSchema)
row = query_id(request).first()
if not row or int(row.status) == 4:
return id_not_found(request)
if int(row.status) in [1,2]:
return id_paid(request)
if int(row.status) == 3:
return id_expired(request)
if request.POST:
if 'simpan' in request.POST:
controls = request.POST.items()
try:
controls = form.validate(controls)
except ValidationFailure as e:
return dict(form=form)
save = BJBVA.update_va(dict(controls), row, rpc_params())
if save:
request.session.flash('BJBVA No. %s sudah ditambahkan.' % save.va_number)
else:
request.session.flash('BJBVA gagal ditambahkan.')
return route_list(request)
return route_list(request)
elif SESS_EDIT_FAILED in request.session:
return session_failed(request, SESS_EDIT_FAILED)
values = row.to_dict()
values['expired_date'] = ymdhms(values['expired_date'])
inv = q_inv(values['invoice_no']).first()
pokok, denda = calculate_tagihan(dict(pokok = inv.jumlah,jatuh_tempo=inv.jatuh_tempo))
values['amount'] = (pokok+denda)
form.set_appstruct(values)
return dict(form=form)
##########
# Delete #
##########
@view_config(route_name='bjbva-del', renderer='templates/bjbva/delete.pt', permission='delete')
def view_delete(self):
request = self.req
row = query_id(request).first()
if not row or int(row.status) == 4:
return id_not_found(request)
if int(row.status) in [1,2]:
return id_paid(request)
if int(row.status) == 3:
return id_expired(request)
form = Form(colander.Schema(), buttons=('hapus','batal'))
if request.POST:
if 'hapus' in request.POST:
save = BJBVA.cancel_va(row.to_dict(), rpc_params())
if save:
request.session.flash('BJBVA No. %s sudah dihapus.' % save.va_number)
else:
request.session.flash('BJBVA gagal dihapus.')
DBSession.flush()
return route_list(request)
return dict(row=row, form=form.render())
##########
# Action #
##########
@view_config(route_name='bjbva-act', renderer='json', permission='read')
def view_act(self):
req = self.req
params = req.params
url_dict = req.matchdict
if url_dict['act']=='grid':
columns = [
ColumnDT('id'),
ColumnDT('va_number'),
ColumnDT('invoice_no'),
ColumnDT('description'),
ColumnDT('customer_name'),
ColumnDT('amount'),
ColumnDT('client_refnum'),
ColumnDT('expired_date'),
ColumnDT('tgl_bayar'),
ColumnDT('status'),
]
query = DBSession.query(BJBVA.id, BJBVA.va_number, BJBVA.invoice_no, BJBVA.description,
BJBVA.customer_name, BJBVA.amount, BJBVA.client_refnum,
func.to_char(BJBVA.expired_date, 'DD-MM-YYYY HH24:MI:SS').label('expired_date'),
func.to_char(ArPayment.tgl_bayar, 'DD-MM-YYYY HH24:MI:SS').label('tgl_bayar'),
ArInvoice.jumlah.label('jml_bayar'),
case([
(BJBVA.status == '0', literal('Belum Dibayar'))
],
else_=
case([
(BJBVA.status == '1', literal('Dibayar Sebagian'))
],
else_=
case([
(BJBVA.status == '2', literal('Dibayar Penuh'))
],
else_=
case([
(BJBVA.status == '3', literal('Kadaluarsa'))
],
else_=
case([
(BJBVA.status == '4', literal('Disabled'))
],
else_= literal('-')))))).label('status'),
).join(ArInvoice, ArInvoice.kode==BJBVA.invoice_no).\
outerjoin(ArPayment, ArInvoice.id==ArPayment.arinvoice_id).\
filter( #ArInvoice.departemen_id==req.session['departemen_id'],
func.to_char(BJBVA.created,'YYYY') == str(req.session['tahun']))
rowTable = DataTables(req, BJBVA, query, columns)
return rowTable.output_result()
elif url_dict['act'] == 'kodebayar':
term = 'term' in params and params['term'] or ''
q = DBSession.query(ArInvoice). \
filter(ArInvoice.status_bayar == 0,
ArInvoice.kode.ilike('%%%s%%' % term)).\
order_by(ArInvoice.kode)
# filter(ArInvoice.departemen_id==req.session['departemen_id']).\
rows = q.all()
r = []
for k in rows:
d = dict(id=k.id,
value=k.kode,
kode=k.kode,
nama=k.op_nama)
r.append(d)
return r
elif url_dict['act'] == 'detail':
term = 'term' in params and params['term'].strip() or ''
row = q_inv(term).first()
pokok, denda = calculate_tagihan(dict(pokok = row.jumlah,jatuh_tempo=row.jatuh_tempo))
return dict(id=row.id,
value=row.subjek_nama,
description=row.description,
customer_name=row.subjek_nama,
customer_email=row.subjek_email and row.subjek_email or '-',
customer_phone=row.subjek_phone and row.subjek_phone or '-',
expired_date=ymdhms(datetime.combine(date.today(),time(23,59,59))),
amount=(pokok + denda))
elif url_dict['act'] == 'update':
term = 'term' in params and params['term'] or ''
if term:
va = DBSession.query(BJBVA).join(ArInvoice, ArInvoice.kode==BJBVA.invoice_no).\
filter(BJBVA.id==term, ArInvoice.status_bayar==0).first()
if va:
update_va(req, va, rpc_params())
elif url_dict['act'] == 'cron':
vas = DBSession.query(BJBVA).select_from(BJBVA).join(ArInvoice, ArInvoice.kode==BJBVA.invoice_no).\
join(ArPayment, ArPayment.arinvoice_id == ArInvoice.id).\
filter(BJBVA.status=='0',ArInvoice.status_bayar==1).all()
for va in vas:
values = va.to_dict()
BJBVA.cancel_va(values, rpc_params())
@jsonrpc_method(method='callback', endpoint='bjbva-callback')
def callback(request, data):
##
## CALLBACK BODY
## {
## "data": {
## "invoice_no": "230001",
## "va_number": "00170743733",
## "transaction_date": "2021-08-19 10:08:30",
## "transaction_amount": 526829,
## "unpaid": 0,
## "status": 2
## }
## }
##
auth_from_rpc(request)
log.error('REQUEST BJBVA')
log.error(data)
get_va = BJBVA.query().filter(BJBVA.va_number==data['va_number'],
BJBVA.invoice_no==data['invoice_no']).first()
if not get_va:
return render_to_response('json',
dict(response_code='-1',response_message='VA Number not Found'))
get_va.status = 'status' in data and data['status']\
and str(data['status']) or get_va.status
get_va.transaction_amount = 'transaction_amount' in data and data['transaction_amount']\
and data['transaction_amount'] or get_va.amount
get_va.transaction_date = 'transaction_date' in data and data['transaction_date']\
and data['transaction_date'] or datetime.now().strftime('%Y-%m-%d %H:%M:%S')
pay = save_pembayaran(
request,
dict(
invoice_no = get_va.invoice_no,
va_number = get_va.va_number,
transaction_date = get_va.transaction_date,
transaction_amount = get_va.transaction_amount,
status = get_va.status,
amount = get_va.amount
)
)
if not pay:
return render_to_response('json',
dict(response_code='-1',response_message='Failed to update'))
if int(get_va.status) == 2 and not pay.status:
get_va.status = '1'
try:
DBSession.add(get_va)
DBSession.flush()
return render_to_response('json',
dict(response_code='0000',response_message='Success'))
except:
return render_to_response('json',
dict(response_code='-1',response_message='Failed to update'))
def update_va(request,row, parameter):
saved_va = BJBVA.inquiry_va(row, parameter)
if hasattr(saved_va,'status') and saved_va.status and int(saved_va.status) in [1,2]:
save_pembayaran(
request,
dict(
invoice_no = saved_va.invoice_no,
va_number = saved_va.va_number,
transaction_date = ymdhms(saved_va.transaction_date),
transaction_amount = saved_va.transaction_amount,
status = saved_va.status,
)
)
def save_pembayaran(request, values):
if int(values['status']) not in [1,2]:
return
invoice = ArInvoice.query().filter(ArInvoice.kode==values['invoice_no']).first()
if not invoice:
return
values.update(invoice.to_dict())
values['tgl_bayar'] = datetime_from_str(values['transaction_date'])
values['ntb'] = 'BJBVA'
values['bayar'] = int(values['transaction_amount'])
values['tahun'] = values['tgl_bayar'].strftime('%Y')
values['status'] = 2
pay = save_payment(request, values)
return pay
def q_inv(kode):
return 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("' Jatuh Tempo:'") ,
func.to_char(ArInvoice.jatuh_tempo, 'DD/MM/YYYY') ,
literal_column("' '") ,
ArInvoice.keterangan).label('description'),
ArInvoice.wp_nama.label('subjek_nama'),
Subjek.email.label('subjek_email'),
literal_column("'-'").label('subjek_phone')).\
filter(ArInvoice.status_bayar == 0,ArInvoice.kode == kode).\
outerjoin(Subjek, Subjek.id==ArInvoice.subjek_pajak_id)
def calculate_tagihan(values):
pokok = int(values['pokok'])
denda = hitung_bunga(pokok,values['jatuh_tempo'])
return pokok, denda
...@@ -62,9 +62,9 @@ def deferred_tahun(node, kw): ...@@ -62,9 +62,9 @@ def deferred_tahun(node, kw):
return widget.SelectWidget(values=values) return widget.SelectWidget(values=values)
TAHUNS = (('','Pilih Tahun'), TAHUNS = (('','Pilih Tahun'),
('1990','1990'),('1991','1991'),('1992','1992'),('1993','1993'),('1994','1994'), # ('1990','1990'),('1991','1991'),('1992','1992'),('1993','1993'),('1994','1994'),
('1995','1995'),('1996','1996'),('1997','1997'),('1998','1998'),('1999','1999'), # ('1995','1995'),('1996','1996'),('1997','1997'),('1998','1998'),('1999','1999'),
('2000','2000'),('2001','2001'),('2002','2002'),('2003','2003'),('2004','2004'), # ('2000','2000'),('2001','2001'),('2002','2002'),('2003','2003'),('2004','2004'),
('2005','2005'),('2006','2006'),('2007','2007'),('2008','2008'),('2009','2009'), ('2005','2005'),('2006','2006'),('2007','2007'),('2008','2008'),('2009','2009'),
('2010','2010'),('2011','2011'),('2012','2012'),('2013','2013'),('2014','2014'), ('2010','2010'),('2011','2011'),('2012','2012'),('2013','2013'),('2014','2014'),
('2015','2015'),('2016','2016'),('2017','2017'),('2018','2018'),('2019','2019'), ('2015','2015'),('2016','2016'),('2017','2017'),('2018','2018'),('2019','2019'),
...@@ -283,7 +283,7 @@ def view_add(request): ...@@ -283,7 +283,7 @@ def view_add(request):
return session_failed(request, SESS_ADD_FAILED) return session_failed(request, SESS_ADD_FAILED)
return dict(form=form, private_key=private_key, found=found, data_key=data_key) return dict(form=form, private_key=private_key, found=found, data_key=data_key)
def query_id(request): def query_id(request):
engInformix = EngInformix() engInformix = EngInformix()
sql_result1 = """ sql_result1 = """
......
...@@ -19,7 +19,7 @@ SESS_EDIT_FAILED = 'user edit failed' ...@@ -19,7 +19,7 @@ SESS_EDIT_FAILED = 'user edit failed'
####### #######
# Add # # Add #
####### #######
import logging
def form_validator(form, value): def form_validator(form, value):
def err_no_rangka(): def err_no_rangka():
raise colander.Invalid(form, raise colander.Invalid(form,
...@@ -139,7 +139,7 @@ class AddSchema(colander.Schema): ...@@ -139,7 +139,7 @@ class AddSchema(colander.Schema):
colander.String(), colander.String(),
missing=colander.drop, missing=colander.drop,
title = 'Thn. Pembuatan', title = 'Thn. Pembuatan',
oid="th_buatan" oid="th_buatan"
) )
tg_akhir_pjklm = colander.SchemaNode( tg_akhir_pjklm = colander.SchemaNode(
colander.String(), colander.String(),
...@@ -259,7 +259,7 @@ def save(request, values, row=None): ...@@ -259,7 +259,7 @@ def save(request, values, row=None):
tg_pros_daftar, jam_daftar, kd_status, flag_sms) tg_pros_daftar, jam_daftar, kd_status, flag_sms)
VALUES('{no_rangka}', '{no_ktp}', '{email}', '{no_hp}', '{ivr}', VALUES('{no_rangka}', '{no_ktp}', '{email}', '{no_hp}', '{ivr}',
'{c_date}' , '{c_time}', '{kd_status}', '{flag_sms}')""" '{c_date}' , '{c_time}', '{kd_status}', '{flag_sms}')"""
logging.info(sql)
row = engInformix.execute(sql.format( row = engInformix.execute(sql.format(
no_rangka = values['no_rangka'], no_rangka = values['no_rangka'],
no_ktp = values['no_ktp'], no_ktp = values['no_ktp'],
...@@ -270,7 +270,8 @@ def save(request, values, row=None): ...@@ -270,7 +270,8 @@ def save(request, values, row=None):
c_time = values['c_time'], c_time = values['c_time'],
kd_status = 0, kd_status = 0,
flag_sms = 0)) flag_sms = 0))
except: except Exception as e:
logging.info(e)
return return
tm_awal = datetime.now() tm_awal = datetime.now()
...@@ -279,25 +280,24 @@ def save(request, values, row=None): ...@@ -279,25 +280,24 @@ def save(request, values, row=None):
sql_result = """ sql_result = """
SELECT * FROM v_smsdft SELECT * FROM v_smsdft
WHERE no_rangka= '{no_rangka}' and no_ktp= '{no_ktp}' WHERE no_rangka= '{no_rangka}' and no_ktp= '{no_ktp}'
and email = '{email}' and no_hp='{no_hp}' and ivr= '{ivr}' and no_hp='{no_hp}' and ivr= '{ivr}'
and tg_pros_daftar='{c_date}' and jam_daftar='{c_time}' and tg_pros_daftar='{c_date}' and jam_daftar='{c_time}'
and kd_status='{kd_status}' and kd_status='{kd_status}'
""".format( """.format(
no_rangka = values['no_rangka'], no_rangka = values['no_rangka'],
no_ktp = values['no_ktp'], no_ktp = values['no_ktp'],
email = values['email'], # email = values['email'],
no_hp = values['no_hp'], no_hp = values['no_hp'],
ivr = '11', ivr = '11',
c_date = values['c_date'], c_date = values['c_date'],
c_time = values['c_time'], c_time = values['c_time'],
kd_status = 2) kd_status = 2)
trx_timeout = 10 trx_timeout = 20
delay_after_insert = 1 delay_after_insert = 1
awal = time() awal = time()
p = None p = None
msg = None msg = None
while time() - awal < trx_timeout: while time() - awal < trx_timeout:
sleep(delay_after_insert) sleep(delay_after_insert)
try: try:
...@@ -370,6 +370,7 @@ def view_add(request): ...@@ -370,6 +370,7 @@ def view_add(request):
c_now = datetime.now() c_now = datetime.now()
ctrl['c_date'] = c_now.strftime('%m-%d-%Y') ctrl['c_date'] = c_now.strftime('%m-%d-%Y')
ctrl['c_time'] = c_now.strftime('%H:%M:%S') ctrl['c_time'] = c_now.strftime('%H:%M:%S')
ctrl['c_date2'] = c_now
row = save_request(ctrl, request) row = save_request(ctrl, request)
found = 1 found = 1
return HTTPFound(location=request.route_url('pkb-edit',nr=ctrl['no_rangka'], return HTTPFound(location=request.route_url('pkb-edit',nr=ctrl['no_rangka'],
...@@ -391,13 +392,12 @@ def query_id(request): ...@@ -391,13 +392,12 @@ def query_id(request):
sql_result1 = """ sql_result1 = """
SELECT * FROM v_smsdft SELECT * FROM v_smsdft
WHERE no_rangka= '{no_rangka}' and no_ktp= '{no_ktp}' WHERE no_rangka= '{no_rangka}' and no_ktp= '{no_ktp}'
and email = '{email}' and no_hp='{no_hp}' and ivr= '{ivr}' and no_hp='{no_hp}' and ivr= '{ivr}'
and tg_pros_daftar='{c_date}' and jam_daftar='{c_time}' and tg_pros_daftar='{c_date}' and jam_daftar='{c_time}'
and kd_status<>'{kd_status}' and kd_status<>'{kd_status}'
""".format( """.format(
no_rangka = request.matchdict['nr'], no_rangka = request.matchdict['nr'],
no_ktp = request.matchdict['nk'], no_ktp = request.matchdict['nk'],
email = request.matchdict['em'],
no_hp = request.matchdict['nh'], no_hp = request.matchdict['nh'],
c_date = request.matchdict['cd'], c_date = request.matchdict['cd'],
c_time = request.matchdict['ct'], c_time = request.matchdict['ct'],
...@@ -446,6 +446,7 @@ def view_edit(request): ...@@ -446,6 +446,7 @@ def view_edit(request):
c_now = datetime.now() c_now = datetime.now()
ctrl['c_date'] = c_now.strftime('%m-%d-%Y') ctrl['c_date'] = c_now.strftime('%m-%d-%Y')
ctrl['c_time'] = c_now.strftime('%H:%M:%S') ctrl['c_time'] = c_now.strftime('%H:%M:%S')
ctrl['c_date2'] = c_now
row = save_request(ctrl, request) row = save_request(ctrl, request)
found = 1 found = 1
print '----------------Row Hasil Select--------------------',row print '----------------Row Hasil Select--------------------',row
......
...@@ -192,9 +192,16 @@ class ViewLaporan(BaseViews): ...@@ -192,9 +192,16 @@ class ViewLaporan(BaseViews):
def reports_act(self): def reports_act(self):
global awal, akhir, tgl_awal, tgl_akhir,u,unit_kd,unit_nm,unit_al,now,thn,thun,bulan,bulan2 global awal, akhir, tgl_awal, tgl_akhir,u,unit_kd,unit_nm,unit_al,now,thn,thun,bulan,bulan2
req = self.request req = self.request
params = req.params params = req.params
url_dict = req.matchdict url_dict = req.matchdict
u = req.user.id if not req.user:
req_user = False
req_user_id = None
else:
req_user = True
req_user_id = req.user.id
u = req_user_id # req.user.id
now = datetime.now().strftime('%Y-%m-%d') now = datetime.now().strftime('%Y-%m-%d')
thn = datetime.now().strftime('%Y') thn = datetime.now().strftime('%Y')
id = 'id' in params and params['id'] and int(params['id']) or 0 id = 'id' in params and params['id'] and int(params['id']) or 0
...@@ -212,40 +219,47 @@ class ViewLaporan(BaseViews): ...@@ -212,40 +219,47 @@ class ViewLaporan(BaseViews):
bulan2 = int(bulan)-1 bulan2 = int(bulan)-1
sptpd_id = 'sptpd_id' in params and params['sptpd_id'] and str(params['sptpd_id']) or '' sptpd_id = 'sptpd_id' in params and params['sptpd_id'] and str(params['sptpd_id']) or ''
if group_in(req, 'bendahara'): if req_user == True:
unit_id = DBSession.query(UserUnit.unit_id
if group_in(req, 'bendahara'):
unit_id = DBSession.query(UserUnit.unit_id
).filter(UserUnit.user_id==u ).filter(UserUnit.user_id==u
).first() ).first()
unit_id = '%s' % unit_id unit_id = '%s' % unit_id
unit_id = int(unit_id) unit_id = int(unit_id)
unit = DBSession.query(Unit.kode.label('kd'), unit = DBSession.query(Unit.kode.label('kd'),
Unit.nama.label('nm'), Unit.nama.label('nm'),
Unit.alamat.label('al') Unit.alamat.label('al')
).filter(UserUnit.unit_id==unit_id, ).filter(UserUnit.unit_id==unit_id,
Unit.id==unit_id Unit.id==unit_id
).first() ).first()
#unit_kd = '%s' % unit.kd #unit_kd = '%s' % unit.kd
unit_kd = strip('%s' % unit.kd) unit_kd = strip('%s' % unit.kd)
unit_nm = '%s' % unit.nm unit_nm = '%s' % unit.nm
unit_al = '%s' % unit.al unit_al = '%s' % unit.al
elif group_in(req, 'wp'): elif group_in(req, 'wp'):
unit_id = DBSession.query(UserUnit.unit_id unit_id = DBSession.query(UserUnit.unit_id
).filter(UserUnit.user_id==u ).filter(UserUnit.user_id==u
).first() ).first()
unit_id = '%s' % unit_id unit_id = '%s' % unit_id
unit_id = int(unit_id) unit_id = int(unit_id)
unit = DBSession.query(Unit.kode.label('kd'), unit = DBSession.query(Unit.kode.label('kd'),
Unit.nama.label('nm'), Unit.nama.label('nm'),
Unit.alamat.label('al') Unit.alamat.label('al')
).filter(UserUnit.unit_id==unit_id, ).filter(UserUnit.unit_id==unit_id,
Unit.id==unit_id Unit.id==unit_id
).first() ).first()
unit_kd = '%s' % unit.kd unit_kd = '%s' % unit.kd
unit_nm = '%s' % unit.nm unit_nm = '%s' % unit.nm
unit_al = '%s' % unit.al unit_al = '%s' % unit.al
else:
unit_kd = "1.20.05."
unit_nm = "BADAN PENDAPATAN DAERAH"
unit_al = "Jl. Soekarno Hatta, No. 528, Bandung"
else: else:
unit_kd = "1.20.05." unit_kd = "1.20.05."
...@@ -865,7 +879,7 @@ class ViewLaporan(BaseViews): ...@@ -865,7 +879,7 @@ class ViewLaporan(BaseViews):
elif url_dict['act']=='Laporan_7' : elif url_dict['act']=='Laporan_7' :
query = DBSession.query(ARSspd.bayar.label('bayar'), query = DBSession.query(ARSspd.bayar.label('bayar'),
ARSspd.bunga.label('bunga'), (ARInvoice.denda+ARSspd.bunga).label('bunga'),
#ARInvoice.denda.label('bunga'), #ARInvoice.denda.label('bunga'),
ARSspd.tgl_bayar.label('tgl'), ARSspd.tgl_bayar.label('tgl'),
ARInvoice.kode.label('kd'), ARInvoice.kode.label('kd'),
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
${structure:field.serialize()} ${structure:field.serialize()}
<script> <script>
$(document).ready(function () { $(document).ready(function () {
//Membatasi 4 Digit & Membatasi Huruf //Membatasi 4 Digit & Membatasi Huruf
$('#m_pjk_thn').keyup(function(){ $('#m_pjk_thn').keyup(function(){
var m_pjk_thn = this.value.length; var m_pjk_thn = this.value.length;
if(!/^[0-9]+$/.test(this.value)){ if(!/^[0-9]+$/.test(this.value)){
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
</div> </div>
<!--npa --> <!--npa -->
<label for="npa" class="control-label col-md-3" id="req-npa"> <label for="npa" class="control-label col-md-3" id="req-npa">
NPS </label> NPA </label>
<div class="col-md-3" tal:define="field form['npa']" id="item-${field.oid}"> <div class="col-md-3" tal:define="field form['npa']" id="item-${field.oid}">
${structure:field.serialize()} ${structure:field.serialize()}
<script> <script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!