def prepare_direct_debit(db, route, amount): """Prepare to debit a bank account. """ assert isinstance(amount, (Decimal, Money)), type(amount) assert route.network == 'mango-ba' participant = route.participant amount = Money(amount, 'EUR') if isinstance(amount, Decimal) else amount debit_amount, fee, vat = upcharge_direct_debit(amount) amount = debit_amount - fee status = 'pre' if route.mandate else 'pre-mandate' return record_exchange(db, route, amount, fee, vat, participant, status)
def prepare_direct_debit(db, route, amount): """Prepare to debit a bank account. """ assert isinstance(amount, (Decimal, Money)), type(amount) assert route.network == 'mango-ba' participant = route.participant amount = Money(amount, 'EUR') if isinstance(amount, Decimal) else amount debit_amount, fee, vat = upcharge_direct_debit(amount) amount = debit_amount - fee status = 'pre' if route.mandate else 'pre-mandate' return record_exchange(db, route, amount, fee, vat, participant, status)
def prepare_direct_debit(db, route, amount): """Prepare to debit a bank account. """ typecheck(amount, Decimal) assert route.network == 'mango-ba' participant = route.participant debit_amount, fee, vat = upcharge_direct_debit(amount) amount = debit_amount - fee if not participant.mangopay_wallet_id: create_wallet(db, participant) status = 'pre' if route.mandate else 'pre-mandate' return record_exchange(db, route, amount, fee, vat, participant, status)