Fixed codeclimate issues

This commit is contained in:
Sergei Tsõganov 2022-10-12 10:40:03 +03:00
parent 5e6dbac462
commit 59ecfa8e2f
3 changed files with 18 additions and 21 deletions

View file

@ -33,8 +33,7 @@ class SendMonthlyInvoicesJob < ApplicationJob # rubocop:disable Metrics/ClassLen
result = EisBilling::GetMonthlyInvoiceNumbers.send_request(invoice_without_numbers.size)
response = JSON.parse(result.body)
billing_restrictions_issue if response['code'] == '403'
billing_out_of_range_issue if response['error'] == 'out of range'
handle_assign_numbers_response_errors(response)
numbers = response['invoice_numbers']
invoice_without_numbers.each_with_index do |inv, index|
@ -61,11 +60,9 @@ class SendMonthlyInvoicesJob < ApplicationJob # rubocop:disable Metrics/ClassLen
private
def billing_out_of_range_issue
raise 'INVOICE NUMBER LIMIT REACHED, COULD NOT GENERATE INVOICE'
end
def billing_restrictions_issue
raise 'PROBLEM WITH TOKEN'
def handle_assign_numbers_response_errors(response)
raise 'INVOICE NUMBER LIMIT REACHED, COULD NOT GENERATE INVOICE' if response['code'] == '403'
raise 'PROBLEM WITH TOKEN' if response['error'] == 'out of range'
end
end

View file

@ -25,6 +25,19 @@ module Invoice::BookKeeping
invoice
end
def to_e_invoice(payable: true)
generator = Invoice::EInvoiceGenerator.new(self, payable)
generator.generate
end
def do_not_send_e_invoice?
e_invoice_sent? || cancelled?
end
def e_invoice_sent?
e_invoice_sent_at.present?
end
private
def compose_monthly_directo_lines(lines: [])

View file

@ -131,19 +131,6 @@ class Invoice < ApplicationRecord
generator.as_pdf
end
def to_e_invoice(payable: true)
generator = Invoice::EInvoiceGenerator.new(self, payable)
generator.generate
end
def do_not_send_e_invoice?
e_invoice_sent? || cancelled?
end
def e_invoice_sent?
e_invoice_sent_at.present?
end
def as_csv_row
[
number,