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:
		
							parent
							
								
									e20a9b8123
								
							
						
					
					
						commit
						b7512e0b31
					
				
					 4 changed files with 43 additions and 1 deletions
				
			
		|  | @ -10,6 +10,8 @@ from corepos.trans.db import model as coretrans | |||
| from .master import CoreMasterView | ||||
| from rattail_demo.web.db import CoreTransSession | ||||
| 
 | ||||
| from rattail_corepos.corepos.importing.square import FromSquareToCoreTrans | ||||
| 
 | ||||
| 
 | ||||
| class TransactionDetailView(CoreMasterView): | ||||
|     """ | ||||
|  | @ -20,6 +22,9 @@ class TransactionDetailView(CoreMasterView): | |||
|     model_title = "CORE-POS Transaction Detail" | ||||
|     url_prefix = '/corepos/transaction-details' | ||||
|     route_prefix = 'corepos.transaction_details' | ||||
|     deletable = True | ||||
|     bulk_deletable = True | ||||
|     supports_import_batch_from_file = True | ||||
| 
 | ||||
|     labels = { | ||||
|         'store_row_id': "Store Row ID", | ||||
|  | @ -43,6 +48,11 @@ class TransactionDetailView(CoreMasterView): | |||
|         'total', | ||||
|     ] | ||||
| 
 | ||||
|     def get_bulk_delete_session(self): | ||||
|         from corepos.trans.db import Session as CoreTransSession | ||||
| 
 | ||||
|         return CoreTransSession() | ||||
| 
 | ||||
|     def configure_grid(self, g): | ||||
|         super(TransactionDetailView, self).configure_grid(g) | ||||
| 
 | ||||
|  | @ -71,6 +81,23 @@ class TransactionDetailView(CoreMasterView): | |||
|         f.set_type('discount', '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): | ||||
|     TransactionDetailView.defaults(config) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar