diff --git a/tailbone_corepos/views/members.py b/tailbone_corepos/views/members.py index f9d4841..28848ef 100644 --- a/tailbone_corepos/views/members.py +++ b/tailbone_corepos/views/members.py @@ -85,6 +85,56 @@ class MemberViewSupplement(ViewSupplement): return [tags.link_to("View CORE-POS Member", url)] +class MemberEquityPaymentViewSupplement(ViewSupplement): + """ + Member view supplement for CORE integration + """ + route_prefix = 'member_equity_payments' + + labels = { + 'corepos_card_number': "CORE-POS Card Number", + 'corepos_transaction_number': "CORE-POS Transaction Number", + 'corepos_transaction_id': "CORE-POS Transaction ID", + 'corepos_department_number': "CORE-POS Department Number", + } + + def get_grid_query(self, query): + model = self.model + return query.outerjoin(model.CoreMemberEquityPayment) + + def configure_grid(self, g): + model = self.model + + g.set_filter('corepos_card_number', model.CoreMemberEquityPayment.corepos_card_number) + g.set_sorter('corepos_card_number', model.CoreMemberEquityPayment.corepos_card_number) + + g.set_filter('corepos_transaction_number', model.CoreMemberEquityPayment.corepos_transaction_number) + g.set_sorter('corepos_transaction_number', model.CoreMemberEquityPayment.corepos_transaction_number) + + g.set_filter('corepos_transaction_id', model.CoreMemberEquityPayment.corepos_transaction_id) + g.set_sorter('corepos_transaction_id', model.CoreMemberEquityPayment.corepos_transaction_id) + + g.set_filter('corepos_department_number', model.CoreMemberEquityPayment.corepos_department_number) + g.set_sorter('corepos_department_number', model.CoreMemberEquityPayment.corepos_department_number) + + g.append('corepos_transaction_number') + g.set_label('corepos_transaction_number', "CORE-POS Trans. No.") + if 'corepos_transaction_number' in g.filters: + g.filters['corepos_transaction_number'].label = self.labels['corepos_transaction_number'] + g.set_link('corepos_transaction_number') + + def configure_form(self, f): + f.append('corepos_card_number') + f.append('corepos_transaction_number') + f.append('corepos_transaction_id') + f.append('corepos_department_number') + + def get_version_child_classes(self): + model = self.model + return [model.CoreMemberEquityPayment] + + def includeme(config): MembershipTypeViewSupplement.defaults(config) MemberViewSupplement.defaults(config) + MemberEquityPaymentViewSupplement.defaults(config)