Browse Source

allow first month free to be applied anytime

tags/v0.9.18
Jonathan Cobb 4 years ago
parent
commit
20a7075eca
1 changed files with 15 additions and 15 deletions
  1. +15
    -15
      bubble-server/src/main/java/bubble/cloud/payment/promo/firstMonthFree/FirstMonthFreePaymentDriver.java

+ 15
- 15
bubble-server/src/main/java/bubble/cloud/payment/promo/firstMonthFree/FirstMonthFreePaymentDriver.java View File

@@ -21,11 +21,11 @@ public class FirstMonthFreePaymentDriver extends PromotionalPaymentDriverBase<Pr


@Override public boolean addPromoToAccount(Promotion promo, Account caller) { @Override public boolean addPromoToAccount(Promotion promo, Account caller) {
// caller must not have any bills // caller must not have any bills
final int billCount = billDAO.countByAccount(caller.getUuid());
if (billCount != 0) {
log.warn("applyPromo: promo="+promo.getName()+", account="+caller.getName()+", account must have no Bills, found "+billCount+" bills");
return false;
}
// final int billCount = billDAO.countByAccount(caller.getUuid());
// if (billCount != 0) {
// log.warn("applyPromo: promo="+promo.getName()+", account="+caller.getName()+", account must have no Bills, found "+billCount+" bills");
// return false;
// }
// does the caller already have one of these? // does the caller already have one of these?
final List<AccountPaymentMethod> existingCreditPaymentMethods = paymentMethodDAO.findByAccountAndCloud(caller.getUuid(), promo.getCloud()); final List<AccountPaymentMethod> existingCreditPaymentMethods = paymentMethodDAO.findByAccountAndCloud(caller.getUuid(), promo.getCloud());
if (!empty(existingCreditPaymentMethods)) { if (!empty(existingCreditPaymentMethods)) {
@@ -50,16 +50,16 @@ public class FirstMonthFreePaymentDriver extends PromotionalPaymentDriverBase<Pr
AccountPlan accountPlan, AccountPlan accountPlan,
AccountPaymentMethod paymentMethod) { AccountPaymentMethod paymentMethod) {
// must have exactly one bill, this bill // must have exactly one bill, this bill
final List<Bill> bills = billDAO.findByAccount(accountPlan.getAccount());
if (bills.size() != 1 || !bills.get(0).getUuid().equals(bill.getUuid())) {
return false;
}
// must not have used this promotion before
final List<AccountPaymentMethod> existingFirstMonthFree = paymentMethodDAO.findByAccountAndCloud(accountPlan.getAccount(), promo.getCloud());
if (existingFirstMonthFree.size() != 1 || !existingFirstMonthFree.get(0).getPromotion().equals(promo.getUuid())) {
return false;
}
// final List<Bill> bills = billDAO.findByAccount(accountPlan.getAccount());
// if (bills.size() != 1 || !bills.get(0).getUuid().equals(bill.getUuid())) {
// return false;
// }
//
// // must not have used this promotion before
// final List<AccountPaymentMethod> existingFirstMonthFree = paymentMethodDAO.findByAccountAndCloud(accountPlan.getAccount(), promo.getCloud());
// if (existingFirstMonthFree.size() != 1 || !existingFirstMonthFree.get(0).getPromotion().equals(promo.getUuid())) {
// return false;
// }


return super.canUseNow(bill, promo, promoDriver, promos, usable, accountPlan, paymentMethod); return super.canUseNow(bill, promo, promoDriver, promos, usable, accountPlan, paymentMethod);
} }


Loading…
Cancel
Save