Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/jobs/invoice/mark_depositeds_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class Invoice
class MarkDepositedsJob < ApplicationJob
queue_as :default
def perform
Invoice.where(aasm_state: :paid_v2).find_in_batches(batch_size: 100) do |batch|
batch.each do |invoice|
if invoice.canonical_transactions.count >= 2 || invoice.manually_marked_as_paid? || invoice.completed_deprecated?
invoice.mark_deposited!
end
end
end
end

end

end
18 changes: 18 additions & 0 deletions app/jobs/one_time_jobs/backfill_deposited_state_for_invoices.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module OneTimeJobs
class BackfillDepositedStateForInvoices
queue_as :default

def perform
Invoice.find_in_batches(batch_size: 100) do |batch|
batch.each do |invoice|
if invoice.deposited?
invoice.update_column(:aasm_state, :deposited_v2)
end
end
end
end

end
end
7 changes: 3 additions & 4 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,11 @@ def archived?
end

def deposited? # TODO move to aasm
canonical_transactions.count >= 2 || manually_marked_as_paid? || completed_deprecated?
deposited_v2? || canonical_transactions.count >= 2 || manually_marked_as_paid? || completed_deprecated?
end

def state
return :success if paid_v2? && deposited?
return :success if paid_v2? && event.can_front_balance?
return :success if (paid_v2? && event.can_front_balance?) || deposited?
return :success if manually_marked_as_paid?
return :info if paid_v2?
return :error if void_v2?
Expand All @@ -244,7 +243,7 @@ def state
end

def state_text
return "Deposited" if paid_v2? && (event.can_front_balance? || deposited?)
return "Deposited" if (paid_v2? && event.can_front_balance?) || deposited?
return "In Transit" if paid_v2?
return "Paid" if manually_marked_as_paid?
return "Voided" if void_v2?
Expand Down
4 changes: 4 additions & 0 deletions config/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ invoice_opens_to_paids_job:
cron: "30 * * * *" # run every hour
class: "Invoice::OpensToPaidsJob"

invoice_mark_depositeds_job:
cron: "30 * * * *" # run every hour
class: "Invoice::MarkDepositedsJob"

donation_nightly_job:
cron: "*/30 * * * *" # run every 30 minutes
class: "Donation::NightlyJob"
Expand Down
Loading