Add feature demo for importing Square transactions to CORE-POS

also allow delete of CORE-POS transactions, for sake of demo
This commit is contained in:
Lance Edgar 2018-11-22 20:38:36 -06:00
parent e20a9b8123
commit b7512e0b31
4 changed files with 43 additions and 1 deletions

View file

@ -0,0 +1,11 @@
## -*- coding: utf-8; -*-
<%inherit file="/master/index.mako" />
<%def name="context_menu_items()">
${parent.context_menu_items()}
% if request.has_perm('{}.import_file'.format(permission_prefix)):
<li>${h.link_to("Import {} from Square CSV".format(model_title_plural), url('{}.import_square'.format(route_prefix)))}</li>
% endif
</%def>
${parent.body()}

View file

@ -97,7 +97,7 @@
</li> </li>
% endif % endif
% if request.has_any_perm('batch.handheld.list', 'batch.inventory.list'): % if request.has_any_perm('batch.handheld.list', 'batch.inventory.list', 'batch.importer.list'):
<li> <li>
<a>Batches</a> <a>Batches</a>
<ul> <ul>
@ -107,6 +107,9 @@
% if request.has_perm('batch.inventory.list'): % if request.has_perm('batch.inventory.list'):
<li>${h.link_to("Inventory", url('batch.inventory'))}</li> <li>${h.link_to("Inventory", url('batch.inventory'))}</li>
% endif % endif
% if request.has_perm('batch.importer.list'):
<li>${h.link_to("Import / Export", url('batch.importer'))}</li>
% endif
</ul> </ul>
</li> </li>
% endif % endif

View file

@ -41,3 +41,4 @@ def includeme(config):
# batch views # batch views
config.include('tailbone.views.handheld') config.include('tailbone.views.handheld')
config.include('tailbone.views.inventory') config.include('tailbone.views.inventory')
config.include('tailbone.views.batch.importer')

View file

@ -10,6 +10,8 @@ from corepos.trans.db import model as coretrans
from .master import CoreMasterView from .master import CoreMasterView
from rattail_demo.web.db import CoreTransSession from rattail_demo.web.db import CoreTransSession
from rattail_corepos.corepos.importing.square import FromSquareToCoreTrans
class TransactionDetailView(CoreMasterView): class TransactionDetailView(CoreMasterView):
""" """
@ -20,6 +22,9 @@ class TransactionDetailView(CoreMasterView):
model_title = "CORE-POS Transaction Detail" model_title = "CORE-POS Transaction Detail"
url_prefix = '/corepos/transaction-details' url_prefix = '/corepos/transaction-details'
route_prefix = 'corepos.transaction_details' route_prefix = 'corepos.transaction_details'
deletable = True
bulk_deletable = True
supports_import_batch_from_file = True
labels = { labels = {
'store_row_id': "Store Row ID", 'store_row_id': "Store Row ID",
@ -43,6 +48,11 @@ class TransactionDetailView(CoreMasterView):
'total', 'total',
] ]
def get_bulk_delete_session(self):
from corepos.trans.db import Session as CoreTransSession
return CoreTransSession()
def configure_grid(self, g): def configure_grid(self, g):
super(TransactionDetailView, self).configure_grid(g) super(TransactionDetailView, self).configure_grid(g)
@ -71,6 +81,23 @@ class TransactionDetailView(CoreMasterView):
f.set_type('discount', 'currency') f.set_type('discount', 'currency')
f.set_type('total', 'currency') f.set_type('total', 'currency')
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)
def includeme(config): def includeme(config):
TransactionDetailView.defaults(config) TransactionDetailView.defaults(config)