Exemplo n.º 1
0
 def f(p):
     amount = p.giving_today
     if p.old_balance < 0:
         amount -= p.old_balance
     if p.id in holds:
         charge_amount = upcharge(amount)[0]
         if holds[p.id].amount >= charge_amount * 100:
             return
         else:
             # The amount is too low, cancel the hold and make a new one
             cancel_card_hold(holds.pop(p.id))
     hold, error = create_card_hold(self.db, p, amount)
     if error:
         return 1
     else:
         holds[p.id] = hold
Exemplo n.º 2
0
 def f(p):
     amount = p.giving_today
     if p.old_balance < 0:
         amount -= p.old_balance
     if p.id in holds:
         charge_amount = upcharge(amount)[0]
         if holds[p.id].amount >= charge_amount:
             return
         else:
             # The amount is too low, cancel the hold and make a new one
             cancel_card_hold(holds.pop(p.id))
     hold, error = create_card_hold(self.db, p, amount)
     if error:
         return 1
     else:
         holds[p.id] = hold
Exemplo n.º 3
0
        def f(p):
            amount = p.giving_today - p.old_balance

            if p.id in holds:
                if amount >= MINIMUM_CHARGE:
                    charge_amount = upcharge(amount)[0]
                    if holds[p.id].amount >= charge_amount:
                        return
                    else:
                        # The amount is too low, cancel the hold and make a new one
                        cancel_card_hold(holds.pop(p.id))
                else:
                    # not up to minimum charge level. cancel the hold
                    cancel_card_hold(holds.pop(p.id))
                    return
            if amount >= MINIMUM_CHARGE:
                hold, error = create_card_hold(self.db, p, amount)
                if error:
                    return 1
                else:
                    holds[p.id] = hold
Exemplo n.º 4
0
        def f(p):
            amount = p.giving_today - p.old_balance

            if p.id in holds:
                if amount >= MINIMUM_CHARGE:
                    charge_amount = upcharge(amount)[0]
                    if holds[p.id].amount >= charge_amount:
                        return
                    else:
                        # The amount is too low, cancel the hold and make a new one
                        cancel_card_hold(holds.pop(p.id))
                else:
                    # not up to minimum charge level. cancel the hold
                    cancel_card_hold(holds.pop(p.id))
                    return
            if amount >= MINIMUM_CHARGE:
                hold, error = create_card_hold(self.db, p, amount)
                if error:
                    return 1
                else:
                    holds[p.id] = hold