mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 06:56:23 +02:00
change logic for generate invoice
This commit is contained in:
parent
ccd9260ce8
commit
c2969fa877
6 changed files with 32 additions and 29 deletions
|
@ -13,7 +13,7 @@ module Admin
|
||||||
|
|
||||||
if @invoice&.persisted?
|
if @invoice&.persisted?
|
||||||
flash[:notice] = t(:record_created)
|
flash[:notice] = t(:record_created)
|
||||||
send_invoice_data_to_billing_system
|
# send_invoice_data_to_billing_system
|
||||||
redirect_to [:admin, @invoice]
|
redirect_to [:admin, @invoice]
|
||||||
else
|
else
|
||||||
flash.now[:alert] = t(:failed_to_create_record)
|
flash.now[:alert] = t(:failed_to_create_record)
|
||||||
|
@ -102,13 +102,13 @@ module Admin
|
||||||
invoices.where(account_activities: { created_at: date_from..date_until })
|
invoices.where(account_activities: { created_at: date_from..date_until })
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_invoice_data_to_billing_system
|
# def send_invoice_data_to_billing_system
|
||||||
add_invoice_instance = EisBilling::AddDeposits.new(@invoice)
|
# add_invoice_instance = EisBilling::AddDeposits.new(@invoice)
|
||||||
result = add_invoice_instance.send_invoice
|
# result = add_invoice_instance.send_invoice
|
||||||
|
|
||||||
link = JSON.parse(result.body)['everypay_link']
|
# link = JSON.parse(result.body)['everypay_link']
|
||||||
|
|
||||||
@invoice.update(payment_link: link)
|
# @invoice.update(payment_link: link)
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
module EisBilling
|
module EisBilling
|
||||||
class BaseController < ApplicationController
|
class BaseController < ApplicationController
|
||||||
|
# load_and_authorize_resource
|
||||||
|
|
||||||
skip_authorization_check # Temporary solution
|
skip_authorization_check # Temporary solution
|
||||||
skip_before_action :verify_authenticity_token # Temporary solution
|
skip_before_action :verify_authenticity_token # Temporary solution
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,9 @@ module EisBilling
|
||||||
sum = params[:standing_amount]
|
sum = params[:standing_amount]
|
||||||
everypay_response = params
|
everypay_response = params
|
||||||
|
|
||||||
|
logger.info 'REQUEST FROM BILLING'
|
||||||
|
logger.info params
|
||||||
|
|
||||||
payment_status = define_payment_status(params[:payment_state])
|
payment_status = define_payment_status(params[:payment_state])
|
||||||
|
|
||||||
invoice = Invoice.find_by(number: invoice_number)
|
invoice = Invoice.find_by(number: invoice_number)
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Registrar
|
||||||
|
|
||||||
if @invoice
|
if @invoice
|
||||||
flash[:notice] = t(:please_pay_the_following_invoice)
|
flash[:notice] = t(:please_pay_the_following_invoice)
|
||||||
send_invoice_data_to_billing_system
|
# send_invoice_data_to_billing_system
|
||||||
redirect_to [:registrar, @invoice]
|
redirect_to [:registrar, @invoice]
|
||||||
else
|
else
|
||||||
flash[:alert] = @deposit.errors.full_messages.join(', ')
|
flash[:alert] = @deposit.errors.full_messages.join(', ')
|
||||||
|
@ -22,18 +22,14 @@ class Registrar
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def send_invoice_data_to_billing_system
|
# def send_invoice_data_to_billing_system
|
||||||
add_invoice_instance = EisBilling::AddDeposits.new(@invoice)
|
# add_invoice_instance = EisBilling::AddDeposits.new(@invoice)
|
||||||
result = add_invoice_instance.send_invoice
|
# result = add_invoice_instance.send_invoice
|
||||||
|
|
||||||
Rails.logger.info "Deposits controller ------->"
|
# link = JSON.parse(result.body)['everypay_link']
|
||||||
Rails.logger.info result.body
|
|
||||||
Rails.logger.info "-----------------------------------------"
|
|
||||||
|
|
||||||
link = JSON.parse(result.body)['everypay_link']
|
# @invoice.update(payment_link: link)
|
||||||
|
# end
|
||||||
@invoice.update(payment_link: link)
|
|
||||||
end
|
|
||||||
|
|
||||||
def deposit_params
|
def deposit_params
|
||||||
params.require(:deposit).permit(:amount, :description)
|
params.require(:deposit).permit(:amount, :description)
|
||||||
|
|
|
@ -107,15 +107,21 @@ class Registrar < ApplicationRecord
|
||||||
.deliver_later(wait: 1.minute)
|
.deliver_later(wait: 1.minute)
|
||||||
end
|
end
|
||||||
|
|
||||||
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
|
unless Rails.env.staging?
|
||||||
|
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
|
||||||
|
end
|
||||||
|
|
||||||
# add_invoice_instance = EisBilling::AddDeposits.new(invoice)
|
add_invoice_instance = EisBilling::AddDeposits.new(invoice)
|
||||||
# result = add_invoice_instance.send_invoice
|
result = add_invoice_instance.send_invoice
|
||||||
|
|
||||||
# Rails.logger.info "Invoice created from transaction ------->"
|
link = JSON.parse(result.body)['everypay_link']
|
||||||
# Rails.logger.info invoice
|
|
||||||
# Rails.logger.info result.body
|
invoice.update(payment_link: link)
|
||||||
# Rails.logger.info "-----------------------------------------"
|
|
||||||
|
Rails.logger.info "Invoice created from transaction ------->"
|
||||||
|
Rails.logger.info invoice
|
||||||
|
Rails.logger.info result.body
|
||||||
|
Rails.logger.info "-----------------------------------------"
|
||||||
|
|
||||||
invoice
|
invoice
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
module EisBilling
|
module EisBilling
|
||||||
class GetInvoiceNumber < EisBilling::Base
|
class GetInvoiceNumber < EisBilling::Base
|
||||||
def self.send_invoice
|
def self.send_invoice
|
||||||
p "+++++++++++"
|
|
||||||
Rails.logger.info invoice_number_generator_url
|
|
||||||
p "+++++++++++"
|
|
||||||
|
|
||||||
send_request
|
send_request
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue