def _ensure_card_providers(): """ Creates a list of default card providers """ log.info("Creating Card Providers") from stoqlib.domain.payment.card import CreditProvider, CardPaymentDevice providers = { u'VISA': u'VISA', u'MASTER': u'MASTERCARD', u'AMEX': u'AMERICAN EXPRESS' } store = new_store() for short_name, provider_id in providers.items(): provider = CreditProvider.get_provider_by_provider_id( provider_id, store) if not provider.is_empty(): continue CreditProvider(short_name=short_name, provider_id=providers[short_name], open_contract_date=TransactionTimestamp(), store=store) devices = store.find(CardPaymentDevice) if devices.is_empty(): CardPaymentDevice(store=store, description=_(u'Default')) store.commit(close=True)
def _ensure_card_providers(): """ Creates a list of default card providers """ log.info("Creating Card Providers") from stoqlib.domain.payment.card import CreditProvider, CardPaymentDevice providers = [u'VISANET', u'REDECARD', u'AMEX', u'HIPERCARD', u'BANRISUL', u'PAGGO', u'CREDISHOP', u'CERTIF'] store = new_store() for name in providers: provider = CreditProvider.get_provider_by_provider_id(name, store) if not provider.is_empty(): continue CreditProvider(short_name=name, provider_id=name, open_contract_date=TransactionTimestamp(), store=store) devices = store.find(CardPaymentDevice) if devices.is_empty(): CardPaymentDevice(store=store, description=_(u'Default')) store.commit(close=True)
def create_model(self, store): return CardPaymentDevice(store=store)
def _get_card_device(self, store, name): device = store.find(CardPaymentDevice, description=name).any() if not device: device = CardPaymentDevice(store=store, description=name) return device
def create_card_device(self, description=u'Cielo'): from stoqlib.domain.payment.card import CardPaymentDevice return CardPaymentDevice(store=self.store, description=description)