mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
add task Id: 3713, reference: 1706002/VL, stripe id: in_1ASRQy2sOmf47Nz9Xpxtw46A, invoice total: 30.0, stripe invoice total: 80.0, date: 2017-06-08 16:16:26 +0200
Id: 3716, reference: 1706005/VL, stripe id: in_1ASRye2sOmf47Nz9utkjPDve, invoice total: 30.0, stripe invoice total: 40.0, date: 2017-06-08 16:51:15 +0200 Id: 3717, reference: 1706006/VL, stripe id: in_1ASS1X2sOmf47Nz93Xn2UxVh, invoice total: 30.0, stripe invoice total: 40.0, date: 2017-06-08 16:54:14 +0200 Id: 3718, reference: 1706007/VL, stripe id: in_1ASSBI2sOmf47Nz9Ol0gEEfC, invoice total: 30.0, stripe invoice total: 40.0, date: 2017-06-08 17:04:19 +0200 allow find the invoices incoherent
This commit is contained in:
parent
511bd320f5
commit
2ff47f3204
@ -1,5 +1,7 @@
|
||||
# Changelog Fab Manager
|
||||
|
||||
- add task `rake fablab:get_incoherent_invoice` allow find the invoices incoherent
|
||||
|
||||
## v2.5.7 2017 June 8
|
||||
|
||||
- Portuguese and Brazilian support
|
||||
|
@ -202,6 +202,11 @@ class Invoice < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# get amount total paid
|
||||
def amount_paid
|
||||
total - (wallet_amount ? wallet_amount : 0)
|
||||
end
|
||||
|
||||
private
|
||||
def generate_and_send_invoice
|
||||
unless Rails.env.test?
|
||||
|
@ -304,4 +304,22 @@ namespace :fablab do
|
||||
p.save
|
||||
end
|
||||
end
|
||||
|
||||
desc 'get incoherent invoice'
|
||||
task :get_incoherent_invoice, [:start_date] => :environment do |task, args|
|
||||
date = Date.parse('2017-05-01')
|
||||
if args.start_date
|
||||
begin
|
||||
date = Date.parse(args.start_date)
|
||||
rescue => e
|
||||
fail e
|
||||
end
|
||||
end
|
||||
Invoice.where('created_at > ? AND stp_invoice_id IS NOT NULL', date).each do |invoice|
|
||||
stp_invoice = Stripe::Invoice.retrieve(invoice.stp_invoice_id)
|
||||
if invoice.amount_paid != stp_invoice.total
|
||||
puts "Id: #{invoice.id}, reference: #{invoice.reference}, stripe id: #{stp_invoice.id}, invoice total: #{invoice.amount_paid / 100.0}, stripe invoice total: #{stp_invoice.total / 100.0}, date: #{invoice.created_at}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user