|
|
|
@ -334,6 +334,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(50.0) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(50.0) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 0, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(50.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(50.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 0, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(50.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(50.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 0, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(50.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(50.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when rent is paid every 4 weeks" do |
|
|
|
@ -371,6 +400,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(30.0) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(30.0) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 1, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(30.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(30.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 1, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(30.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(30.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 1, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(30.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(30.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when rent is paid every calendar month" do |
|
|
|
@ -408,6 +466,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(30.0) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(30.0) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 2, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(30.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(30.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 2, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(30.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(30.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 2, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(30.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(30.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when rent is paid weekly for 50 weeks" do |
|
|
|
@ -445,6 +532,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(125.0) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(125.0) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 3, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(125.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(125.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 3, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(125.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(125.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 3, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(125.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(125.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when rent is paid weekly for 49 weeks" do |
|
|
|
@ -482,6 +598,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(122.5) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(122.5) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(122.5) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(122.5) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(122.5) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(122.5) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(122.5) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(122.5) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when rent is paid weekly for 48 weeks" do |
|
|
|
@ -519,6 +664,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(120.0) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(120.0) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(120.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(120.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(120.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(120.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(120.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(120.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when rent is paid weekly for 47 weeks" do |
|
|
|
@ -556,6 +730,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(117.5) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(117.5) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(117.5) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(117.5) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(117.5) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(117.5) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(117.5) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(117.5) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when rent is paid weekly for 46 weeks" do |
|
|
|
@ -593,6 +796,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(115.0) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(115.0) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(115.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(115.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(115.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(115.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(115.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(115.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when rent is paid weekly for 52 weeks" do |
|
|
|
@ -630,6 +862,35 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(case_log.wtcharge).to eq(130.0) |
|
|
|
|
expect(record_from_db["wtcharge"]).to eq(130.0) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the tenant has an outstanding amount after benefits" do |
|
|
|
|
context "when tenant is in receipt of housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 1) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(130.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(130.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 6) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(130.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(130.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when tenant is in receipt of housing benefit and universal credit" do |
|
|
|
|
it "correctly derives and saves weekly total shortfall" do |
|
|
|
|
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 8) |
|
|
|
|
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |
|
|
|
|
expect(case_log.wtshortfall).to eq(130.0) |
|
|
|
|
expect(record_from_db["wtshortfall"]).to eq(130.0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|