2018-11-22 11:16:59 -06:00
|
|
|
# -*- coding: utf-8; -*-
|
|
|
|
"""
|
|
|
|
CORE-POS transaction views
|
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import unicode_literals, absolute_import
|
|
|
|
|
|
|
|
from corepos.trans.db import model as coretrans
|
|
|
|
|
|
|
|
from .master import CoreMasterView
|
|
|
|
from rattail_demo.web.db import CoreTransSession
|
|
|
|
|
2018-11-22 20:38:36 -06:00
|
|
|
from rattail_corepos.corepos.importing.square import FromSquareToCoreTrans
|
|
|
|
|
2018-11-22 11:16:59 -06:00
|
|
|
|
|
|
|
class TransactionDetailView(CoreMasterView):
|
|
|
|
"""
|
|
|
|
Master view for transaction details.
|
|
|
|
"""
|
|
|
|
Session = CoreTransSession
|
|
|
|
model_class = coretrans.TransactionDetail
|
|
|
|
model_title = "CORE-POS Transaction Detail"
|
|
|
|
url_prefix = '/corepos/transaction-details'
|
|
|
|
route_prefix = 'corepos.transaction_details'
|
2018-11-22 20:38:36 -06:00
|
|
|
deletable = True
|
|
|
|
bulk_deletable = True
|
|
|
|
supports_import_batch_from_file = True
|
2018-11-22 11:16:59 -06:00
|
|
|
|
|
|
|
labels = {
|
|
|
|
'store_row_id': "Store Row ID",
|
|
|
|
'store_id': "Store ID",
|
|
|
|
'pos_row_id': "POS Row ID",
|
|
|
|
'transaction_id': "Transaction ID",
|
|
|
|
'upc': "UPC",
|
|
|
|
}
|
|
|
|
|
|
|
|
grid_columns = [
|
|
|
|
'date_time',
|
|
|
|
'register_number',
|
|
|
|
'transaction_number',
|
|
|
|
'card_number',
|
|
|
|
'upc',
|
|
|
|
'department_number',
|
|
|
|
'description',
|
|
|
|
'quantity',
|
|
|
|
'unit_price',
|
|
|
|
'discount',
|
|
|
|
'total',
|
|
|
|
]
|
|
|
|
|
2018-11-22 20:38:36 -06:00
|
|
|
def get_bulk_delete_session(self):
|
|
|
|
from corepos.trans.db import Session as CoreTransSession
|
|
|
|
|
|
|
|
return CoreTransSession()
|
|
|
|
|
2018-11-22 11:16:59 -06:00
|
|
|
def configure_grid(self, g):
|
|
|
|
super(TransactionDetailView, self).configure_grid(g)
|
|
|
|
|
|
|
|
g.set_type('date_time', 'datetime_local')
|
|
|
|
g.set_type('quantity', 'quantity')
|
|
|
|
g.set_type('unit_price', 'currency')
|
|
|
|
g.set_type('discount', 'currency')
|
|
|
|
g.set_type('total', 'currency')
|
|
|
|
|
|
|
|
g.set_sort_defaults('date_time', 'desc')
|
|
|
|
|
|
|
|
g.set_label('register_number', "Register")
|
|
|
|
g.set_label('transaction_number', "Trans. No.")
|
|
|
|
g.set_label('card_number', "Card No.")
|
|
|
|
g.set_label('department_number', "Dept. No.")
|
|
|
|
|
|
|
|
g.set_link('upc')
|
|
|
|
g.set_link('description')
|
|
|
|
|
|
|
|
def configure_form(self, f):
|
|
|
|
super(TransactionDetailView, self).configure_form(f)
|
|
|
|
|
|
|
|
f.set_type('date_time', 'datetime_local')
|
|
|
|
f.set_type('quantity', 'quantity')
|
|
|
|
f.set_type('unit_price', 'currency')
|
|
|
|
f.set_type('discount', 'currency')
|
|
|
|
f.set_type('total', 'currency')
|
|
|
|
|
2018-11-22 20:38:36 -06:00
|
|
|
def import_square(self):
|
|
|
|
return self.import_batch_from_file(FromSquareToCoreTrans, 'TransactionDetail',
|
|
|
|
importer_host_title="Square CSV")
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def defaults(cls, config):
|
|
|
|
route_prefix = cls.get_route_prefix()
|
|
|
|
url_prefix = cls.get_url_prefix()
|
|
|
|
permission_prefix = cls.get_permission_prefix()
|
|
|
|
|
|
|
|
# import from square
|
|
|
|
config.add_route('{}.import_square'.format(route_prefix), '{}/import-square'.format(url_prefix))
|
|
|
|
config.add_view(cls, attr='import_square', route_name='{}.import_square'.format(route_prefix),
|
|
|
|
permission='{}.import_file'.format(permission_prefix))
|
|
|
|
|
|
|
|
cls._defaults(config)
|
|
|
|
|
2018-11-22 11:16:59 -06:00
|
|
|
|
|
|
|
def includeme(config):
|
|
|
|
TransactionDetailView.defaults(config)
|