Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Kunto
/
backoffice
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 3d893f3b
authored
Aug 06, 2019
by
musthofa
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
customer invoice
1 parent
69d4e70b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
376 additions
and
11 deletions
src/agratek/api/merchant/scripts/data/routes.csv
src/agratek/api/merchant/views/customer.py
src/agratek/api/merchant/views/list_vendor.py
src/agratek/api/merchant/views/templates/base.pt
src/agratek/api/merchant/scripts/data/routes.csv
View file @
3d893f3
...
...
@@ -49,3 +49,10 @@ api-integrated-delete,/api/integrated/{id}/delete,Delete Api Integrated Payment,
api-integrated-view,/api/integrated/{id}/view,View Api Integrated Payment,1,0
api-integrated-doc,/api/integrated/doc,Doc Api Integrated Payment,1,0
api-integrated-notify,/api/integrated/{name}/notify,Api Integrated Payment Notify,1,0
api-customer-list,/api/customer/list,List Customer,1,0
api-customer-act,/api/customer/{act}/act,Act Customer,1,0
api-customer-view,/api/customer/{id}/view,View Customer,1,0
api-customer-add,/api/customer/add,Add Customer,1,0
api-customer-edit,/api/customer/{id}/edit,Edit Customer,1,0
api-customer-delete,/api/customer/{id}/delete,Delete Customer,1,0
\ No newline at end of file
src/agratek/api/merchant/views/customer.py
0 → 100644
View file @
3d893f3
from
datetime
import
datetime
import
colander
from
datatables
import
ColumnDT
from
deform
import
widget
,
Form
,
ValidationFailure
from
opensipkd.base.views
import
DataTables
from
pyramid.httpexceptions
import
HTTPFound
from
pyramid.view
import
view_config
from
.
import
BaseView
# , save_file_upload
from
..models
import
(
DBSession
,
flush_row
,
Satuan
)
# from ..models import (H2hArInvoice, H2hArInvoiceDet)
from
..models
import
(
Produk
,
Partner
,
PartnerLog
,
PartnerProduk
,
H2hArInvoice
,
H2hArInvoiceDet
)
from
..tools
import
(
btn_reset
,
btn_cancel
,
btn_delete
,
btn_save
)
from
opensipkd.pasar.models.views
import
(
deferred_produk
,
deferred_vendor
,
deferred_customer
)
class
AddSchema
(
colander
.
Schema
):
__tablename__
=
'h2h_ar_invoice'
kode
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"kode"
,
)
customer_id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
title
=
'Customer'
,
oid
=
"customer_id"
,
widget
=
deferred_customer
)
cust_inv_no
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
'TRX Customer'
,
oid
=
"cust_inv_no"
,
widget
=
widget
.
TextInputWidget
()
)
produk_id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
title
=
'Produk'
,
oid
=
"produk_id"
,
widget
=
deferred_produk
)
id_pel
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
'No.Tujuan/ID Pelanggan'
,
oid
=
"id_pel"
,
widget
=
widget
.
TextInputWidget
())
vendor_id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
title
=
'Vendor'
,
oid
=
"vendor_id"
,
widget
=
deferred_vendor
)
vend_inv_no
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
'TRX Vendor'
,
oid
=
"vend_inv_no"
,
widget
=
widget
.
TextInputWidget
(
css_class
=
"readonly"
)
)
amount
=
colander
.
SchemaNode
(
colander
.
Integer
(),
oid
=
"amount"
,
)
reconciled
=
colander
.
SchemaNode
(
colander
.
Integer
(),
oid
=
"reconciled"
,
)
class
EditSchema
(
AddSchema
):
id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
title
=
'ID'
,
missing
=
colander
.
drop
,
oid
=
"id"
,
widget
=
widget
.
HiddenWidget
())
def
form_validator
(
form
,
value
):
pass
def
get_form
(
request
,
class_form
,
buttons
=
None
,
row
=
None
):
schema
=
class_form
(
validator
=
form_validator
)
schema
=
schema
.
bind
(
vendor
=
Partner
.
get_vendor_list
(),
produk
=
Produk
.
get_e_list
(),
customer
=
Partner
.
get_customer_list
())
schema
.
request
=
request
if
row
:
schema
.
deserialize
(
row
)
if
not
buttons
:
buttons
=
(
btn_save
,
btn_reset
)
return
Form
(
schema
,
buttons
=
buttons
)
def
route_list
(
request
):
return
HTTPFound
(
location
=
request
.
route_url
(
'api-customer-list'
))
def
save
(
values
,
row
):
# if not row:
# row = H2hArInvoice()
# row.create_uid = values['uid']
# row.created = datetime.now()
# else:
# row.update_uid = values['uid']
# row.updated = datetime.now()
row
.
from_dict
(
values
)
flush_row
(
row
)
return
row
def
save_request
(
request
,
values
,
values_det
,
row
=
None
):
if
not
row
:
row
=
H2hArInvoice
()
values
[
'uid'
]
=
request
.
user
.
id
values
[
'status'
]
=
'status'
in
values
and
values
[
'status'
]
and
1
or
0
else
:
values
[
'update_uid'
]
=
request
.
user
.
id
values
[
'updated'
]
=
datetime
.
now
()
DBSession
.
query
(
H2hArInvoiceDet
)
.
filter
(
H2hArInvoiceDet
.
ar_invoice_id
==
row
.
id
)
.
delete
()
row
=
save
(
values
,
row
)
row_det
=
H2hArInvoiceDet
()
row_det
.
id_pel
=
values
[
'id_pel'
]
row_det
.
ar_invoice_id
=
row
.
id
row_det
=
save
(
values_det
,
row_det
)
request
.
session
.
flash
(
'Data
%
s Berhasil disimpan'
%
values
[
'kode'
])
# return row
form_params_edit
=
dict
(
scripts
=
"""
$(document).ready(function(){
});
"""
)
form_params_view
=
dict
(
scripts
=
"""
$(document).ready(function(){
});
"""
)
def
session_failed
(
request
,
session_name
):
r
=
dict
(
form
=
request
.
session
[
session_name
])
del
request
.
session
[
session_name
]
return
r
def
id_not_found
(
request
):
id
=
request
.
matchdict
[
'id'
]
request
.
session
.
flash
(
'Data
%
s Tidak Ditemukan'
%
id
,
'error'
)
return
route_list
(
request
)
def
query_id
(
request
):
id
=
request
.
matchdict
[
'id'
]
return
H2hArInvoice
.
query_id
(
id
)
class
ViewData
(
BaseView
):
@view_config
(
route_name
=
'api-customer-list'
,
permission
=
"api-customer-list"
,
renderer
=
'templates/list.pt'
)
def
view_list
(
self
):
params
=
{
'columns'
:
[
dict
(
title
=
"ID"
),
dict
(
title
=
"Customer"
),
dict
(
title
=
"TRX Customer"
),
dict
(
title
=
"Produk"
),
dict
(
title
=
"No.Tujuan/ID Pelanggan"
),
# dict(title="Vendor"),
# dict(title="TRX Vendor"),
dict
(
title
=
"Amount"
),
dict
(
title
=
"Reconciled"
),
],
'column_data'
:
[
dict
(
data
=
"id"
,
width
=
"0px"
),
dict
(
data
=
"customer_nm"
),
dict
(
data
=
"cust_inv_no"
),
dict
(
data
=
"produk_nm"
),
dict
(
data
=
"id_pel"
),
# dict(data="vendor_nm"),
# dict(data="vend_inv_no"),
dict
(
data
=
"amount"
),
dict
(
data
=
"reconciled"
),
],
'buttons'
:
[
dict
(
id
=
"btn_add"
,
cls
=
"btn btn btn-success"
,
title
=
"Tambah"
),
dict
(
id
=
"btn_edit"
,
cls
=
"btn btn btn-primary"
,
title
=
"Edit"
),
dict
(
id
=
"btn_delete"
,
cls
=
"btn btn btn-primary"
,
title
=
"Hapus"
),
dict
(
id
=
"btn_close"
,
cls
=
"btn btn-danger"
,
title
=
"Tutup"
),
],
'route'
:
"/api/customer"
,
'scripts'
:
"""
$('#btn_edit').click(function() {
if (mID) window.location = oTableUri + '/' + mID + '/edit';
else
$.SmartMessageBox({
title : "Edit",
content : "Pilih Baris yang akan di lihat...",
buttons : '[Oke]'
});;
});
$('#btn_delete').click(function() {
if (mID) window.location = oTableUri + '/' + mID + '/delete';
else
$.SmartMessageBox({
title : "Delete",
content : "Pilih Baris yang akan di lihat...",
buttons : '[Oke]'
});;
});
$('#btn_add').click(function() {
window.location = oTableUri + '/add';
});
$("#btn_close").click(function() {
window.location = '/api/merchant';
return false;
});
"""
}
return
dict
(
params
=
params
)
@view_config
(
route_name
=
'api-customer-add'
,
permission
=
"api-customer-admin"
,
renderer
=
'templates/form.pt'
)
def
view_add
(
self
):
request
=
self
.
req
form
=
get_form
(
request
,
AddSchema
)
# form_params = dict(scripts=None)
if
request
.
POST
:
controls
=
request
.
POST
.
items
()
try
:
c
=
form
.
validate
(
controls
)
print
(
"#############################PAGER############################"
)
print
(
dict
(
controls
))
print
(
"******************BATES**************"
)
print
(
dict
(
c
.
items
()))
print
(
"#############################PAGER############################"
)
except
ValidationFailure
as
e
:
form
.
set_appstruct
(
e
.
cstruct
)
return
dict
(
form
=
form
,
params
=
form_params_edit
)
values
=
dict
(
c
.
items
())
row
=
save_request
(
request
,
dict
(
c
.
items
()),
dict
(
c
.
items
()))
return
route_list
(
request
)
# values = dict(
# # vendor_id=3,
# id_pel=1234567890,
# cust_inv_no="C-iNV-123",
# vend_inv_no="V-iNV-123",
# )
# form.render(values)
return
dict
(
form
=
form
,
params
=
form_params_edit
)
@view_config
(
route_name
=
'api-customer-act'
,
renderer
=
'json'
,
permission
=
"api-customer-list"
)
def
view_act
(
self
):
request
=
self
.
req
url_dict
=
request
.
matchdict
act
=
url_dict
[
'act'
]
if
act
==
"grid"
:
columns
=
[
ColumnDT
(
H2hArInvoice
.
id
,
mData
=
'id'
),
ColumnDT
(
Partner
.
nama
,
mData
=
'customer_nm'
),
ColumnDT
(
H2hArInvoice
.
cust_inv_no
,
mData
=
'cust_inv_no'
),
ColumnDT
(
Produk
.
nama
,
mData
=
'produk_nm'
),
ColumnDT
(
H2hArInvoiceDet
.
id_pel
,
mData
=
'id_pel'
),
# ColumnDT(Partner.nama, mData='vendor_nm'),
# ColumnDT(H2hArInvoiceDet.vend_inv_no, mData='vend_inv_no'),
ColumnDT
(
H2hArInvoice
.
amount
,
mData
=
'amount'
),
ColumnDT
(
H2hArInvoice
.
reconciled
,
mData
=
'reconciled'
),
]
query
=
DBSession
.
query
()
.
select_from
(
H2hArInvoice
)
.
join
(
H2hArInvoiceDet
,
H2hArInvoiceDet
.
ar_invoice_id
==
H2hArInvoice
.
id
)
.
\
join
(
Partner
,
Partner
.
id
==
H2hArInvoice
.
customer_id
)
.
\
join
(
Produk
,
Produk
.
id
==
H2hArInvoiceDet
.
produk_id
)
row_table
=
DataTables
(
request
.
GET
,
query
,
columns
)
return
row_table
.
output_result
()
@view_config
(
route_name
=
'api-customer-edit'
,
permission
=
"api-customer-admin"
,
renderer
=
'templates/form.pt'
)
def
view_edit
(
self
):
request
=
self
.
req
form
=
get_form
(
request
,
AddSchema
)
row
=
query_id
(
request
)
.
first
()
row_det
=
DBSession
.
query
(
H2hArInvoiceDet
)
.
filter
(
H2hArInvoiceDet
.
ar_invoice_id
==
row
.
id
)
.
first
()
if
not
row
:
return
id_not_found
()
if
request
.
POST
:
controls
=
request
.
POST
.
items
()
try
:
c
=
form
.
validate
(
controls
)
except
ValidationFailure
as
e
:
form
.
set_appstruct
(
e
.
cstruct
)
return
dict
(
form
=
form
,
params
=
form_params_edit
)
values
=
dict
(
c
.
items
())
save_request
(
request
,
values
,
values
,
row
)
return
route_list
(
request
)
valus
=
row
.
to_dict
()
values_det
=
row_det
.
to_dict
()
values
=
{}
for
val
in
valus
:
if
valus
[
val
]
!=
None
:
values
[
val
]
=
valus
[
val
]
for
val_det
in
values_det
:
if
values_det
[
val_det
]
!=
None
:
values
[
val_det
]
=
values_det
[
val_det
]
values
[
'id_pel'
]
=
row_det
.
id_pel
form
.
render
(
values
)
return
dict
(
form
=
form
,
params
=
form_params_edit
)
@view_config
(
route_name
=
'api-customer-delete'
,
renderer
=
'templates/form.pt'
,
permission
=
"api-customer-admin"
)
def
view_delete
(
self
):
request
=
self
.
req
# form = get_form(request, EditSchema, (btn_cancel, btn_delete))
form
=
Form
(
colander
.
Schema
(),
EditSchema
,
buttons
=
(
btn_cancel
,
btn_delete
))
for
f
in
form
:
form
[
f
]
.
widget
.
readonly
=
True
query
=
query_id
(
request
)
row
=
query
.
first
()
query2
=
DBSession
.
query
(
H2hArInvoiceDet
)
.
filter
(
H2hArInvoiceDet
.
ar_invoice_id
==
row
.
id
)
row_det
=
query2
.
first
()
if
not
row
:
return
id_not_found
(
request
)
if
request
.
POST
:
if
'delete'
in
request
.
POST
:
request
.
session
.
flash
(
'Data
%
s berhasil dihapus'
%
row
.
cust_inv_no
)
query2
.
delete
()
query
.
delete
()
return
route_list
(
request
)
values
=
row
.
to_dict
()
form
.
render
(
values
)
return
dict
(
form
=
form
,
params
=
{
"scripts"
:
None
})
src/agratek/api/merchant/views/list_vendor.py
View file @
3d893f3
...
...
@@ -48,39 +48,52 @@ class ViewData(BaseView):
# dict(title="Customer"),
dict
(
title
=
"Vendor"
),
dict
(
title
=
"Nama Produk"
),
dict
(
title
=
"TRX Customer"
),
dict
(
title
=
"TRX Vendor"
),
dict
(
title
=
"ID Pelanggan"
),
dict
(
title
=
"TRX Vendor"
),
dict
(
title
=
"Nilai Beli"
),
dict
(
title
=
"Nilai Jual"
),
dict
(
title
=
"Amount Oth 1"
),
dict
(
title
=
"Amount Oth 2"
),
dict
(
title
=
"Amount Oth 3"
),
dict
(
title
=
"Amount Oth 4"
),
dict
(
title
=
"Amount Oth 5"
),
dict
(
title
=
"Sub Total"
),
dict
(
title
=
"Discount"
),
dict
(
title
=
"Nilai Jual"
),
],
'column_data'
:
[
dict
(
data
=
"id"
,
width
=
"0px"
),
# dict(data="customer"),
dict
(
data
=
"vendor"
),
dict
(
data
=
"produk_nama"
),
dict
(
data
=
"cust_trx"
),
dict
(
data
=
"vend_trx"
),
dict
(
data
=
"bill_no"
),
dict
(
data
=
"id_pel"
),
dict
(
data
=
"vend_inv_no"
),
dict
(
data
=
"amt_buy"
),
dict
(
data
=
"amt_sell"
),
dict
(
data
=
"amt_oth1"
),
dict
(
data
=
"amt_oth2"
),
dict
(
data
=
"amt_oth3"
),
dict
(
data
=
"amt_oth4"
),
dict
(
data
=
"amt_oth5"
),
dict
(
data
=
"subtotal"
),
dict
(
data
=
"discount"
),
dict
(
data
=
"amt_sell"
),
],
'buttons'
:
[
dict
(
id
=
"btn_view"
,
cls
=
"btn btn btn-info"
,
title
=
"Detail"
),
dict
(
id
=
"btn_delete"
,
cls
=
"btn btn btn-primary"
,
title
=
"Hapus"
),
dict
(
id
=
"btn_close"
,
cls
=
"btn btn-danger"
,
title
=
"Tutup"
),
],
'route'
:
"/api/vendor"
,
'scripts'
:
"""
$('#btn_view').click(function() {
if (mID) window.location = oTableUri + '/' + mID + '/view';
else
$.SmartMessageBox({
title : "Detail",
content : "Pilih Baris yang akan di lihat...",
buttons : '[Oke]'
});;
});
$('#btn_delete').click(function() {
if (mID) window.location = oTableUri + '/' + mID + '/delete';
else
...
...
@@ -120,16 +133,17 @@ class ViewData(BaseView):
# ColumnDT(Partner.nama, mData='customer'),
ColumnDT
(
Partner
.
nama
,
mData
=
'vendor'
),
ColumnDT
(
Produk
.
nama
,
mData
=
'produk_nama'
),
ColumnDT
(
PartnerLog
.
cust_trx
,
mData
=
'cust_trx'
),
ColumnDT
(
PartnerLog
.
vend_trx
,
mData
=
'vend_trx'
),
ColumnDT
(
PartnerLog
.
bill_no
,
mData
=
'bill_no'
),
ColumnDT
(
PartnerLog
.
id_pel
,
mData
=
'id_pel'
),
ColumnDT
(
PartnerLog
.
vend_inv_no
,
mData
=
'vend_inv_no'
),
ColumnDT
(
PartnerLog
.
amt_buy
,
mData
=
'amt_buy'
),
ColumnDT
(
PartnerLog
.
amt_sell
,
mData
=
'amt_sell'
),
ColumnDT
(
PartnerLog
.
amt_oth1
,
mData
=
'amt_oth1'
),
ColumnDT
(
PartnerLog
.
amt_oth2
,
mData
=
'amt_oth2'
),
ColumnDT
(
PartnerLog
.
amt_oth3
,
mData
=
'amt_oth3'
),
ColumnDT
(
PartnerLog
.
amt_oth4
,
mData
=
'amt_oth4'
),
ColumnDT
(
PartnerLog
.
amt_oth5
,
mData
=
'amt_oth5'
),
ColumnDT
(
PartnerLog
.
subtotal
,
mData
=
'subtotal'
),
ColumnDT
(
PartnerLog
.
discount
,
mData
=
'discount'
),
ColumnDT
(
PartnerLog
.
amt_sell
,
mData
=
'amt_sell'
),
]
query
=
DBSession
.
query
()
.
select_from
(
PartnerLog
)
.
join
(
Produk
,
Produk
.
id
==
PartnerLog
.
produk_id
)
.
join
(
Partner
,
Partner
.
id
==
PartnerLog
.
vendor_id
)
.
\
...
...
src/agratek/api/merchant/views/templates/base.pt
View file @
3d893f3
...
...
@@ -43,6 +43,12 @@
<span
class=
"menu-item-parent"
>
Integrated Test
</span>
</a>
</li>
<li>
<a
href=
"${request._host}/api/customer/list"
>
<i
class=
"fa fa-lg fa-fw fa-home"
></i>
<span
class=
"menu-item-parent"
>
Customer Invoice
</span>
</a>
</li>
</ul>
</html>
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