app/models/bank_transaction.rb
# For successful binding, reference number, invoice id and sum must match with the invoice
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
For successful binding, reference number, invoice id and sum must match with the invoice
rubocop: disable Metrics/PerceivedComplexity
rubocop: disable Metrics/CyclomaticComplexity
For successful binding reference number invoice id and sum must match with the invoice rubocop : disable Metrics / PerceivedComplexity rubocop : disable Metrics / CyclomaticComplexity
def autobind_invoice
    return if binded?
    registrar = Registrar.find_by(reference_no: reference_no)
    return unless registrar
    match = description.match(/^[^\d]*(\d+)/)
    return unless match
    invoice_no = match[1].to_i
    return unless invoice_no
    invoice = registrar.invoices.find_by(number: invoice_no)
    return unless invoice
    return if invoice.binded?
    return if invoice.cancelled?
    return if invoice.sum != sum
    create_activity(registrar, invoice)
  end
def autobind_invoice return if binded? registrar = Registrar . find_by ( reference_no : reference_no ) return unless registrar match = description . match ( / ^[^ \d ]*( \d +) / ) return unless match invoice_no = match [ 1 ] . to_i return unless invoice_no invoice = registrar . invoices . find_by ( number : invoice_no ) return unless invoice return if invoice . binded? return if invoice . cancelled? return if invoice . sum != sum create_activity ( registrar , invoice ) end
For successful binding, reference number, invoice id and sum must match with the invoice
rubocop: disable Metrics/PerceivedComplexity
rubocop: disable Metrics/CyclomaticComplexity
For successful binding reference number invoice id and sum must match with the invoice rubocop : disable Metrics / PerceivedComplexity rubocop : disable Metrics / CyclomaticComplexity