mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 14:36:22 +02:00
fixed tests
This commit is contained in:
parent
36d629fe2b
commit
c9ed31771b
4 changed files with 35 additions and 49 deletions
|
@ -9,10 +9,6 @@ module EisBilling
|
|||
before_action :load_invoice, only: :update
|
||||
|
||||
def update
|
||||
p '=========='
|
||||
p params
|
||||
p '=========='
|
||||
|
||||
if @invoice.update(modified_params) && payment_orders_handler
|
||||
|
||||
render json: {
|
||||
|
@ -30,43 +26,27 @@ module EisBilling
|
|||
private
|
||||
|
||||
def payment_orders_handler
|
||||
p '-----'
|
||||
p @invoice.cancelled?
|
||||
p status.issued?
|
||||
p status
|
||||
p '------'
|
||||
|
||||
if @invoice.payment_orders.present?
|
||||
if @invoice.cancelled? && status.paid? || @invoice.cancelled? && status.issued?
|
||||
@invoice.errors.add(:base, 'Unable to change status of record')
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
if @invoice.paid? && (status.failed? || status.cancelled?)
|
||||
@invoice.errors.add(:base, 'Unable to change status of record')
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return true if (@invoice.paid? && status.paid?) || (@invoice.unpaid? && status.issued?) || (@invoice.cancelled? && status.cancelled?)
|
||||
|
||||
if status.issued?
|
||||
@invoice.cancel_manualy
|
||||
elsif status.paid?
|
||||
@invoice.autobind_manually
|
||||
else
|
||||
@invoice.cancel
|
||||
end
|
||||
else
|
||||
return unless status.paid?
|
||||
return false if @invoice.cancelled? && status.paid? || @invoice.cancelled? && status.issued?
|
||||
return false if @invoice.paid? && (status.failed? || status.cancelled?)
|
||||
|
||||
case
|
||||
when @invoice.paid? && status.paid?
|
||||
true
|
||||
when @invoice.unpaid? && status.issued?
|
||||
true
|
||||
when @invoice.cancelled? && (status.cancelled? || status.failed?)
|
||||
true
|
||||
when status.issued?
|
||||
@invoice.cancel_manualy
|
||||
when status.paid?
|
||||
@invoice.autobind_manually
|
||||
else
|
||||
@invoice.cancel
|
||||
end
|
||||
end
|
||||
|
||||
def status
|
||||
status = case params[:status][:status]
|
||||
status = case params[:status]
|
||||
when 'paid'
|
||||
'paid'
|
||||
when 'cancelled'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue