Browse Source

Total charge is inferred

pull/199/head
baarkerlounger 3 years ago
parent
commit
b04100d06b
  1. 3
      app/models/case_log.rb
  2. 18
      spec/models/case_log_spec.rb

3
app/models/case_log.rb

@ -132,7 +132,7 @@ class CaseLog < ApplicationRecord
enum la_known: POLAR, _suffix: true
enum net_income_known: NET_INCOME_KNOWN, _suffix: true
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at renttype lettype is_la_inferred totchild totelder totadult incfreq].freeze
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at renttype lettype is_la_inferred totchild totelder totadult incfreq tcharge].freeze
OPTIONAL_FIELDS = %w[postcode_known
la_known
first_time_property_let_as_social_housing].freeze
@ -245,6 +245,7 @@ private
self.totchild = get_totchild
self.totelder = get_totelder
self.totadult = get_totadult
self.tcharge = brent.to_i + scharge.to_i + pscharge.to_i + supcharg.to_i
end
def get_totelder

18
spec/models/case_log_spec.rb

@ -1178,6 +1178,24 @@ RSpec.describe Form, type: :model do
end
end
context "rent and charges" do
let!(:case_log) do
CaseLog.create({
managing_organisation: organisation,
owning_organisation: organisation,
brent: 5,
scharge: 10,
pscharge: 3,
supcharg: 12
})
end
it "correctly sums rental charges" do
record_from_db = ActiveRecord::Base.connection.execute("select tcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["tcharge"]).to eq(30)
end
end
context "household members derived vars" do
let!(:household_case_log) do
CaseLog.create({

Loading…
Cancel
Save