Skip to content

Instantly share code, notes, and snippets.

@spencerroan
Created October 31, 2015 20:00
Show Gist options
  • Save spencerroan/e83bbe3dbeb8bf12e5ef to your computer and use it in GitHub Desktop.
Save spencerroan/e83bbe3dbeb8bf12e5ef to your computer and use it in GitHub Desktop.
def lines(invoice)
(invoice.lines.count / 100.0).ceil.times.map do |page|
offset = page * 100
invoice.lines.all(count: 100, offset: offset).map do |line|
Stripe::InvoiceItem.construct_from line
end
end.flatten
end
def del_iis(iis)
pb = ProgressBar.new("die", iis.size)
iis.each do |ii|
ii.delete
pb.inc
end
pb.finish
end
def delete_invoice_items_for_customer(cust_id)
invoice = Stripe::Invoice.upcoming(customer: cust_id)
lis = lines(invoice)
iis = lis.select { |line| line.metadata.present? && line.metadata[:invoice_line] == 'cash_issued'}
del_iis(iis)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment