diff --git a/modules/mobile/app/models/mobile/v0/debt.rb b/modules/mobile/app/models/mobile/v0/debt.rb index 82610a3a6f6..ab02abc9341 100644 --- a/modules/mobile/app/models/mobile/v0/debt.rb +++ b/modules/mobile/app/models/mobile/v0/debt.rb @@ -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 diff --git a/modules/mobile/app/serializers/mobile/v0/debts_serializer.rb b/modules/mobile/app/serializers/mobile/v0/debts_serializer.rb index b33db1f5397..3005c884406 100644 --- a/modules/mobile/app/serializers/mobile/v0/debts_serializer.rb +++ b/modules/mobile/app/serializers/mobile/v0/debts_serializer.rb @@ -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 @@ -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