Commit cf6ba005 by taufikyu

penambahan menu kode bayar (ws) dan revisi laporan skrd

1 parent 4c93baf0
No preview for this file type
No preview for this file type
...@@ -235,4 +235,6 @@ id,kode,nama,path,factory,perm_name,disabled,created,updated,create_uid ...@@ -235,4 +235,6 @@ id,kode,nama,path,factory,perm_name,disabled,created,updated,create_uid
250,"anggaran-edit","Edit Anggaran","/anggaran/{id}/edit",,"edit",0,"2015-03-08 16:45:45",,1 250,"anggaran-edit","Edit Anggaran","/anggaran/{id}/edit",,"edit",0,"2015-03-08 16:45:45",,1
251,"anggaran-delete","Hapus Anggaran","/anggaran/{id}/delete",,"delete",0,"2015-03-08 16:45:45",,1 251,"anggaran-delete","Hapus Anggaran","/anggaran/{id}/delete",,"delete",0,"2015-03-08 16:45:45",,1
252,"anggaran-csv","CSV Anggaran","/anggaran/{csv}/csv",,"read",0,"2015-03-08 16:45:45",,1 252,"anggaran-csv","CSV Anggaran","/anggaran/{csv}/csv",,"read",0,"2015-03-08 16:45:45",,1
253,"anggaran-pdf","PDF Anggaran","/anggaran/{pdf}/pdf",,"read",0,"2015-03-08 16:45:45",,1
\ No newline at end of file \ No newline at end of file
253,"anggaran-pdf","PDF Anggaran","/anggaran/{pdf}/pdf",,"read",0,"2015-03-08 16:45:45",,1
254,"arinvoice-ws","Invoice WS","/arinvoicews",,"read",0,"2020-09-18 16:45:45",,1
255,"arinvoice-ws-act","Invoice WS Act","/arinvoicews/{act}/act",,"read",0,"2020-09-18 16:45:45",,1
\ No newline at end of file \ No newline at end of file
...@@ -43,49 +43,72 @@ from pyramid.view import notfound_view_config ...@@ -43,49 +43,72 @@ from pyramid.view import notfound_view_config
######## ########
@view_config(route_name='home', renderer='templates/home.pt') @view_config(route_name='home', renderer='templates/home.pt')
def view_home(request): def view_home(request):
if 'date' in request.params and request.params['date']: statusadmin = False
request.session['date'] = request.params['date'].strip() if hasattr(request.user,'groups'):
if 'date' in request.session and request.session['date']: for g in request.user.groups:
now = date_from_str(request.session['date']) if g.group_name=='admin':
else: statusadmin = True
now = date.today() break
request.session['date'] = dmy(now) if statusadmin == True:
if 'unit' in request.params: if 'date' in request.params and request.params['date']:
request.session['unit'] = request.params['unit'].strip() request.session['date'] = request.params['date'].strip()
dates = dict( if 'date' in request.session and request.session['date']:
year = now.year, now = date_from_str(request.session['date'])
month = now.month, else:
week = int(now.strftime('%W')), now = date.today()
day = now, request.session['date'] = dmy(now)
) if 'unit' in request.params:
opd_ls = Unit.query().order_by(Unit.kode).all() request.session['unit'] = request.params['unit'].strip()
data_dashboard = dict( dates = dict(
tabular = dict( year = now.year,
tahun = dict(q=0,n=0), month = now.month,
bulan = dict(q=0,n=0), week = int(now.strftime('%W')),
minggu = dict(q=0,n=0), day = now,
hari = dict(q=0,n=0),
),
chart = dict(
q = [0,0,0,0,0,0,0,0,0,0,0,0],
n = [0,0,0,0,0,0,0,0,0,0,0,0],
),
opd= [],
sopd10= [],
sopd= [],
) )
payments = DBSession.query( opd_ls = Unit.query().order_by(Unit.kode).all()
ARSspd.tgl_bayar.label('tanggal'), data_dashboard = dict(
ARSspd.bayar.label('jumlah'), tabular = dict(
Unit.kode.label('kode'), tahun = dict(q=0,n=0),
Unit.nama.label('nama'), bulan = dict(q=0,n=0),
).join(ARInvoice, ARInvoice.id == ARSspd.arinvoice_id).\ minggu = dict(q=0,n=0),
join(Unit, func.trim(Unit.kode) == func.trim(ARInvoice.unit_kode)).\ hari = dict(q=0,n=0),
filter(ARSspd.tahun_id==dates['year']).order_by(ARInvoice.unit_kode) ),
payments = payments.all() chart = dict(
for p in payments: q = [0,0,0,0,0,0,0,0,0,0,0,0],
if 'unit' in request.session and request.session['unit']: n = [0,0,0,0,0,0,0,0,0,0,0,0],
if p.kode.strip().startswith(request.session['unit']): ),
opd= [],
sopd10= [],
sopd= [],
)
payments = DBSession.query(
ARSspd.tgl_bayar.label('tanggal'),
ARSspd.bayar.label('jumlah'),
Unit.kode.label('kode'),
Unit.nama.label('nama'),
).join(ARInvoice, ARInvoice.id == ARSspd.arinvoice_id).\
join(Unit, func.trim(Unit.kode) == func.trim(ARInvoice.unit_kode)).\
filter(ARSspd.tahun_id==dates['year']).order_by(ARInvoice.unit_kode)
payments = payments.all()
for p in payments:
if 'unit' in request.session and request.session['unit']:
if p.kode.strip().startswith(request.session['unit']):
data_dashboard['tabular']['tahun']['q'] += 1
data_dashboard['tabular']['tahun']['n'] += int(p.jumlah)
if p.tanggal.month == dates['month']:
data_dashboard['tabular']['bulan']['q'] += 1
data_dashboard['tabular']['bulan']['n'] += int(p.jumlah)
if int(p.tanggal.strftime('%W')) == dates['week']:
data_dashboard['tabular']['minggu']['q'] += 1
data_dashboard['tabular']['minggu']['n'] += int(p.jumlah)
if p.tanggal.date() == dates['day']:
data_dashboard['tabular']['hari']['q'] += 1
data_dashboard['tabular']['hari']['n'] += int(p.jumlah)
for x in range(12):
if p.tanggal.month == x+1:
data_dashboard['chart']['q'][x] += int(1)
data_dashboard['chart']['n'][x] += int(p.jumlah)
elif not 'unit' in request.session or not request.session['unit']:
data_dashboard['tabular']['tahun']['q'] += 1 data_dashboard['tabular']['tahun']['q'] += 1
data_dashboard['tabular']['tahun']['n'] += int(p.jumlah) data_dashboard['tabular']['tahun']['n'] += int(p.jumlah)
if p.tanggal.month == dates['month']: if p.tanggal.month == dates['month']:
...@@ -101,50 +124,36 @@ def view_home(request): ...@@ -101,50 +124,36 @@ def view_home(request):
if p.tanggal.month == x+1: if p.tanggal.month == x+1:
data_dashboard['chart']['q'][x] += int(1) data_dashboard['chart']['q'][x] += int(1)
data_dashboard['chart']['n'][x] += int(p.jumlah) data_dashboard['chart']['n'][x] += int(p.jumlah)
elif not 'unit' in request.session or not request.session['unit']:
data_dashboard['tabular']['tahun']['q'] += 1 tanggal_berjalan = datetime.now()
data_dashboard['tabular']['tahun']['n'] += int(p.jumlah) tahun_berjalan = tanggal_berjalan.year
if p.tanggal.month == dates['month']: opd = DBSession.query(
data_dashboard['tabular']['bulan']['q'] += 1 ARSspd.tgl_bayar.label('tanggal'),
data_dashboard['tabular']['bulan']['n'] += int(p.jumlah) ARSspd.bayar.label('jumlah'),
if int(p.tanggal.strftime('%W')) == dates['week']: Unit.kode.label('kode'),
data_dashboard['tabular']['minggu']['q'] += 1 Unit.nama.label('nama'),
data_dashboard['tabular']['minggu']['n'] += int(p.jumlah) ).join(ARInvoice, ARInvoice.id == ARSspd.arinvoice_id).\
if p.tanggal.date() == dates['day']: join(Unit, func.trim(Unit.kode) == func.trim(ARInvoice.unit_kode)).\
data_dashboard['tabular']['hari']['q'] += 1 filter(ARSspd.tahun_id==tahun_berjalan).order_by(ARInvoice.unit_kode).all()
data_dashboard['tabular']['hari']['n'] += int(p.jumlah) prev_opd = ''
for x in range(12): i = -1
if p.tanggal.month == x+1: for o in opd:
data_dashboard['chart']['q'][x] += int(1) ##OPD SESUAI TANGGAL
data_dashboard['chart']['n'][x] += int(p.jumlah) if prev_opd != o.kode:
i += 1
tanggal_berjalan = datetime.now() data_dashboard['opd'].append(dict(kode=o.kode.strip(),unit=o.nama.strip(),jumlah=0))
tahun_berjalan = tanggal_berjalan.year prev_opd = o.kode
opd = DBSession.query( data_dashboard['opd'][i]['jumlah']+=int(o.jumlah)
ARSspd.tgl_bayar.label('tanggal'), sort_opd = sorted(data_dashboard['opd'], key = lambda i: (i['jumlah']), reverse=True)
ARSspd.bayar.label('jumlah'), i = -1
Unit.kode.label('kode'), for sopd in sort_opd:
Unit.nama.label('nama'),
).join(ARInvoice, ARInvoice.id == ARSspd.arinvoice_id).\
join(Unit, func.trim(Unit.kode) == func.trim(ARInvoice.unit_kode)).\
filter(ARSspd.tahun_id==tahun_berjalan).order_by(ARInvoice.unit_kode).all()
prev_opd = ''
i = -1
for o in opd:
##OPD SESUAI TANGGAL
if prev_opd != o.kode:
i += 1 i += 1
data_dashboard['opd'].append(dict(kode=o.kode.strip(),unit=o.nama.strip(),jumlah=0)) if i < 10:
prev_opd = o.kode data_dashboard['sopd10'].append(dict(peringkat=i+1, kode=sopd['kode'], unit=sopd['unit'], nominal=sopd['jumlah']))
data_dashboard['opd'][i]['jumlah']+=int(o.jumlah) data_dashboard['sopd'].append(dict(peringkat=i+1, kode=sopd['kode'], unit=sopd['unit'], nominal=sopd['jumlah']))
sort_opd = sorted(data_dashboard['opd'], key = lambda i: (i['jumlah']), reverse=True) return dict(project='esipkd', dates=dates, data = data_dashboard, opds=opd_ls, statusadmin=statusadmin)
i = -1 else:
for sopd in sort_opd: return dict(project='esipkd', statusadmin=statusadmin)
i += 1
if i < 10:
data_dashboard['sopd10'].append(dict(peringkat=i+1, kode=sopd['kode'], unit=sopd['unit'], nominal=sopd['jumlah']))
data_dashboard['sopd'].append(dict(peringkat=i+1, kode=sopd['kode'], unit=sopd['unit'], nominal=sopd['jumlah']))
return dict(project='esipkd', dates=dates, data = data_dashboard, opds=opd_ls)
######### #########
......
...@@ -24,7 +24,8 @@ from ..tools import ( ...@@ -24,7 +24,8 @@ from ..tools import (
odt_export, odt_export,
terbilang, terbilang,
thousand, thousand,
dmy dmy,
BULANS
) )
from ..models import DBSession from ..models import DBSession
from ..models.isipkd import( from ..models.isipkd import(
...@@ -816,15 +817,20 @@ def view_pdf(request): ...@@ -816,15 +817,20 @@ def view_pdf(request):
item.wp_alamat = (row.wp_alamat_2 and row.wp_alamat_2 != '-') and ('{} {}'.format(row.wp_alamat_1, row.wp_alamat_2)) or row.wp_alamat_1 item.wp_alamat = (row.wp_alamat_2 and row.wp_alamat_2 != '-') and ('{} {}'.format(row.wp_alamat_1, row.wp_alamat_2)) or row.wp_alamat_1
item.wp_kode = row.wp_kode item.wp_kode = row.wp_kode
item.rek_nama = row.rek_nama item.rek_nama = row.rek_nama
item.periode_1 = row.periode_1 item.rek_kode = row.rek_kode
item.periode_2 = row.periode_2 item.periode_1 = dmy(row.periode_1)
item.periode_2 = dmy(row.periode_2)
item.kodebayar = row.kode item.kodebayar = row.kode
item.no_skrd = row.no_skrd item.no_skrd = row.no_skrd
item.tahunskrd = row.tahun_id item.tahunskrd = row.tahun_id
BULAN = dict(BULANS)
bulan = row.tgl_tetap.strftime('%m')
item.tgl_tetap = '{} {},'.format(row.tgl_tetap.strftime('%d'),BULAN[bulan])
item.tahun_tetap = row.tgl_tetap.year
item.tahun = datetime.now().year item.tahun = datetime.now().year
item.jumlah = thousand(row.jumlah) item.jumlah = thousand(row.jumlah)
item.jatuh_tempo = dmy(row.jatuh_tempo) item.jatuh_tempo = dmy(row.jatuh_tempo)
item.terbilang = terbilang(row.jumlah) item.terbilang = terbilang(row.jumlah) + ' Rupiah'
data = {} data = {}
data['item'] = item data['item'] = item
......
import sys
import re
import logging
import os
from email.utils import parseaddr
from sqlalchemy import not_, func, or_, desc
from datetime import datetime
from time import gmtime, strftime, strptime
from pyramid.view import (
view_config,
)
from pyramid.httpexceptions import (
HTTPFound,
)
import colander
from deform import (
Form,
widget,
ValidationFailure,
)
from ..tools import (
_DTnumberformat,
multi_dict_values,
odt_export,
terbilang,
thousand,
dmy,
BULANS,
csv_response
)
from ..models import DBSession
from ..models.isipkd import(
Pegawai, ObjekPajak, SubjekPajak, ARInvoice,
Unit, UserUnit,Wilayah, Pajak, Rekening,
ARSts, ARStsItem, ARSspd, ARTbp
)
from ..models.rpc import DepartemenRoute
from datatables import (
ColumnDT, DataTables)
from ..security import group_finder,group_in
from daftar import (STATUS, deferred_status,
daftar_subjekpajak, deferred_subjekpajak,
daftar_objekpajak, deferred_objekpajak,
daftar_wilayah, deferred_wilayah,
daftar_unit, deferred_unit,
daftar_pajak, deferred_pajak,
auto_op_nm, auto_unit_nm, auto_wp_nm, auto_wp_nm3
)
SESS_ADD_FAILED = 'Gagal tambah Tagihan'
SESS_EDIT_FAILED = 'Gagal edit Tagihan'
log = logging.getLogger(__name__)
########
# List #
########
@view_config(route_name='arinvoicews', renderer='templates/arinvoice/list_ws.pt',
permission='read')
def view_list(request):
awal = 'awal' in request.GET and request.GET['awal'] or datetime.now().strftime('%Y-%m-%d')
akhir = 'akhir' in request.GET and request.GET['akhir'] or datetime.now().strftime('%Y-%m-%d')
return dict(rows={"awal":awal, "akhir":akhir})
#######
# Add #
#######
def form_validator(form, value):
def err_kode():
raise colander.Invalid(form,
'Kode invoice %s sudah digunakan oleh ID %d' % (
value['kode'], found.id))
def err_name():
raise colander.Invalid(form,
'Uraian %s sudah digunakan oleh ID %d' % (
value['nama'], found.id))
if 'id' in form.request.matchdict:
uid = form.request.matchdict['id']
q = DBSession.query(ARInvoice).filter_by(id=uid)
r = q.first()
else:
r = None
class AddSchema(colander.Schema):
moneywidget = widget.MoneyInputWidget(
size=20, options={'allowZero':True,
'precision':0
})
unit_id = colander.SchemaNode(
colander.Integer(),
widget=widget.HiddenWidget(),
oid="unit_id",
title="OPD",
)
unit_nm = colander.SchemaNode(
colander.String(),
title="OPD",
oid="unit_nm"
)
subjek_pajak_id = colander.SchemaNode(
colander.Integer(),
widget=widget.HiddenWidget(),
title="Penyetor",
oid = "subjek_pajak_id"
)
subjek_pajak_nm = colander.SchemaNode(
colander.String(),
widget=auto_wp_nm3,
title="Penyetor",
oid = "subjek_pajak_nm"
)
subjek_pajak_us = colander.SchemaNode(
colander.Integer(),
widget=widget.HiddenWidget(),
oid = "subjek_pajak_us"
)
subjek_pajak_un = colander.SchemaNode(
colander.Integer(),
widget=widget.HiddenWidget(),
oid = "subjek_pajak_un"
)
wp_nama = colander.SchemaNode(
colander.String(),
#widget=auto_wp_nm3,
title="Nama Lainnya",
oid = "wp_nama"
)
wp_alamat_1 = colander.SchemaNode(
colander.String(),
#widget=auto_wp_nm3,
title="Alamat",
oid = "wp_alamat_1"
)
objek_pajak_id = colander.SchemaNode(
colander.Integer(),
title="Objek",
widget=widget.HiddenWidget(),
oid = "objek_pajak_id"
)
objek_pajak_nm = colander.SchemaNode(
colander.String(),
widget=auto_op_nm,
title="Objek",
oid = "objek_pajak_nm"
)
kode = colander.SchemaNode(
colander.String(),
title="Kode Bayar",
missing = colander.drop,
)
periode_1 = colander.SchemaNode(
colander.Date(),
title="Periode 1",
widget = widget.DateInputWidget()
)
periode_2 = colander.SchemaNode(
colander.Date(),
title="Periode 2"
)
tgl_tetap = colander.SchemaNode(
colander.Date(),
oid = "tgl_tetap"
)
jatuh_tempo = colander.SchemaNode(
colander.Date(),
oid = 'jatuh_tempo',
)
dasar = colander.SchemaNode(
colander.Integer(),
default = 0,
widget = moneywidget,
oid = "dasar"
)
tarif = colander.SchemaNode(
colander.Integer(),
default = 0,
widget = moneywidget,
oid = "tarif",
title="Tarif (%)",
missing=colander.drop
)
pokok = colander.SchemaNode(
colander.Integer(),
default = 0,
widget = moneywidget,
missing=colander.drop,
oid = "pokok"
)
denda = colander.SchemaNode(
colander.Integer(),
default = 0,
widget = moneywidget,
oid = "denda"
)
bunga = colander.SchemaNode(
colander.Integer(),
default = 0,
widget = moneywidget,
oid = "bunga"
)
jumlah = colander.SchemaNode(
colander.Integer(),
default = 0,
widget = moneywidget,
missing=colander.drop,
oid = "jumlah"
)
no_skrd = colander.SchemaNode(
colander.String(),
oid = "no_skrd"
)
class EditSchema(AddSchema):
id = colander.SchemaNode(colander.Integer(),
missing=colander.drop,
widget=widget.HiddenWidget(readonly=True)
)
def get_form(request, class_form):
schema = class_form(validator=form_validator)
schema = schema.bind(daftar_status=STATUS,
daftar_subjekpajak=daftar_subjekpajak(),
daftar_unit=daftar_unit(),
daftar_objekpajak=daftar_objekpajak(),
)
schema.request = request
return Form(schema, buttons=('simpan','batal'))
def save(request, values, row=None):
log.debug('*** values {}'.format(values))
if not row:
row = ARInvoice()
row.create_date = datetime.now()
row.create_uid = request.user.id
row.from_dict(values)
#row.update_date = datetime.now()
row.update_uid = request.user.id
row.dasar = re.sub("[^0-9]", "", row.dasar)
row.tarif = re.sub("[^0-9]", "", row.tarif)
row.pokok = re.sub("[^0-9]", "", row.pokok)
row.denda = re.sub("[^0-9]", "", row.denda)
row.bunga = re.sub("[^0-9]", "", row.bunga)
row.jumlah = re.sub("[^0-9]", "", row.jumlah)
if not row.tahun_id:
row.tahun_id = datetime.now().strftime('%Y')
unit = Unit.get_by_id(row.unit_id)
row.unit_kd = unit.kode
row.unit_nm = unit.nama
ref = Unit.get_by_id(row.unit_id)
row.unit_kode = ref.kode
row.unit_nama = ref.nama
ref = SubjekPajak.get_by_id(row.subjek_pajak_id)
row.wp_kode = ref.kode
#row.wp_nama = ref.nama
#row.wp_alamat_1 = ref.alamat_1
row.wp_alamat_2 = ref.alamat_2
ref = ObjekPajak.get_by_id(row.objek_pajak_id)
row.op_kode = ref.kode
row.op_nama = ref.nama
row.op_alamat_1 = ref.alamat_1
row.op_alamat_2 = ref.alamat_2
row.wilayah_id = ref.wilayah_id
row.rekening_id = ref.pajaks.rekening_id
row.rek_kode = ref.pajaks.rekenings.kode
row.rek_nama = ref.pajaks.rekenings.nama
row.denda_rekening_id = ref.pajaks.denda_rekening_id
ref = Wilayah.get_by_id(row.wilayah_id)
row.wilayah_kode = ref.kode
#-- Perubahan pada No bayar dan filter tanggal 13-062017 --#
tgl_tetap = values['tgl_tetap']
prefix = '21'
tgl_tetap_new = datetime.strptime(values['tgl_tetap'], '%Y-%m-%d').date()
tanggal = tgl_tetap_new.day
bulan = tgl_tetap_new.month
tahun = tgl_tetap_new.strftime('%y')
if not row.kode and not row.no_id:
invoice_no = DBSession.query(func.max(ARInvoice.no_id)).\
filter(#ARInvoice.tahun_id==row.tahun_id,
ARInvoice.wilayah_id==row.wilayah_id,
ARInvoice.tgl_tetap==tgl_tetap_new,
func.substr(ARInvoice.kode,1,2)=='21').scalar()
print "--------- Invoice No ---------- ",invoice_no
print "--tahun--",row.tahun_id
print "--wilayah--",row.wilayah_id
print "--tanggal--",tgl_tetap_new
if not invoice_no:
row.no_id = 1
else:
row.no_id = invoice_no+1
row.kode = "".join([prefix, re.sub("[^0-9]", "", row.wilayah_kode),
str(tanggal).rjust(2,'0'),
str(bulan).rjust(2,'0'),
str(tahun).rjust(2,'0'),
str(row.no_id).rjust(4,'0')])
row.owner_id = request.user.id
DBSession.add(row)
DBSession.flush()
return row
def save_request(values, request, row=None):
if 'id' in request.matchdict:
values['id'] = request.matchdict['id']
row = save(request, values, row)
request.session.flash('No Bayar %s sudah disimpan.' % row.kode)
def route_list(request):
return HTTPFound(location=request.route_url('arinvoiceb'))
def session_failed(request, session_name):
try:
session_name.set_appstruct(request.session[SESS_ADD_FAILED])
except:
pass
r = dict(form=session_name)
del request.session[SESS_ADD_FAILED]
return r
#@view_config(route_name='arinvoiceb-add', renderer='templates/arinvoice/add_b.pt',
# permission='add')
#def view_add(request):
# form = get_form(request, AddSchema)
# values = {}
#
# u = request.user.id
# if u != 1 :
# a = DBSession.query(UserUnit.unit_id).filter(UserUnit.user_id==u).first()
# b = '%s' % a
# c = int(b)
# values['unit_id'] = c
# unit = DBSession.query(Unit.nama.label('unm')
# ).filter(Unit.id==c,
# ).first()
# values['unit_nm'] = unit.unm
#
# values['tgl_tetap'] = datetime.now()
# values['jatuh_tempo'] = datetime.now()
# values['periode_1'] = datetime.now()
# values['periode_2'] = datetime.now()
# form.set_appstruct(values)
# if request.POST:
# if 'simpan' in request.POST:
# controls = request.POST.items()
# #log.debug('*** request.POST.items {}'.format(controls))
# controls_dicted = multi_dict_values(controls)
#
# # Cek Kode
# if not controls_dicted['kode']=='':
# a = form.validate(controls)
# b = a['kode']
# c = "%s" % b
# cek = DBSession.query(ARInvoice).filter(ARInvoice.kode==c).first()
# if cek :
# request.session.flash('Kode Bayar %s sudah digunakan.' % b, 'error')
# return HTTPFound(location=request.route_url('arinvoiceb-add'))
#
# try:
# c = form.validate(controls)
# except ValidationFailure, e:
# return dict(form=form)
# save_request(controls_dicted, request)
# return route_list(request)
# elif SESS_ADD_FAILED in request.session:
# return session_failed(request, form)
# return dict(form=form, is_unit=0, is_sp=0)
########
# Edit #
########
def query_id(request):
return DBSession.query(ARInvoice).filter(ARInvoice.id==request.matchdict['id'])
def id_not_found(request):
msg = 'No Bayar ID %s tidak ditemukan atau sudah dibayar.' % request.matchdict['id']
request.session.flash(msg, 'error')
return route_list(request)
#@view_config(route_name='arinvoiceb-edit', renderer='templates/arinvoice/add_b.pt',
# permission='edit')
#def view_edit(request):
# row = query_id(request).first()
# uid = row.id
# kode = row.kode
#
# if not row:
# return id_not_found(request)
# if row.status_bayar:
# request.session.flash('Data sudah masuk di Penerimaan', 'error')
# return route_list(request)
# if row.is_sts:
# request.session.flash('Data sudah masuk di STS', 'error')
# return route_list(request)
# if row.is_tbp:
# request.session.flash('Data hasil Posting TBPB tidak bisa di edit', 'error')
# return route_list(request)
#
# form = get_form(request, EditSchema)
# if request.POST:
# if 'simpan' in request.POST:
# controls = request.POST.items()
# controls_dicted = multi_dict_values(controls)
# try:
# c = form.validate(controls)
# except ValidationFailure, e:
# return dict(form=form)
# return HTTPFound(location=request.route_url('arinvoiceb-edit',
# id=row.id))
# #save_request(dict(controls), request, row)
# save_request(controls_dicted, request, row)
# return route_list(request)
# elif SESS_EDIT_FAILED in request.session:
# return session_failed(request, SESS_EDIT_FAILED)
# values = row.to_dict()
# values['objek_pajak_nm'] = row.objekpajaks and row.objekpajaks.nama or row.op_nama
# values['subjek_pajak_nm'] = row.subjekpajaks and row.subjekpajaks.nama or row.wp_nama
# values['objek_pajak_id'] = row.objek_pajak_id or 0
# values['subjek_pajak_id'] = row.subjek_pajak_id or 0
# values['subjek_pajak_us'] = row.subjekpajaks and row.subjekpajaks.user_id or 0
# values['subjek_pajak_un'] = row.subjekpajaks and row.subjekpajaks.unit_id or 0
# values['unit_nm'] = row.units.nama
# form.set_appstruct(values)
# return dict(form=form)
###########
# Posting #
###########
def save_request2(request, row1=None):
row1 = ARInvoice()
return row1
def save_request3(request, row2=None):
row2 = ARSts()
return row2
#@view_config(route_name='arinvoiceb-posting', renderer='templates/arinvoice/posting.pt',
# permission='read')
#def view_posting(request):
# awal = 'awal' in request.GET and request.GET['awal'] or datetime.now().strftime('%Y-%m-%d')
# akhir = 'akhir' in request.GET and request.GET['akhir'] or datetime.now().strftime('%Y-%m-%d')
#
# form = Form(colander.Schema(),buttons=('posting','batal'))
# if request.POST:
# if 'posting' in request.POST:
# u = request.user.id
# rows1 = DBSession.query(ARInvoice.unit_id.label('un_id'),
# ARInvoice.unit_kode.label('un_kd'),
# ARInvoice.unit_nama.label('un_nm')
# ).filter(ARInvoice.status_bayar==1,
# ARInvoice.tgl_tetap.between(awal,akhir),
# ARInvoice.is_sts==0,
# #ARInvoice.is_sspd==1,
# #or_(ARInvoice.is_tbp==1,
# # ARInvoice.is_sspd==1)
# ).group_by(ARInvoice.unit_id,
# ARInvoice.unit_kode,
# ARInvoice.unit_nama
# ).order_by(ARInvoice.unit_kode)
# if u != 1:
# rows1 = rows1.filter(ARInvoice.owner_id==u)
# for row in rows1:
# a = ARSts()
# x = datetime.now().strftime('%d-%m-%Y')
# x1 = row.un_kd
#
# a.create_date = datetime.now()
# a.create_uid = u
# a.nama = "Setoran tanggal %s" % x + " atas unit %s" % x1
# a.tahun_id = datetime.now().strftime('%Y')
# a.tgl_sts = datetime.now().strftime('%Y-%m-%d')
# a.unit_id = row.un_id
# a.unit_kode = row.un_kd
# a.unit_nama = row.un_nm
#
# sts_no = DBSession.query(func.max(ARSts.no_id)).\
# filter(ARSts.tahun_id==a.tahun_id,
# ARSts.unit_id==a.unit_id).scalar()
# if not sts_no:
# a.no_id = 1
# else:
# a.no_id = sts_no+1
#
# a.kode = "".join([str(a.tahun_id), re.sub("[^0-9]", "", a.unit_kode),
# str(a.no_id).rjust(6,'0')])
# DBSession.add(a)
# DBSession.flush()
# b = a.id
# b1 = a.unit_id
#
# rows = DBSession.query(ARInvoice.id.label('inv_id'),
# ARInvoice.kode.label('kd'),
# ARInvoice.rekening_id.label('rek_id'),
# ARInvoice.rek_kode.label('rek_kd'),
# ARInvoice.rek_nama.label('rek_nm'),
# ARInvoice.jumlah.label('jumlah'),
# ARInvoice.is_sspd.label('is_sspd')
# ).filter(ARInvoice.status_bayar==1,
# ARInvoice.tgl_tetap.between(awal,akhir),
# ARInvoice.is_sts==0,
# #ARInvoice.is_sspd==1,
# #or_(ARInvoice.is_tbp==1,
# # ARInvoice.is_sspd==1),
# ARInvoice.unit_id==b1
# ).order_by(ARInvoice.rek_kode,
# ARInvoice.kode)
# if u != 1:
# rows = rows.filter(ARInvoice.owner_id==u)
# for row1 in rows:
# items=ARStsItem()
# items.sts_id = b
# items.invoice_id = row1.inv_id
# items.kode = row1.kd
# items.rekening_id = row1.rek_id
# items.rek_kode = row1.rek_kd
# items.rek_nama = row1.rek_nm
# items.jumlah = row1.jumlah
# DBSession.add(items)
# DBSession.flush()
#
# if row1.is_sspd!=0:
# sspd = DBSession.query(ARSspd
# ).filter(ARSspd.arinvoice_id==row1.inv_id,
# ARSspd.bayar!=0
# ).first()
# sspd.posted=1
# DBSession.add(sspd)
# DBSession.flush()
#
# inv = DBSession.query(ARInvoice
# ).filter(ARInvoice.id==row1.inv_id
# ).first()
# inv.is_sts=1
# DBSession.add(inv)
# DBSession.flush()
#
# jumlah = DBSession.query(func.sum(ARStsItem.jumlah)).\
# filter(ARStsItem.sts_id==b).scalar()
# if jumlah:
# rows2 = DBSession.query(ARSts
# ).filter(ARSts.id==b
# ).first()
# rows2.jumlah=jumlah
# DBSession.add(rows2)
# DBSession.flush()
# return route_list(request)
# return dict(message='Posting No.Bayar Sukses', form=form.render())
def save_request4(request, row4=None):
row4 = ARTbp()
return row4
##########
# Delete #
##########
#@view_config(route_name='arinvoiceb-delete', renderer='templates/arinvoice/delete.pt',
# permission='delete')
#def view_delete(request):
# q = query_id(request)
# row = q.first()
#
# if not row:
# return id_not_found(request)
# if row.status_bayar:
# request.session.flash('Data sudah masuk di Penerimaan', 'error')
# return route_list(request)
# if row.is_sts:
# request.session.flash('Data sudah masuk di STS', 'error')
# return route_list(request)
# if row.arsspds:
# form = Form(colander.Schema(), buttons=('batal',))
# else:
# form = Form(colander.Schema(), buttons=('hapus', 'batal'))
#
# if request.POST:
# if 'hapus' in request.POST:
# msg = 'No Bayar ID %d %s sudah dihapus.' % (row.id, row.kode)
# ## Update ke TBP ##
# rows1 = DBSession.query(ARTbp
# ).filter(ARTbp.invoice_id==row.id,
# ARTbp.invoice_kode==row.kode
# ).all()
# for row4 in rows1:
# row4.status_invoice=0
# row4.invoice_id=0
# row4.invoice_kode='-'
# save_request4(request, row4)
#
# q.delete()
# DBSession.flush()
# request.session.flash(msg)
# return route_list(request)
# return dict(row=row, form=form.render())
##########
# Action #
##########
def qry_arinv():
return DBSession.query(ARInvoice).\
join(Unit)
@view_config(route_name='arinvoicews-act', renderer='json',
permission='read')
def view_act(request):
req = request
params = req.params
url_dict = req.matchdict
user = req.user
awal = 'awal' in request.GET and request.GET['awal'] or datetime.now().strftime('%Y-%m-%d')
akhir = 'akhir' in request.GET and request.GET['akhir'] or datetime.now().strftime('%Y-%m-%d')
if url_dict['act']=='grid':
u = request.user.id
columns = []
columns.append(ColumnDT('id'))
columns.append(ColumnDT('kode'))
columns.append(ColumnDT('wp_nama'))
columns.append(ColumnDT('op_kode'))
columns.append(ColumnDT('op_nama'))
columns.append(ColumnDT('rek_nama'))
columns.append(ColumnDT('jumlah', filter=_DTnumberformat))
columns.append(ColumnDT('unit_nama'))
columns.append(ColumnDT('is_tbp'))
columns.append(ColumnDT('is_sspd'))
columns.append(ColumnDT('is_sts'))
query = DBSession.query(ARInvoice)\
.select_from(ARInvoice)\
.join(DepartemenRoute, DepartemenRoute.ar_invoice_id==ARInvoice.id)
rowTable = DataTables(req, ARInvoice, query, columns)
return rowTable.output_result()
elif url_dict['act']=='csv':
query = DBSession.query(
ARInvoice.kode.label('kodebayar'),
ARInvoice.unit_nama.label('unit_nama'),
ARInvoice.wp_nama.label('wp_nama'),
ARInvoice.wp_alamat_1.label('wp_alamat_1'),
ARInvoice.wp_alamat_2.label('wp_alamat_2'),
ARInvoice.wp_kode.label('wp_kode'),
ARInvoice.rek_nama.label('rek_nama'),
ARInvoice.rek_kode.label('rek_kode'),
func.to_char(
ARInvoice.periode_1,
'DD-MM-YYYY'
).label('periode_1'),
func.to_char(
ARInvoice.periode_2,
'DD-MM-YYYY'
).label('periode_2'),
func.to_char(
ARInvoice.jatuh_tempo,
'DD-MM-YYYY'
).label('jatuh_tempo'),
ARInvoice.no_skrd.label('no_skrd'),
func.to_char(
ARInvoice.tgl_tetap,
'DD-MM-YYYY'
).label('tgl_tetap'),
ARInvoice.tahun_id.label('tahun'),
ARInvoice.pokok.label('pokok'),
ARInvoice.denda.label('denda'),
ARInvoice.bunga.label('bunga'),
ARInvoice.jumlah.label('jumlah'),
ARInvoice.status_bayar.label('status_bayar')
)\
.select_from(ARInvoice)\
.join(DepartemenRoute, DepartemenRoute.ar_invoice_id==ARInvoice.id)
row = query.first()
if not row:
req.session.flash('Data tidak ditemukan.')
raise HTTPFound(location=req.route_url('arinvoicews'))
header = row.keys()
rows = []
for item in query.all():
rows.append(list(item))
filename = 'Kode bayar (WS).csv'
value = {
'header': header,
'rows': rows,
}
return csv_response(req, value, filename)
elif url_dict['act']=='pdf':
query = DBSession.query(
ARInvoice.kode.label('kodebayar'),
ARInvoice.unit_nama.label('unit_nama'),
ARInvoice.wp_nama.label('wp_nama'),
ARInvoice.wp_alamat_1.label('wp_alamat_1'),
ARInvoice.wp_alamat_2.label('wp_alamat_2'),
ARInvoice.wp_kode.label('wp_kode'),
ARInvoice.rek_nama.label('rek_nama'),
ARInvoice.rek_kode.label('rek_kode'),
ARInvoice.jatuh_tempo.label('jatuh_tempo'),
ARInvoice.no_skrd.label('no_skrd'),
ARInvoice.tgl_tetap.label('tgl_tetap'),
ARInvoice.tahun_id.label('tahun'),
ARInvoice.pokok.label('pokok'),
ARInvoice.denda.label('denda'),
ARInvoice.bunga.label('bunga'),
ARInvoice.jumlah.label('jumlah'),
ARInvoice.status_bayar.label('status_bayar')
)\
.select_from(ARInvoice)\
.join(DepartemenRoute, DepartemenRoute.ar_invoice_id==ARInvoice.id)
row = query.first()
if not row:
req.session.flash('Data tidak ditemukan.')
raise HTTPFound(location=req.route_url('arinvoicews'))
from py3o.template import Template
class Item(object):
pass
_here = os.path.dirname(__file__) # get current folder -> views
path = os.path.dirname(_here) # mundur 1 level
path = os.path.join(path, 'reports/')
file = '/tmp/kode_bayar_ws'
template= Template(path+'kode_bayar_ws.odt', file+'.odt')
items = list()
rows = query.all()
sum = 0
for row in rows:
item = Item()
item.kodebayar = row.kodebayar
item.unit_nama = row.unit_nama
item.wp_kode = row.wp_kode
item.wp_nama = row.wp_nama
item.rek_kode = row.rek_kode
item.rek_nama = row.rek_nama
item.tgl_tetap = dmy(row.tgl_tetap)
item.jatuh_tempo = dmy(row.jatuh_tempo)
item.no_skrd = row.no_skrd
item.pokok = thousand(int(row.pokok))
item.denda = thousand(int(row.denda))
item.jumlah = thousand(int(row.jumlah))
sum += int(row.jumlah)
items.append(item)
document = Item()
document.sum = thousand(sum)
data = dict(items = items, document = document)
template.render(data)
return odt_export(request, file, 'pdf')
from ..reports.rml_report import open_rml_row, open_rml_pdf, pdf_response
def query_reg():
return DBSession.query(ARInvoice.kode.label('a'),
ARInvoice.wp_nama.label('b'),
ARInvoice.rek_kode.label('c'),
ARInvoice.op_nama.label('d'),
ARInvoice.tgl_tetap.label('e'),
func.trim(func.to_char(ARInvoice.jumlah,'999,999,999,990')).label('f'),
ARInvoice.unit_nama.label('g'),
).order_by(ARInvoice.tgl_tetap,
ARInvoice.kode)
def query_cetak():
return DBSession.query(ARInvoice.kode.label('a'),
ARInvoice.wp_nama.label('b'),
ARInvoice.wp_alamat_1.label('c'),
ARInvoice.rek_kode.label('d'),
ARInvoice.rek_nama.label('e'),
func.trim(func.to_char(ARInvoice.pokok,'999,999,999,990')).label('f'),
func.trim(func.to_char(ARInvoice.denda,'999,999,999,990')).label('g'),
func.trim(func.to_char(ARInvoice.bunga,'999,999,999,990')).label('h'),
func.trim(func.to_char(ARInvoice.jumlah,'999,999,999,990')).label('i'),
ARInvoice.tgl_tetap.label('j'),
ARInvoice.unit_nama.label('k'),
).order_by(ARInvoice.unit_kode,
ARInvoice.rek_kode)
########
# CSV #
########
#@view_config(route_name='arinvoiceb-csv', renderer='csv')
#def view_csv(request):
# ses = request.session
# params = request.params
# url_dict = request.matchdict
# u = request.user.id
# awal = 'awal' in request.params and request.params['awal']\
# or datetime.now().strftime('%Y-%m-%d')
# akhir = 'akhir' in request.params and request.params['akhir']\
# or datetime.now().strftime('%Y-%m-%d')
# if url_dict['csv']=='reg' :
# query = query_reg()
# if u != 1:
# query = query.filter(ARInvoice.owner_id==u)
#
# row = query.filter(ARInvoice.tgl_tetap.between(awal,akhir),
# ARInvoice.status_grid==0)#.first()
# #print "-- ROW -- ",row
# header = 'No. Bayar','Penyetor','Objek','Uraian','Tgl. Tetap','Jumlah','OPD' #row.keys()
# rows = []
# for item in row.all():
# rows.append(list(item))
#
# # override attributes of response
# filename = 'Tagihan_Bendahara_%s_sd_%s.csv' %(awal, akhir)
# request.response.content_disposition = 'attachment;filename=' + filename
#
# return {
# 'header': header,
# 'rows' : rows,
# }
##########
# PDF #
##########
#@view_config(route_name='arinvoiceb-pdf', permission='read')
#def view_pdf(request):
# global awal,akhir,unit_nm,unit_al,unit_kd
# params = request.params
# url_dict = request.matchdict
# u = request.user.id
#
# if group_in(request, 'bendahara'):
# unit_id = DBSession.query(UserUnit.unit_id
# ).filter(UserUnit.user_id==u
# ).first()
# unit_id = '%s' % unit_id
# unit_id = int(unit_id)
#
# unit = DBSession.query(Unit.kode.label('kode'),
# Unit.nama.label('nama'),
# Unit.alamat.label('alamat')
# ).filter(UserUnit.unit_id==unit_id,
# Unit.id==unit_id
# ).first()
# unit_kd = '%s' % unit.kode
# unit_nm = '%s' % unit.nama
# unit_al = '%s' % unit.alamat
#
# awal = 'awal' in request.params and request.params['awal']\
# or datetime.now().strftime('%Y-%m-%d')
# akhir = 'akhir' in request.params and request.params['akhir']\
# or datetime.now().strftime('%Y-%m-%d')
# id1 = 'id1' in request.params and request.params['id1']
#
# if url_dict['pdf']=='reg' :
# nm = "BADAN PENDAPATAN DAERAH"
# al = "Jl. Soekarno Hatta, No. 528, Bandung"
# query = query_reg()
# if u != 1:
# query = query.filter(ARInvoice.owner_id==u)
#
# rml_row = open_rml_row('arinvoiceb.row.rml')
# rows=[]
# for r in query.filter(ARInvoice.tgl_tetap.between(awal,akhir),
# ARInvoice.status_grid==0).all():
# s = rml_row.format(kode=r.a,
# wp=r.b,
# rek_k=r.c,
# rek_n=r.d,
# terutang=r.e.strftime('%d-%m-%Y'),
# jumlah=r.f,
# unit=r.g)
# rows.append(s)
# if group_in(request, 'bendahara'):
# pdf, filename = open_rml_pdf('arinvoiceb.rml', rows2=rows,
# un_nm=unit_nm,
# un_al=unit_al,
# awal=awal,
# akhir=akhir)
# else:
# pdf, filename = open_rml_pdf('arinvoiceb.rml', rows2=rows,
# awal=awal,
# akhir=akhir,
# un_nm=nm,
# un_al=al)
# return pdf_response(request, pdf, filename)
#
# if url_dict['pdf']=='cetak' :
# query = query_cetak()
# rml_row = open_rml_row('arinvoiceb_cetak.row.rml')
# rows=[]
#
# for r in query.filter(ARInvoice.tgl_tetap.between(awal,akhir),ARInvoice.id==id1).all():
# s = rml_row.format(kode=r.a,
# wp_n=r.b,
# wp_a=r.c,
# rek_k=r.d,
# rek_n=r.e,
# terutang=r.f,
# denda=r.g,
# bunga=r.h,
# jumlah=r.i,
# terima=r.j.strftime('%d/%m/%Y'),
# unit=r.k )
# rows.append(s)
# pdf, filename = open_rml_pdf('arinvoiceb_cetak.rml', rows2=rows)
# return pdf_response(request, pdf, filename)
#
# if url_dict['pdf']=='skrd' :
# if not 'id' in params or not params['id']:
# request.session.flash('ID tidak ditemukan','error')
# raise route_list()
#
# from py3o.template import Template
# class Item(object):
# pass
# _here = os.path.dirname(__file__) # get current folder -> views
# path = os.path.dirname(_here) # mundur 1 level
# path = os.path.join(path, 'reports/')
# file = '/tmp/skrd'
# template= Template(path+'skrd.odt', file+'.odt')
#
# row = DBSession.query(ARInvoice).filter_by(id=params['id']).first()
# item = Item()
# item.opd = row.unit_nama
# item.wp_nama = row.wp_nama
# item.wp_alamat = (row.wp_alamat_2 and row.wp_alamat_2 != '-') and ('{} {}'.format(row.wp_alamat_1, row.wp_alamat_2)) or row.wp_alamat_1
# item.wp_kode = row.wp_kode
# item.rek_nama = row.rek_nama
# item.rek_kode = row.rek_kode
# item.periode_1 = dmy(row.periode_1)
# item.periode_2 = dmy(row.periode_2)
# item.kodebayar = row.kode
# item.no_skrd = row.no_skrd
# item.tahunskrd = row.tahun_id
# BULAN = dict(BULANS)
# bulan = row.tgl_tetap.strftime('%m')
# item.tgl_tetap = '{} {},'.format(row.tgl_tetap.strftime('%d'),BULAN[bulan])
# item.tahun_tetap = row.tgl_tetap.year
# item.tahun = datetime.now().year
# item.jumlah = thousand(row.jumlah)
# item.jatuh_tempo = dmy(row.jatuh_tempo)
# item.terbilang = terbilang(row.jumlah) + ' Rupiah'
#
# data = {}
# data['item'] = item
# template.render(data)
# return odt_export(request, file, 'pdf')
...@@ -100,7 +100,7 @@ def custom_error(code, message): ...@@ -100,7 +100,7 @@ def custom_error(code, message):
def get_mandatory(data, values): def get_mandatory(data, values):
for value in values: for value in values:
if not value in data or not data[value]: if not value in data or not data[value]:
raise JsonRpcInvalidDataError raise JsonRpcInvalidDataError(message="{} Not Found".format(value))
def get_seconds(): def get_seconds():
begin_unix_time = datetime(1970, 1, 1) begin_unix_time = datetime(1970, 1, 1)
...@@ -163,6 +163,7 @@ def set_invoice(request, data): ...@@ -163,6 +163,7 @@ def set_invoice(request, data):
- periode_1 - periode_1
- periode_2 - periode_2
- jatuh_tempo - jatuh_tempo
- no_skrd
- tgl_skrd - tgl_skrd
:return: :return:
- kd_bayar - kd_bayar
...@@ -171,7 +172,7 @@ def set_invoice(request, data): ...@@ -171,7 +172,7 @@ def set_invoice(request, data):
auth_from_rpc(request) auth_from_rpc(request)
param = ['op_kode','rek_kode','dasar','tarif', param = ['op_kode','rek_kode','dasar','tarif',
'pokok','denda','bunga','jumlah','periode_1', 'pokok','denda','bunga','jumlah','periode_1',
'periode_2','jatuh_tempo','tgl_tetap'] 'periode_2','jatuh_tempo','tgl_tetap','no_skrd']
get_mandatory(data, param) get_mandatory(data, param)
values = clear_null_value(data) values = clear_null_value(data)
if 'jatuh_tempo' in values and values['jatuh_tempo']: if 'jatuh_tempo' in values and values['jatuh_tempo']:
...@@ -180,12 +181,10 @@ def set_invoice(request, data): ...@@ -180,12 +181,10 @@ def set_invoice(request, data):
values['periode_1'] = date_from_str(values['periode_1']) values['periode_1'] = date_from_str(values['periode_1'])
if 'periode_2' in values and values['periode_2']: if 'periode_2' in values and values['periode_2']:
values['periode_2'] = date_from_str(values['periode_2']) values['periode_2'] = date_from_str(values['periode_2'])
# if not 'status_bayar' in values or not values['status_bayar']:
# values['status_bayar'] = 0
values['status_bayar'] = 0 values['status_bayar'] = 0
op = ObjekPajak.get_by_kode(values['op_kode']) op = ObjekPajak.get_by_kode(values['op_kode'])
if not op: if not op:
return custom_error(-1,'Objek Pajak not found') return custom_error(-1,'Objek Pajak kode {} not found'.format(values['op_kode']))
values['objek_pajak_id'] = op.id values['objek_pajak_id'] = op.id
values['op_kode'] = op.kode values['op_kode'] = op.kode
values['op_nama'] = op.nama values['op_nama'] = op.nama
...@@ -196,30 +195,26 @@ def set_invoice(request, data): ...@@ -196,30 +195,26 @@ def set_invoice(request, data):
values['unit_id'] = op.unit_id values['unit_id'] = op.unit_id
subjek = SubjekPajak.get_by_id(values['subjek_pajak_id']) subjek = SubjekPajak.get_by_id(values['subjek_pajak_id'])
if not subjek: if not subjek:
return custom_error(-1,'Subjek Pajak not found, contact admin') return custom_error(-1,'Subjek Pajak id {} not found, contact admin'.format(values['subjek_pajak_id']))
values['wp_kode'] = subjek.kode values['wp_kode'] = subjek.kode
values['wp_nama'] = subjek.nama values['wp_nama'] = subjek.nama
values['wp_alamat_1'] = subjek.alamat_1 values['wp_alamat_1'] = subjek.alamat_1
values['wp_alamat_2'] = subjek.alamat_2 values['wp_alamat_2'] = subjek.alamat_2
unit = Unit.get_by_id(values['unit_id']) unit = Unit.get_by_id(values['unit_id'])
if not unit: if not unit:
return custom_error(-1,'Unit not found, contact admin') return custom_error(-1,'Unit id {} not found, contact admin'.format(values['unit_id']))
values['unit_kode'] = unit.id values['unit_kode'] = unit.id
values['unit_nama'] = unit.nama values['unit_nama'] = unit.nama
rek = Rekening.get_by_kode(values['rek_kode']) rek = Rekening.get_by_kode(values['rek_kode'])
if not rek: if not rek:
return custom_error(-1,'Rekening not found, contact admin') return custom_error(-1,'Rekening kode {} not found, contact admin'.format(values['rek_kode']))
values['rekening_id'] = rek.id values['rekening_id'] = rek.id
values['rek_nama'] = rek.nama values['rek_nama'] = rek.nama
rdata = {} rdata = {}
for v in values: for v in values:
v = v.strip() v = v.strip()
row_invoice = DBSession.query(ARInvoice).\ row_invoice = DBSession.query(ARInvoice).\
filter( filter(ARInvoice.no_skrd == values['no_skrd']).first()
ARInvoice.tgl_tetap == values['tgl_tetap'],
ARInvoice.op_kode == values['op_kode'],
ARInvoice.rekening_id == values['rekening_id'],
).first()
if row_invoice: if row_invoice:
if row_invoice.status_bayar == 1: if row_invoice.status_bayar == 1:
raise JsonRpcBillAllreadyPaidError raise JsonRpcBillAllreadyPaidError
...@@ -229,6 +224,7 @@ def set_invoice(request, data): ...@@ -229,6 +224,7 @@ def set_invoice(request, data):
# Save Departemen_Route # Save Departemen_Route
values['kode'] = invoice.kode values['kode'] = invoice.kode
values['no_skrd'] = invoice.no_skrd
values['tgl_skrd'] = invoice.tgl_tetap values['tgl_skrd'] = invoice.tgl_tetap
values['ar_invoice_id'] = invoice.id values['ar_invoice_id'] = invoice.id
save_departemen_route(request, values) save_departemen_route(request, values)
......
<html metal:use-macro="load: ../base.pt">
<div metal:fill-slot="content">
<link href="/static/datatables/extensions/TableTools/css/dataTables.tableTools.min.css" rel="stylesheet">
<link href="/static/datatables/media/css/dataTables.bootstrap.css" rel="stylesheet">
<h4>Daftar Kode Bayar (Bendahara)</h4>
<hr>
<div class="container">
<!--form class="form-inline" role="form" id="frm_upload" name="frm_upload">
<label for="upload" class="control-label">Upload:</label>
<input type="text" class="form-control" id="upload">
<button type="submit" class="btn btn-default">Upload</button>
</form-->
</div>
<p>
<table id="table1" name="table1" class="table table-bordered table-hover table-condensed" >
<thead>
<tr>
<th>ID</th>
<th>Kode Bayar</th>
<th>Penyetor</th>
<th>Objek</th>
<th>Uraian</th>
<th>Rekening</th>
<th>Jumlah</th>
<th>OPD</th>
<th>TBP</th>
<th>SSPD</th>
<th>STS</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script src="/static/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="/static/datatables/media/js/jquery.dataTables.ext.js"></script>
<script src="/static/datatables/extensions/TableTools/media/js/ZeroClipboard.js"></script>
<script src="/static/datatables/media/js/dataTables.bootstrap.js"></script>
<script>
var mID;
var oTable;
var iPos;
var oFormUrl = "/arinvoicews/";
var oTableUrl = oFormUrl+"grid/act";
$.fn.dataTable.ext.search.push(
function( oSettings, aData, iDataIndex ) {
var iFini = document.getElementById('awal').value;
var iFfin = document.getElementById('akhir').value;
var iStartDateCol = 6;
var iEndDateCol = 7;
alert(iFini);
iFini=iFini.substring(6,10) + iFini.substring(3,5)+ iFini.substring(0,2);
iFfin=iFfin.substring(6,10) + iFfin.substring(3,5)+ iFfin.substring(0,2);
var datofini = aData[iStartDateCol].substring(6,10) + aData[iStartDateCol].substring(3,5) + aData[iStartDateCol].substring(0,2);
var datoffin = aData[iEndDateCol].substring(6,10) + aData[iEndDateCol].substring(3,5) + aData[iEndDateCol].substring(0,2);
if ( iFini === "" && iFfin === "" )
{
return true;
}
else if ( iFini <= datofini && iFfin === "")
{
return true;
}
else if ( iFfin >= datoffin && iFini === "")
{
return true;
}
else if (iFini <= datofini && iFfin >= datoffin)
{
return true;
}
return false;
}
);
$(document).ready(function () {
oTable = $('#table1').DataTable({
ajaxSource : oTableUrl,
//"bStateSave" : true,
serverSide : true,
"bProcessing" : true,
"sDom" : '<"toolbar">lfrtip',
"bScrollCollapse" : true,
"bSort" : true,
"bSearch" : true,
"bInfo" : false,
"bFilter" : true,
"bAutoWidth" : false,
"bPaginate" : true,
"sPaginationType" : "full_numbers",
"lengthMenu": [
[10, 25, 50, 100],
[10, 25, 50, 100]
],
"aoColumnDefs": [
{"bSearchable": false, "bVisible": false, "aTargets": [0,8,9,10]}
],
"aoColumns": [
null,
{"sWidth": "100px", "sClass": "left"},
{"sWidth": "30px", "sClass": "center"},
{"sWidth": "30px", "sClass": "center"},
null,
null,
{"sWidth": "75px", "sClass": "right"},
//{"sWidth": "75px", "sClass": "center"},
//{"sWidth": "40px", "sClass": "center"},
//{"sWidth": "40px", "sClass": "center"},
null,
{"sWidth": "30px", "sClass": "center"},
{"sWidth": "30px", "sClass": "center"},
{"sWidth": "30px", "sClass": "center"},
],
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
$(nRow).on("click", function (event) {
if ($(this).hasClass('row_selected')) {
/* mID = '';
$(this).removeClass('row_selected'); */
} else {
var data = oTable.fnGetData(this);
oTable.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
})
////Kondisi TBP
//switch(aData[8]){
// case '1' :
// $('td',nRow).css("background-color","#AFEEEE")
// break;
//}
////Kondisi SSPD
//switch(aData[9]){
// case '1' :
// $('td',nRow).css("background-color","#F0E68C")
// break;
//}
////Kondisi STS
//switch(aData[10]){
// case '1' :
// $('td',nRow).css("background-color","#ddffdd")
// break;
//}
},
"language": {
"search" : "Cari: ",
"paginate":{
"first" : "Pertama ",
"last" : "Terakhir ",
"previous": "Sebelumnya ",
"next" : "Selanjutnya ",
},
"lengthMenu": "Tampil _MENU_ baris "
}
});
var tb_array = [
'<div class="btn-group pull-left">',
' <button id="btn_pdf" class="btn btn btn-success pull-left" type="button">PDF</button>',
' <button id="btn_csv" class="btn btn btn-info pull-left" type="button">CSV</button>',
' <button id="btn_close" class="btn btn btn-warning" type="button">Tutup</button>',
' <label class="pull-left">Periode',
' <input id="awal" class="input-sm " type="text" value="${rows.awal}">',
' s.d <input id="akhir" class="input-sm " type="text" value="${rows.akhir}">',
' </label>',
' &nbsp;',
'</div>',
];
var tb = tb_array.join(' ');
$("div.toolbar").html(tb);
var tb_periode = [
];
var tb = tb_periode.join(' ');
$("div.periode").html(tb);
$('#awal').pickadate({"selectMonths" : true,
"submitFormat" : "yyyy-mm-dd",
"selectYears" : true,
"format" : "yyyy-mm-dd"});
$('#akhir').pickadate({"selectMonths": true,
"submitFormat": "yyyy-mm-dd",
"selectYears" : true,
"format" : "yyyy-mm-dd"});
$('#awal, #akhir').change(function(){
oTableUrl = oFormUrl+"grid/act?awal="+$('#awal').val()+"&akhir="+$('#akhir').val();
oTable.ajax.url(oTableUrl).load();
});
$('#table1 tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
mID = '';
$(this).removeClass('selected');
} else {
//iPos = oTable.fnGetPosition(this);
//var aData = oTable.fnGetData(iPos);
var aData = oTable.row( this ).data();
mID = aData[0];
oTable.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
});
$('#btn_tambah').click(function () {
window.location = oFormUrl+'add';
});
$('#btn_edit').click(function () {
if (mID) {
window.location = oFormUrl+mID+'/edit';
} else {
alert('Silahkan pilih data yang akan diedit');
}
});
$('#btn_posting').click(function () {
url = oFormUrl+'posting?awal='+$('#awal').val()+"&akhir="+$('#akhir').val();
window.location = url;
});
$('#btn_print').click(function () {
url = "/reports/act/r100?id="+mID;
if (mID) {
window.open(url);
} else {
alert('Silahkan pilih Kode Bayar');
}
});
$('#btn_print1').click(function () {
if (mID) {
url = oFormUrl+'cetak/pdf?awal='+$('#awal').val()+"&akhir="+$('#akhir').val()+"&id1="+mID;
window.open(url);
} else {
alert('Silahkan pilih data yang akan dicetak kwitansinya.');
}
});
$('#btn_skrd').click(function () {
if (mID) {
url = oFormUrl+'skrd/pdf?id='+mID;
window.open(url);
} else {
alert('Silahkan pilih data yang akan dicetak skrdnya.');
}
});
$('#btn_csv').click(function () {
url = oFormUrl+'csv/act?awal='+$('#awal').val()+"&akhir="+$('#akhir').val();
window.open(url);
});
$('#btn_pdf').click(function () {
url = oFormUrl+'pdf/act?awal='+$('#awal').val()+"&akhir="+$('#akhir').val();
window.open(url);
});
$('#btn_close').click(function () {
window.location = "/"
});
$('#btn_delete').click(function () {
if (mID) {
var hapus = confirm('Hapus data ini?');
if (hapus == true) {
window.location = oFormUrl+mID+'/delete';
};
} else {
alert('Silahkan pilih data yang akan dihapus');
}
});
});
</script>
</div>
</html>
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
<li><a href="/arinvoice">Kode Bayar (BUD)</a></li> <li><a href="/arinvoice">Kode Bayar (BUD)</a></li>
<li><a href="/arinvoiceb">Kode Bayar (Bendahara)</a></li> <li><a href="/arinvoiceb">Kode Bayar (Bendahara)</a></li>
<li><a href="/arinvoicewp">Kode Bayar (WP)</a></li> <li><a href="/arinvoicewp">Kode Bayar (WP)</a></li>
<li><a href="/arinvoicews">Kode Bayar (WS)</a></li>
<li><a href="/report">Laporan</a></li> <li><a href="/report">Laporan</a></li>
</ul> </ul>
</li> </li>
......
...@@ -80,29 +80,32 @@ ...@@ -80,29 +80,32 @@
font-size:13px; font-size:13px;
} }
</style> </style>
<!-- <div class="well"> --> <tal:block tal:condition="not statusadmin">
<!-- <h1>SISTEM PENDAPATAN TERPADU</h1> --> <div class="well">
<!-- <p><img src="/static/img/logo-sipandu-pemda-bjb.png" class="img-float img-thumbnail"/> --> <h1>SISTEM PENDAPATAN TERPADU</h1>
<!-- Selamat datang di aplikasi SIPANDU --> <p><img src="/static/img/logo-sipandu-pemda-bjb.png" class="img-float img-thumbnail"/>
Selamat datang di aplikasi SIPANDU
<!-- <p>SIPANDU merupakan sub sistem dari aplikasi i-SIPKD yang bertujuan --> <p>SIPANDU merupakan sub sistem dari aplikasi i-SIPKD yang bertujuan
<!-- meningkatkan pelayanan kepada masyarakat seluruh Provinsi Jawa Barat --> meningkatkan pelayanan kepada masyarakat seluruh Provinsi Jawa Barat
<!-- khususnya dalam melayani registrasi pembayaran Pajak Daerah Provinsi yang --> khususnya dalam melayani registrasi pembayaran Pajak Daerah Provinsi yang
<!-- terdiri dari:</p> --> terdiri dari:</p>
<!-- <p> --> <p>
<!-- <ul> --> <ul>
<!-- <li>Pajak Kendaraan Bermotor</li> --> <li>Pajak Kendaraan Bermotor</li>
<!-- <li>Pajak Bahan Bakar Kendaraan Bermotor </li> --> <li>Pajak Bahan Bakar Kendaraan Bermotor </li>
<!-- <li>Hibah Masyarakat/Lembaga Swasta</li> --> <li>Hibah Masyarakat/Lembaga Swasta</li>
<!-- <li>Pendapatan Lainnya</li> --> <li>Pendapatan Lainnya</li>
<!-- </ul> --> </ul>
<!-- </p> --> </p>
<!-- <p>Aplikasi Sistem Pendapatan Terpadu ini terselenggara atas kerjasama:</p> --> <p>Aplikasi Sistem Pendapatan Terpadu ini terselenggara atas kerjasama:</p>
<!-- <ul> --> <ul>
<!-- <li>Pemerintah Provinsi Jawa Barat,</li> --> <li>Pemerintah Provinsi Jawa Barat,</li>
<!-- <li>PT. Bank Pembangunan Daerah Jawa Barat dan Banten, Tbk (Bank BJB)</li> --> <li>PT. Bank Pembangunan Daerah Jawa Barat dan Banten, Tbk (Bank BJB)</li>
<!-- </div> --> </div>
</tal:block>
<tal:block tal:condition="statusadmin">
<div class="col-md-6"> <div class="col-md-6">
<h4>REALISASI PENDAPATAN DAERAH TAHUN ${dates['year']}</h4> <h4>REALISASI PENDAPATAN DAERAH TAHUN ${dates['year']}</h4>
</div> </div>
...@@ -356,5 +359,6 @@ ...@@ -356,5 +359,6 @@
$("#unit").val("${request.session['unit']}"); $("#unit").val("${request.session['unit']}");
</tal:block> </tal:block>
</script> </script>
</tal:block>
</div> </div>
</html> </html>
...@@ -30,7 +30,9 @@ requires=['pyramid>=1.5a2<=1.6a1', ...@@ -30,7 +30,9 @@ requires=['pyramid>=1.5a2<=1.6a1',
'z3c.rml', 'z3c.rml',
'xlrd', 'xlrd',
'pyramid_rpc', 'pyramid_rpc',
'requests' 'requests',
'unoconv',
'py3o.template'
] ]
if sys.argv[1:] and sys.argv[1] == 'develop-use-pip': if sys.argv[1:] and sys.argv[1] == 'develop-use-pip':
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!