mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 04:07:33 +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
|
||||
|
||||
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)
|
||||
log_success(invoice)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Invoice::Cancellable
|
|||
end
|
||||
|
||||
def cancelled?
|
||||
cancelled_at
|
||||
cancelled_at.present?
|
||||
end
|
||||
|
||||
def not_cancelled?
|
||||
|
|
|
@ -105,7 +105,7 @@ class Registrar < ApplicationRecord
|
|||
.deliver_later(wait: 1.minute)
|
||||
end
|
||||
|
||||
SendEInvoiceJob.perform_later(invoice.id, payable)
|
||||
SendEInvoiceJob.perform_now(invoice.id, payable)
|
||||
|
||||
invoice
|
||||
end
|
||||
|
|
|
@ -22,6 +22,30 @@ namespace :invoices do
|
|||
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?
|
||||
log 'Got incoming transactions'
|
||||
log incoming_transactions
|
||||
|
@ -51,12 +75,5 @@ namespace :invoices do
|
|||
else
|
||||
log 'Got no incoming transactions parsed, aborting'
|
||||
end
|
||||
|
||||
puts "Transactions processed: #{incoming_transactions.size}"
|
||||
end
|
||||
|
||||
def log(msg)
|
||||
@log ||= Logger.new(STDOUT)
|
||||
@log.info(msg)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue