5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/jobs/tang/import_invoices_job.rb', line 5
def perform(starting_after = nil)
stripe_invoices = Stripe::Invoice.list(limit: 100, starting_after: starting_after)
stripe_invoices.each do |stripe_invoice|
invoice = Invoice.from_stripe(stripe_invoice)
if invoice.present?
stripe_invoice.lines.data.each do |stripe_invoice_item|
InvoiceItem.from_stripe(stripe_invoice_item, invoice)
end
end
end
if stripe_invoices.has_more
Tang::ImportInvoicesJob.perform_now(stripe_invoices.data.last.id)
end
end
|