Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonhoc committed Sep 23, 2024
1 parent eccc75d commit 5ee9381
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
5 changes: 3 additions & 2 deletions modules/mobile/app/models/mobile/v0/debt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ class Debt < Common::Resource
attribute :id, Types::String
attribute :file_number, Types::String.optional.default(nil)
attribute :payee_number, Types::String.optional.default(nil)
attribute :person_entitled, Types::String.optional.default(nil)
attribute :deduction_code, Types::String.optional.default(nil)
attribute :benefit_type, Types::String.optional.default(nil)
attribute :diary_code, Types::String.optional.default(nil)
attribute :diary_code_description, Types::String.optional.default(nil)
attribute :amount_overpaid, Types::Float.optional.default(nil)
attribute :amount_withheld, Types::Float.optional.default(nil)
attribute :original_a_r, Types::Float.optional.default(nil)
attribute :current_a_r, Types::Float.optional.default(nil)
attribute :original_ar, Types::Float.optional.default(nil)
attribute :current_ar, Types::Float.optional.default(nil)
attribute :debt_history, Types::Array do
attribute :date, Types::Date
attribute :letter_code, Types::String
Expand Down
58 changes: 33 additions & 25 deletions modules/mobile/app/serializers/mobile/v0/debts_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ class DebtsSerializer

set_type :debts

attributes :fileNumber,
:payeeNumber,
:personEntitled,
:deductionCode,
:benefitType,
:diaryCode,
:diaryCodeDescription,
:amountOverpaid,
:amountWithheld,
:originalAR,
:currentAR,
:debtHistory
attributes :file_number,
:payee_number,
:person_entitled,
:deduction_code,
:benefit_type,
:diary_code,
:diary_code_description,
:amount_overpaid,
:amount_withheld,
:original_ar,
:current_ar,
:debt_history

def initialize(debts, id = nil)
resource = if debts.is_a? Array
Expand All @@ -33,23 +33,31 @@ def initialize(debts, id = nil)
private

def dependent_debts?(debts)
Array.wrap(debts).any? { |debt| debt.payee_number != '00' }
Array.wrap(debts).any? { |debt| debt['payeeNumber'] != '00' }
end

def serialize_debt(debt, id = nil)
debt_history = Array.wrap(debt['debtHistory']).map do |history|
{
date: history['date'],
letter_code: history['letterCode'],
description: history['description']
}
end

Debt.new(id: id || debt['id'],
fileNumber: debt['fileNumber'],
payeeNumber: debt['payeeNumber'],
personEntitled: debt['personEntitled'],
deductionCode: debt['deductionCode'],
benefitType: debt['benefitType'],
diaryCode: debt['diaryCode'],
diaryCodeDescription: debt['diaryCodeDescription'],
amountOverpaid: debt['amountOverpaid'],
amountWithheld: debt['amountWithheld'],
originalAR: debt['originalAR'],
currentAR: debt['currentAR'],
debtHistory: debt['debtHistory'])
file_number: debt['fileNumber'],
payee_number: debt['payeeNumber'],
person_entitled: debt['personEntitled'],
deduction_code: debt['deductionCode'],
benefit_type: debt['benefitType'],
diary_code: debt['diaryCode'],
diary_code_description: debt['diaryCodeDescription'],
amount_overpaid: debt['amountOverpaid'],
amount_withheld: debt['amountWithheld'],
original_ar: debt['originalAR'],
current_ar: debt['currentAR'],
debt_history:)
end
end
end
Expand Down

0 comments on commit 5ee9381

Please sign in to comment.