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 6aa5f382
authored
Sep 20, 2019
by
Tatang
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ketuker
1 parent
9e225abb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
157 additions
and
166 deletions
src/agratek/api/merchant/views/payment_list.py
src/agratek/api/merchant/views/purchase_list.py
src/agratek/api/merchant/views/templates/payment/list.pt
src/agratek/api/merchant/views/templates/purchase/list.pt
src/agratek/api/merchant/views/payment_list.py
View file @
6aa5f38
...
...
@@ -4,10 +4,10 @@ from deform import widget, Form, ValidationFailure
from
opensipkd.base.views
import
DataTables
from
pyramid.httpexceptions
import
HTTPFound
from
pyramid.view
import
view_config
from
sqlalchemy
import
func
from
sqlalchemy
.orm
import
aliased
from
.
import
BaseView
from
..models
import
(
DBSession
,
H2hArInvoice
,
H2hArInvoiceDet
,
Partner
)
from
..models
import
(
DBSession
,
PartnerPay
,
Partner
)
from
opensipkd.base.tools
import
format_json
from
opensipkd.base.tools.db
import
column_concat
...
...
@@ -18,12 +18,6 @@ status_payment = (
(
2
,
'Batal'
),
)
invoice_type
=
(
(
0
,
'--None--'
),
(
1
,
'Purchase'
),
(
2
,
'Register'
),
)
def
form_validator
(
form
,
value
):
pass
...
...
@@ -35,10 +29,9 @@ class ViewData(BaseView):
renderer
=
'templates/payment/list.pt'
)
def
view_list
(
self
):
class
ToolbarSchema
(
colander
.
Schema
):
inv_type
=
colander
.
SchemaNode
(
colander
.
Integer
(),
default
=
1
,
oid
=
"inv_type"
,
widget
=
widget
.
SelectWidget
(
values
=
invoice_type
,
css_class
=
'form-toolbar'
)
status
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"status"
,
widget
=
widget
.
SelectWidget
(
values
=
status_payment
,
css_class
=
'form-toolbar'
)
)
toolbar
=
ToolbarSchema
(
Validator
=
form_validator
)
...
...
@@ -47,18 +40,22 @@ class ViewData(BaseView):
params
=
{
'form'
:
form
,
'
invoice_type'
:
[
k
and
s
or
'-'
for
k
,
s
in
invoice_type
],
'
status_payment'
:
[
s
for
k
,
s
in
status_payment
if
k
>
-
1
],
'columns'
:
[
dict
(
title
=
"ID"
),
dict
(
title
=
"No. Invoice"
),
dict
(
title
=
"Customer"
),
dict
(
title
=
"Jenis"
),
dict
(
title
=
"Vendor"
),
dict
(
title
=
"Amount"
),
dict
(
title
=
"Status"
),
],
'column_data'
:
[
dict
(
data
=
"id"
,
width
=
"0px"
),
dict
(
data
=
"nomor"
,
width
=
"150px"
),
dict
(
data
=
"customer"
),
dict
(
data
=
"inv_type"
,
width
=
"100px"
),
dict
(
data
=
"vendor"
),
dict
(
data
=
"amount"
,
width
=
"100px"
),
dict
(
data
=
"status"
,
width
=
"100px"
),
],
'buttons'
:
[
dict
(
id
=
"btn_view"
,
cls
=
"btn btn btn-primary"
,
title
=
"View"
),
...
...
@@ -82,17 +79,34 @@ class ViewData(BaseView):
url_dict
=
request
.
matchdict
act
=
url_dict
[
'act'
]
if
act
==
"grid"
:
jenis
=
'jenis'
in
request
.
params
and
request
.
params
[
'jenis'
]
and
int
(
request
.
params
[
'jenis'
])
or
None
status
=
-
1
if
'status'
in
request
.
params
:
status
=
int
(
request
.
params
[
'status'
])
vendor
=
aliased
(
Partner
,
name
=
'vendor'
)
customer
=
aliased
(
Partner
,
name
=
'customer'
)
columns
=
[
ColumnDT
(
H2hArInvoice
.
id
,
mData
=
'id'
),
ColumnDT
(
H2hArInvoice
.
cust_inv_no
,
mData
=
'nomor'
),
ColumnDT
(
Partner
.
nama
,
mData
=
'customer'
),
ColumnDT
(
func
.
coalesce
(
H2hArInvoice
.
cust_inv_type
,
0
),
mData
=
'inv_type'
),
ColumnDT
(
PartnerPay
.
id
,
mData
=
'id'
),
ColumnDT
(
PartnerPay
.
cust_inv_no
,
mData
=
'nomor'
),
ColumnDT
(
column_concat
([
PartnerPay
.
inv_cust_nm
,
' - ('
,
customer
.
nama
,
')'
]),
mData
=
'customer'
),
ColumnDT
(
vendor
.
nama
,
mData
=
'vendor'
),
ColumnDT
(
PartnerPay
.
amt_sell
,
mData
=
'amount'
),
ColumnDT
(
PartnerPay
.
status
,
mData
=
'status'
),
]
query
=
DBSession
.
query
()
.
select_from
(
H2hArInvoice
)
\
.
join
(
Partner
,
Partner
.
id
==
H2hArInvoice
.
customer_id
)
query
=
query
.
filter
(
H2hArInvoice
.
cust_inv_type
==
jenis
)
query
=
DBSession
.
query
()
.
select_from
(
PartnerPay
)
\
.
join
(
vendor
,
vendor
.
id
==
PartnerPay
.
vendor_id
)
\
.
join
(
customer
,
customer
.
id
==
PartnerPay
.
customer_id
)
if
status
>
-
1
:
query
=
query
.
filter
(
PartnerPay
.
status
==
status
)
row_table
=
DataTables
(
request
.
GET
,
query
,
columns
)
return
row_table
.
output_result
()
...
...
@@ -103,19 +117,75 @@ class ViewData(BaseView):
request
=
self
.
req
url_dict
=
request
.
matchdict
view_id
=
url_dict
[
'id'
]
data
=
H2hArInvoice
.
query_id
(
id
=
view_id
)
.
first
()
data
=
PartnerPay
.
query_id
(
id
=
view_id
)
.
first
()
params
=
dict
(
form
=
None
)
if
data
:
customer
=
'{cust} - ({merc})'
.
format
(
cust
=
data
.
inv_cust_nm
,
merc
=
data
.
customer
.
nama
)
form_list
=
(
(
'inv_no'
,
data
.
cust_inv_no
or
''
,
'text'
),
(
'customer'
,
data
.
customer
.
nama
,
'text'
),
(
'amount'
,
data
.
amount
or
0
,
'text'
),
(
'vend_inv_no'
,
data
.
vend_inv_no
or
''
,
'text'
),
(
'cust_inv_no'
,
data
.
cust_inv_no
or
''
,
'text'
),
(
'tx_id'
,
data
.
tx_id
or
''
,
'text'
),
(
'vendor'
,
data
.
vendor
.
nama
,
'text'
),
(
'produk'
,
data
.
produk
.
nama
,
'text'
),
# ('id_pel', data.id_pel or '', 'text'),
(
'customer'
,
customer
,
'text'
),
(
'cust_addr'
,
data
.
inv_cust_addr
or
''
,
'text'
),
(
'cust_phone'
,
data
.
inv_cust_phone
or
''
,
'text'
),
(
'cust_email'
,
data
.
inv_cust_email
or
''
,
'text'
),
(
'cust_city'
,
data
.
inv_cust_city
or
''
,
'text'
),
(
'cust_state'
,
data
.
inv_cust_state
or
''
,
'text'
),
(
'cust_pos'
,
data
.
inv_cust_pos
or
''
,
'text'
),
(
'cust_country'
,
data
.
inv_cust_country
or
''
,
'text'
),
# ('inv_valid_date', data.description, 'text'),
# ('inv_valid_time', data.description, 'text'),
# ('inv_time_stamp', data.description, 'text'),
# ('inv_cust_va', data.description, 'text'),
#
# ('delivery_addr', data.description, 'text'),
# ('delivery_city', data.description, 'text'),
# ('delivery_country', data.description, 'text'),
# ('delivery_nm', data.description, 'text'),
# ('delivery_phone', data.description, 'text'),
# ('delivery_pos', data.description, 'text'),
# ('delivery_state', data.description, 'text'),
# ('delivery_email', data.description, 'text'),
# ('subtotal', data.subtotal, 'text'),
# ('discount', data.discount, 'text'),
# ('amt_sell', data.amt_sell, 'text'),
(
'inquiry'
,
format_json
(
data
.
inquiry
),
'textarea'
),
(
'payment'
,
format_json
(
data
.
payment
),
'textarea'
),
(
'advice'
,
format_json
(
data
.
advice
),
'textarea'
),
(
'notify'
,
format_json
(
data
.
notify
),
'textarea'
),
(
'cancel'
,
format_json
(
data
.
cancel
),
'textarea'
),
(
'cart'
,
format_json
(
data
.
cart
),
'textarea'
),
# ('notes', data.notes, 'text'),
# ('description', data.description, 'text'),
# ('fee', data.description, 'text'),
# ('instmnt_mon', data.description, 'text'),
# ('instmnt_type', data.description, 'text'),
# ('recurr_opt', data.description, 'text'),
# ('m_ref_no', data.description, 'text'),
# ('notax_amt', data.description, 'text'),
# ('pay_valid_dt', data.description, 'text'),
# ('pay_valid_tm', data.description, 'text'),
#
# ('req_dt', data.description, 'text'),
# ('req_tm', data.description, 'text'),
#
# ('vat', data.description, 'text'),
# ('trans_dt', data.description, 'text'),
# ('trans_tm', data.description, 'text'),
# ('card_no', data.description, 'text'),
# ('callback_url', data.description, 'text'),
)
sm
=
colander
.
Schema
()
...
...
src/agratek/api/merchant/views/purchase_list.py
View file @
6aa5f38
...
...
@@ -4,18 +4,16 @@ from deform import widget, Form, ValidationFailure
from
opensipkd.base.views
import
DataTables
from
pyramid.httpexceptions
import
HTTPFound
from
pyramid.view
import
view_config
from
sqlalchemy
.orm
import
aliased
from
sqlalchemy
import
func
from
.
import
BaseView
from
..models
import
(
DBSession
,
PartnerPay
,
Partner
)
from
..models
import
(
DBSession
,
H2hArInvoice
,
H2hArInvoiceDet
,
Partner
)
from
opensipkd.base.tools
import
format_json
from
opensipkd.base.tools.db
import
column_concat
status_payment
=
(
(
-
1
,
'--Semua--'
),
(
0
,
'Pending'
),
(
1
,
'Sukses'
),
(
2
,
'Batal'
),
invoice_type
=
(
(
0
,
'--None--'
),
(
1
,
'Payment'
),
(
2
,
'Register'
),
)
...
...
@@ -29,9 +27,10 @@ class ViewData(BaseView):
renderer
=
'templates/purchase/list.pt'
)
def
view_list
(
self
):
class
ToolbarSchema
(
colander
.
Schema
):
status
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"status"
,
widget
=
widget
.
SelectWidget
(
values
=
status_payment
,
css_class
=
'form-toolbar'
)
inv_type
=
colander
.
SchemaNode
(
colander
.
Integer
(),
default
=
1
,
oid
=
"inv_type"
,
widget
=
widget
.
SelectWidget
(
values
=
invoice_type
,
css_class
=
'form-toolbar'
)
)
toolbar
=
ToolbarSchema
(
Validator
=
form_validator
)
...
...
@@ -40,22 +39,18 @@ class ViewData(BaseView):
params
=
{
'form'
:
form
,
'
status_payment'
:
[
s
for
k
,
s
in
status_payment
if
k
>
-
1
],
'
invoice_type'
:
[
k
and
s
or
'-'
for
k
,
s
in
invoice_type
],
'columns'
:
[
dict
(
title
=
"ID"
),
dict
(
title
=
"No. Invoice"
),
dict
(
title
=
"Customer"
),
dict
(
title
=
"Vendor"
),
dict
(
title
=
"Amount"
),
dict
(
title
=
"Status"
),
dict
(
title
=
"Jenis"
),
],
'column_data'
:
[
dict
(
data
=
"id"
,
width
=
"0px"
),
dict
(
data
=
"nomor"
,
width
=
"150px"
),
dict
(
data
=
"customer"
),
dict
(
data
=
"vendor"
),
dict
(
data
=
"amount"
,
width
=
"100px"
),
dict
(
data
=
"status"
,
width
=
"100px"
),
dict
(
data
=
"inv_type"
,
width
=
"100px"
),
],
'buttons'
:
[
dict
(
id
=
"btn_view"
,
cls
=
"btn btn btn-primary"
,
title
=
"View"
),
...
...
@@ -79,34 +74,17 @@ class ViewData(BaseView):
url_dict
=
request
.
matchdict
act
=
url_dict
[
'act'
]
if
act
==
"grid"
:
status
=
-
1
if
'status'
in
request
.
params
:
status
=
int
(
request
.
params
[
'status'
])
vendor
=
aliased
(
Partner
,
name
=
'vendor'
)
customer
=
aliased
(
Partner
,
name
=
'customer'
)
jenis
=
'jenis'
in
request
.
params
and
request
.
params
[
'jenis'
]
and
int
(
request
.
params
[
'jenis'
])
or
None
columns
=
[
ColumnDT
(
PartnerPay
.
id
,
mData
=
'id'
),
ColumnDT
(
PartnerPay
.
cust_inv_no
,
mData
=
'nomor'
),
ColumnDT
(
column_concat
([
PartnerPay
.
inv_cust_nm
,
' - ('
,
customer
.
nama
,
')'
]),
mData
=
'customer'
),
ColumnDT
(
vendor
.
nama
,
mData
=
'vendor'
),
ColumnDT
(
PartnerPay
.
amt_sell
,
mData
=
'amount'
),
ColumnDT
(
PartnerPay
.
status
,
mData
=
'status'
),
ColumnDT
(
H2hArInvoice
.
id
,
mData
=
'id'
),
ColumnDT
(
H2hArInvoice
.
cust_inv_no
,
mData
=
'nomor'
),
ColumnDT
(
Partner
.
nama
,
mData
=
'customer'
),
ColumnDT
(
func
.
coalesce
(
H2hArInvoice
.
cust_inv_type
,
0
),
mData
=
'inv_type'
),
]
query
=
DBSession
.
query
()
.
select_from
(
PartnerPay
)
\
.
join
(
vendor
,
vendor
.
id
==
PartnerPay
.
vendor_id
)
\
.
join
(
customer
,
customer
.
id
==
PartnerPay
.
customer_id
)
if
status
>
-
1
:
query
=
query
.
filter
(
PartnerPay
.
status
==
status
)
query
=
DBSession
.
query
()
.
select_from
(
H2hArInvoice
)
\
.
join
(
Partner
,
Partner
.
id
==
H2hArInvoice
.
customer_id
)
query
=
query
.
filter
(
H2hArInvoice
.
cust_inv_type
==
jenis
)
row_table
=
DataTables
(
request
.
GET
,
query
,
columns
)
return
row_table
.
output_result
()
...
...
@@ -117,75 +95,19 @@ class ViewData(BaseView):
request
=
self
.
req
url_dict
=
request
.
matchdict
view_id
=
url_dict
[
'id'
]
data
=
PartnerPay
.
query_id
(
id
=
view_id
)
.
first
()
data
=
H2hArInvoice
.
query_id
(
id
=
view_id
)
.
first
()
params
=
dict
(
form
=
None
)
if
data
:
customer
=
'{cust} - ({merc})'
.
format
(
cust
=
data
.
inv_cust_nm
,
merc
=
data
.
customer
.
nama
)
form_list
=
(
(
'vend_inv_no'
,
data
.
vend_inv_no
or
''
,
'text'
),
(
'cust_inv_no'
,
data
.
cust_inv_no
or
''
,
'text'
),
(
'tx_id'
,
data
.
tx_id
or
''
,
'text'
),
(
'vendor'
,
data
.
vendor
.
nama
,
'text'
),
(
'produk'
,
data
.
produk
.
nama
,
'text'
),
# ('id_pel', data.id_pel or '', 'text'),
(
'customer'
,
customer
,
'text'
),
(
'cust_addr'
,
data
.
inv_cust_addr
or
''
,
'text'
),
(
'cust_phone'
,
data
.
inv_cust_phone
or
''
,
'text'
),
(
'cust_email'
,
data
.
inv_cust_email
or
''
,
'text'
),
(
'cust_city'
,
data
.
inv_cust_city
or
''
,
'text'
),
(
'cust_state'
,
data
.
inv_cust_state
or
''
,
'text'
),
(
'cust_pos'
,
data
.
inv_cust_pos
or
''
,
'text'
),
(
'cust_country'
,
data
.
inv_cust_country
or
''
,
'text'
),
# ('inv_valid_date', data.description, 'text'),
# ('inv_valid_time', data.description, 'text'),
# ('inv_time_stamp', data.description, 'text'),
# ('inv_cust_va', data.description, 'text'),
#
# ('delivery_addr', data.description, 'text'),
# ('delivery_city', data.description, 'text'),
# ('delivery_country', data.description, 'text'),
# ('delivery_nm', data.description, 'text'),
# ('delivery_phone', data.description, 'text'),
# ('delivery_pos', data.description, 'text'),
# ('delivery_state', data.description, 'text'),
# ('delivery_email', data.description, 'text'),
# ('subtotal', data.subtotal, 'text'),
# ('discount', data.discount, 'text'),
# ('amt_sell', data.amt_sell, 'text'),
(
'inv_no'
,
data
.
cust_inv_no
or
''
,
'text'
),
(
'customer'
,
data
.
customer
.
nama
,
'text'
),
(
'amount'
,
data
.
amount
or
0
,
'text'
),
(
'inquiry'
,
format_json
(
data
.
inquiry
),
'textarea'
),
(
'payment'
,
format_json
(
data
.
payment
),
'textarea'
),
(
'advice'
,
format_json
(
data
.
advice
),
'textarea'
),
(
'notify'
,
format_json
(
data
.
notify
),
'textarea'
),
(
'cancel'
,
format_json
(
data
.
cancel
),
'textarea'
),
(
'cart'
,
format_json
(
data
.
cart
),
'textarea'
),
# ('notes', data.notes, 'text'),
# ('description', data.description, 'text'),
# ('fee', data.description, 'text'),
# ('instmnt_mon', data.description, 'text'),
# ('instmnt_type', data.description, 'text'),
# ('recurr_opt', data.description, 'text'),
# ('m_ref_no', data.description, 'text'),
# ('notax_amt', data.description, 'text'),
# ('pay_valid_dt', data.description, 'text'),
# ('pay_valid_tm', data.description, 'text'),
#
# ('req_dt', data.description, 'text'),
# ('req_tm', data.description, 'text'),
#
# ('vat', data.description, 'text'),
# ('trans_dt', data.description, 'text'),
# ('trans_tm', data.description, 'text'),
# ('card_no', data.description, 'text'),
# ('callback_url', data.description, 'text'),
)
sm
=
colander
.
Schema
()
...
...
@@ -211,4 +133,3 @@ class ViewData(BaseView):
params
[
'form'
]
=
form
return
dict
(
params
=
params
)
src/agratek/api/merchant/views/templates/payment/list.pt
View file @
6aa5f38
...
...
@@ -56,8 +56,8 @@
var oTableUrl = oTableUri + "/grid/act";
function getDataUrl() {
var opt = $('select#
inv_type
').val();
return oTableUrl + '?
jeni
s=' + opt.toString();
var opt = $('select#
status
').val();
return oTableUrl + '?
statu
s=' + opt.toString();
}
function getViewUrl(vid) {
...
...
@@ -82,18 +82,20 @@
[10, 25, 50, 100],
[10, 25, 50, 100]
],
columns: [
{'data': 'id', 'width': '0px'},
{'data': 'nomor', 'width': '150px'},
{'data': 'customer'},
{'data': 'inv_type', 'width': '100px',
'render': function(data, type, full, meta) {
var st = ${params.invoice_type};
return st[data];
}
}
],
//columns: ${params.column_data},
// columns: [
// {'data': 'id', 'width': '0px'},
// {'data': 'nomor', 'width': '150px'},
// {'data': 'customer'},
// {'data': 'vendor'},
// {'data': 'amount', 'width': '100px'},
// {'data': 'status', 'width': '100px',
// 'render': function(data, type, full, meta) {
// var st = ${params.status_payment};
// return st[data];
// }
// }
// ],
columns: ${params.column_data},
columnDefs: [{
searchable: false,
visible: false,
...
...
@@ -148,6 +150,7 @@
$('#btn_view').click(function() {
if (mID) {
//window.location = oTableUri + '/' + mID + '/view';
$('#payment-view').modal('show');
} else {
$.SmartMessageBox({
...
...
@@ -170,7 +173,7 @@
}
});
$('select#
inv_type
').on('change', function() {
$('select#
status
').on('change', function() {
mID = 0;
oTable.ajax.url(getDataUrl()).load();
});
...
...
src/agratek/api/merchant/views/templates/purchase/list.pt
View file @
6aa5f38
...
...
@@ -56,8 +56,8 @@
var oTableUrl = oTableUri + "/grid/act";
function getDataUrl() {
var opt = $('select#
status
').val();
return oTableUrl + '?
statu
s=' + opt.toString();
var opt = $('select#
inv_type
').val();
return oTableUrl + '?
jeni
s=' + opt.toString();
}
function getViewUrl(vid) {
...
...
@@ -82,20 +82,18 @@
[10, 25, 50, 100],
[10, 25, 50, 100]
],
// columns: [
// {'data': 'id', 'width': '0px'},
// {'data': 'nomor', 'width': '150px'},
// {'data': 'customer'},
// {'data': 'vendor'},
// {'data': 'amount', 'width': '100px'},
// {'data': 'status', 'width': '100px',
// 'render': function(data, type, full, meta) {
// var st = ${params.status_payment};
// return st[data];
// }
// }
// ],
columns: ${params.column_data},
columns: [
{'data': 'id', 'width': '0px'},
{'data': 'nomor', 'width': '150px'},
{'data': 'customer'},
{'data': 'inv_type', 'width': '100px',
'render': function(data, type, full, meta) {
var st = ${params.invoice_type};
return st[data];
}
}
],
//columns: ${params.column_data},
columnDefs: [{
searchable: false,
visible: false,
...
...
@@ -150,7 +148,6 @@
$('#btn_view').click(function() {
if (mID) {
//window.location = oTableUri + '/' + mID + '/view';
$('#payment-view').modal('show');
} else {
$.SmartMessageBox({
...
...
@@ -173,7 +170,7 @@
}
});
$('select#
status
').on('change', function() {
$('select#
inv_type
').on('change', function() {
mID = 0;
oTable.ajax.url(getDataUrl()).load();
});
...
...
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