Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free up coupons from cancelled orders #2311

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

michalrus
Copy link
Contributor

Solves #1703

@@ -170,12 +171,14 @@ trait ApiFixtures extends SuiteMixin with HttpSupport with PhoenixAdminApi with
trait CouponFixtureBase {
def couponActiveFrom: Instant = Instant.now.minus(1, DAYS)
def couponActiveTo: Option[Instant] = None
def couponUsageRules: CouponUsageRules =
CouponUsageRules(isUnlimitedPerCode = true, isUnlimitedPerCustomer = true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d argue they shouldn’t have defaults, either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also cake pattern here is pretty unintuitive. I have to

  1. add another method parameter
  2. provide overrideable value that this method uses as a default

instead of

  1. just calling the function with arguments I want

usesPerCustomer = Some(1)
)

// TODO: extract CheckoutFixture and reuse it here (more refactoring will be needed for that) @michalrus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

form ← * <~ ObjectForms.mustFindById400(coupon.formId)
couponUsage ← * <~ CouponUsages
.filterByCoupon(coupon.formId)
def incrementUsageCounts(codeId: Int, customer: User, incrementBy: Int)(implicit ec: EC,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it’s None… just… don’t call it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants