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 _get_provider(self, store, name): name = name.strip() name = self.PROVIDER_MAP.get(name, name) provider = store.find(CreditProvider, provider_id=name).one() if not provider: provider = CreditProvider(store=store, short_name=name, provider_id=name) return provider
def _ensure_card_providers(): """ Creates a list of default card providers """ log.info("Creating Card Providers") from stoqlib.domain.payment.card import CreditProvider 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) store.commit(close=True)
def create_model(self, store): return CreditProvider(store=store)
def process_one(self, data, fields, store): CreditProvider(open_contract_date=TransactionTimestamp(), short_name=data.provider_name, store=store)
def create_credit_provider(self, short_name=u'Velec'): from stoqlib.domain.payment.card import CreditProvider return CreditProvider(store=self.store, short_name=short_name, open_contract_date=localdate(2006, 01, 01).date())