dscf-credit 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffb129fd2b6a19f2fc1e13b11230f188a2848716bf6f72306ef482bbb16f3292
4
- data.tar.gz: d2ce58e6ead4cb20a94721d5795e1a868911fd191a0698bc42a159a601fb1138
3
+ metadata.gz: 1443779ba67dff25e894c91b282acabdd8e6872728ced4a0dd9066a935da2c12
4
+ data.tar.gz: 141228623b227b54ac146125203dde6bb4adcb40a1c3e39e81062b5e64f50aa9
5
5
  SHA512:
6
- metadata.gz: 29ecb72c0d5604cce920c9afd8bd3421448813b07169c41babe58b445f264330c39c27df49f11668b10e249bc35ea94db9277a18a7c01df686a6e04f0dcb871d
7
- data.tar.gz: f5220dbd0d24d4654a25477c03cb93a37bab731a21bb144c2288d3c17fe083e7d23bfe299cfad77caf66ce7c9fae4875c70729f8cf33e78c463eaba3b72a1bfa
6
+ metadata.gz: 5991cb4fb11b1adbd0ca101d7ed8a27cf6f3f91f634f56aeb800477d1f275c586916d47bf5c5a0a70f657f331d68fdd1c5a77564aa6047103d71d5468eb31ce8
7
+ data.tar.gz: 60d7fec2c04ceb1f5485f4b8cbcf39375219be4ae6e5c79a21ea204203eb6ade319a1709dd90eacc62ec362baf8ed25bb376341aae929c2cadab8de04a4e217b
@@ -312,14 +312,20 @@ module Dscf::Credit
312
312
 
313
313
  # Create an eligible credit line record with the calculated limit
314
314
  #
315
- # Creates a new EligibleCreditLine associated with the loan profile,
316
- # setting both credit_limit and available_limit to the calculated amount.
317
- # Risk is initially set to nil.
315
+ # Finds an existing EligibleCreditLine for the loan profile and credit line combination.
316
+ # If one already exists, it skips creation and returns the existing record to prevent
317
+ # duplicates. If none exists, creates a new one with the calculated limits.
318
+ #
319
+ # This ensures that existing eligible credit lines are preserved with their current
320
+ # available_limit values (which may have been reduced by loan disbursements).
318
321
  #
319
322
  # @param credit_line [CreditLine] The credit line to create eligibility for
320
323
  # @param limit [Float] The calculated credit limit
321
- # @return [EligibleCreditLine] The created eligible credit line record
324
+ # @return [EligibleCreditLine, nil] The existing or newly created eligible credit line record, or nil if already exists
322
325
  def create_eligible_credit_line(credit_line, limit)
326
+ existing = loan_profile.eligible_credit_lines.find_by(credit_line: credit_line)
327
+ return existing if existing
328
+
323
329
  loan_profile.eligible_credit_lines.create!(
324
330
  credit_line: credit_line,
325
331
  credit_limit: limit,
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Credit
3
- VERSION = "0.3.6"
3
+ VERSION = "0.3.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-credit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adoniyas
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-14 00:00:00.000000000 Z
10
+ date: 2025-10-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: dscf-core