mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 12:47:29 +02:00
Add test rake job for processing dummy payment
This commit is contained in:
parent
fb810e5ccb
commit
76a0b80f85
4 changed files with 27 additions and 10 deletions
|
@ -21,7 +21,7 @@ class SendEInvoiceJob < ApplicationJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def process(invoice:, payable:)
|
def process(invoice:, payable:)
|
||||||
invoice.to_e_invoice(payable: payable).deliver
|
invoice.to_e_invoice(payable: payable).deliver unless Rails.env.development?
|
||||||
invoice.update(e_invoice_sent_at: Time.zone.now)
|
invoice.update(e_invoice_sent_at: Time.zone.now)
|
||||||
log_success(invoice)
|
log_success(invoice)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Invoice::Cancellable
|
||||||
end
|
end
|
||||||
|
|
||||||
def cancelled?
|
def cancelled?
|
||||||
cancelled_at
|
cancelled_at.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def not_cancelled?
|
def not_cancelled?
|
||||||
|
|
|
@ -105,7 +105,7 @@ class Registrar < ApplicationRecord
|
||||||
.deliver_later(wait: 1.minute)
|
.deliver_later(wait: 1.minute)
|
||||||
end
|
end
|
||||||
|
|
||||||
SendEInvoiceJob.perform_later(invoice.id, payable)
|
SendEInvoiceJob.perform_now(invoice.id, payable)
|
||||||
|
|
||||||
invoice
|
invoice
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,30 @@ namespace :invoices do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
process_transactions(incoming_transactions)
|
||||||
|
|
||||||
|
puts "Transactions processed: #{incoming_transactions.size}"
|
||||||
|
end
|
||||||
|
|
||||||
|
task test_payments: :environment do
|
||||||
|
registrar = Invoice.last.buyer
|
||||||
|
transactions = [OpenStruct.new(amount: 0.1,
|
||||||
|
currency: 'EUR',
|
||||||
|
date: Time.zone.today,
|
||||||
|
payment_reference_number: registrar.reference_no,
|
||||||
|
payment_description: "description #{registrar.reference_no}")]
|
||||||
|
process_transactions(transactions)
|
||||||
|
puts 'Last registrar invoice is'
|
||||||
|
pp registrar.invoices.last
|
||||||
|
puts "Last invoice paid at #{registrar.invoices.last.receipt_date}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def log(msg)
|
||||||
|
@log ||= Logger.new(STDOUT)
|
||||||
|
@log.info(msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_transactions(incoming_transactions)
|
||||||
if incoming_transactions.any?
|
if incoming_transactions.any?
|
||||||
log 'Got incoming transactions'
|
log 'Got incoming transactions'
|
||||||
log incoming_transactions
|
log incoming_transactions
|
||||||
|
@ -51,12 +75,5 @@ namespace :invoices do
|
||||||
else
|
else
|
||||||
log 'Got no incoming transactions parsed, aborting'
|
log 'Got no incoming transactions parsed, aborting'
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Transactions processed: #{incoming_transactions.size}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def log(msg)
|
|
||||||
@log ||= Logger.new(STDOUT)
|
|
||||||
@log.info(msg)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue