Skip to content

[Card Locking] Move to a time-based upload requirement#13705

Open
manuthecoder wants to merge 20 commits into
mainfrom
mxg-improve-receipt-card-locking-requirements
Open

[Card Locking] Move to a time-based upload requirement#13705
manuthecoder wants to merge 20 commits into
mainfrom
mxg-improve-receipt-card-locking-requirements

Conversation

@manuthecoder
Copy link
Copy Markdown
Contributor

@manuthecoder manuthecoder commented May 10, 2026

Closes #13194 by moving card locking to a time based requirement

Comment thread app/services/user_service/send_card_locking_notification.rb
Comment thread app/services/user_service/update_card_locking.rb
Comment thread spec/models/user/card_locking_spec.rb Outdated
Comment thread spec/models/user/card_locking_spec.rb Outdated
Comment thread spec/models/user/card_locking_spec.rb Outdated
Comment thread spec/services/user_service/update_card_locking_spec.rb Outdated
Comment thread spec/services/user_service/update_card_locking_spec.rb Outdated
Comment thread spec/models/user/card_locking_spec.rb Outdated
Comment thread spec/models/user/card_locking_spec.rb Outdated
Comment thread spec/models/user/card_locking_spec.rb Outdated
Comment thread spec/services/user_service/update_card_locking_spec.rb Outdated
Comment thread spec/services/user_service/update_card_locking_spec.rb Outdated
@manuthecoder manuthecoder marked this pull request as ready for review May 13, 2026 19:01
@manuthecoder manuthecoder requested review from a team and Copilot May 13, 2026 19:01

This comment was marked as resolved.

manuthecoder and others added 2 commits May 13, 2026 22:56
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exclude HcbCodes marked no-or-lost from no-receipt scope
Remove obsolete spec covering unlock-only card lock behavior
@manuthecoder manuthecoder linked an issue May 22, 2026 that may be closed by this pull request
manuthecoder and others added 5 commits May 26, 2026 13:31
Co-authored-by: Claude <noreply@anthropic.com>
The second describe block expected HTTP 201 but the controller returns
200, and stubbed StripeService::PaymentIntent.create after donation
creation — a call the payment_intent action never makes. The first
block already covers this endpoint correctly.

https://claude.ai/code/session_016PnTwan62ypAyZNpohFLaH
Add an early return in User#cards_should_lock? to immediately lock
when total missing receipts reach the hard threshold. Update
create_settled_card_charge to accept an optional stripe_card and add
specs for locking when violations reach the violation threshold and
when total missing receipts hit the hard threshold without violations.
Comment thread app/models/hcb_code.rb Outdated
Comment on lines +668 to +671
canonical_transactions.select { |ct| ct.amount_cents.negative? }.min_by(&:created_at)&.created_at
else
canonical_transactions.expense.minimum(:created_at)
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
canonical_transactions.select { |ct| ct.amount_cents.negative? }.min_by(&:created_at)&.created_at
else
canonical_transactions.expense.minimum(:created_at)
end
canonical_transactions.select { |ct| ct.amount_cents.negative? }.min_by(&:created_at)&.created_at
else
canonical_transactions.expense.minimum(:created_at)
end

expect {
service.run
}.to change { user.reload.cards_locked? }.from(false).to(true)
.and have_enqueued_mail(CardLockingMailer, :cards_locked)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.and have_enqueued_mail(CardLockingMailer, :cards_locked)
.and have_enqueued_mail(CardLockingMailer, :cards_locked)

expect {
service.run
}.to change { user.reload.cards_locked? }.from(true).to(false)
.and have_enqueued_mail(CardLockingMailer, :cards_unlocked)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.and have_enqueued_mail(CardLockingMailer, :cards_unlocked)
.and have_enqueued_mail(CardLockingMailer, :cards_unlocked)

Add @total_missing_count and memoize card_locking_missing_receipts.
Update
locked_message and cards_locked view to show an alternate message when
there
are no 72-hour violations and to hide the violations table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Card Locking] Move to a time-based upload requirement

3 participants