|  |  | @ -298,7 +298,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         context "when the tenant is not in receipt of applicable benefits" do |  |  |  |         context "when the tenant is not in receipt of applicable benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |           it "correctly resets total shortfall" do |  |  |  |           it "correctly resets total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             case_log.update!(wtshortfall: 100, hb: 9) |  |  |  |             case_log.update!(hbrentshortfall: 2, wtshortfall: 100, hb: 9) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |             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 be_nil |  |  |  |             expect(case_log.wtshortfall).to be_nil | 
			
		
	
		
		
			
				
					
					|  |  |  |             expect(record_from_db["wtshortfall"]).to be_nil |  |  |  |             expect(record_from_db["wtshortfall"]).to be_nil | 
			
		
	
	
		
		
			
				
					|  |  | @ -344,7 +344,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 100, period: 2, hb: 1) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(50.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(50.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(50.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -353,7 +353,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 100, period: 2, hb: 6) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(50.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(50.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(50.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -362,7 +362,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 100, period: 2, hb: 8) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(50.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(50.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(50.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -425,7 +425,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 120, period: 3, hb: 1) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(30.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -434,7 +434,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 120, period: 3, hb: 6) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(30.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -443,7 +443,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 120, period: 3, hb: 8) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(30.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -506,7 +506,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(30.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -515,7 +515,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(30.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -524,7 +524,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(30.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(30.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -587,7 +587,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(125.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(125.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(125.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -596,7 +596,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(125.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(125.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(125.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -605,7 +605,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(125.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(125.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(125.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -668,7 +668,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(122.5) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(122.5) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(122.5) | 
			
		
	
	
		
		
			
				
					|  |  | @ -677,7 +677,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(122.5) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(122.5) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(122.5) | 
			
		
	
	
		
		
			
				
					|  |  | @ -686,7 +686,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(122.5) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(122.5) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(122.5) | 
			
		
	
	
		
		
			
				
					|  |  | @ -749,7 +749,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(120.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(120.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(120.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -758,7 +758,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(120.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(120.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(120.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -767,7 +767,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(120.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(120.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(120.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -830,7 +830,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(117.5) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(117.5) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(117.5) | 
			
		
	
	
		
		
			
				
					|  |  | @ -839,7 +839,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(117.5) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(117.5) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(117.5) | 
			
		
	
	
		
		
			
				
					|  |  | @ -848,7 +848,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, 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] |  |  |  |                 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(case_log.wtshortfall).to eq(117.5) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(117.5) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(117.5) | 
			
		
	
	
		
		
			
				
					|  |  | @ -911,7 +911,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 9, hb: 1) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(115.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(115.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(115.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -920,7 +920,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 9, hb: 6) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(115.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(115.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(115.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -929,7 +929,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 9, hb: 8) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(115.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(115.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(115.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -992,7 +992,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  |           context "when the tenant has an outstanding amount after benefits" do |  |  |  |           context "when the tenant has an outstanding amount after benefits" do | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit" do |  |  |  |             context "when tenant is in receipt of housing benefit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 1) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 1, hb: 1) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(130.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(130.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(130.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -1001,7 +1001,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do |  |  |  |             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 |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 6) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 1, hb: 6) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(130.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(130.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(130.0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -1010,7 +1010,7 @@ RSpec.describe CaseLog do | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do |  |  |  |             context "when tenant is in receipt of housing benefit and universal credit" do | 
			
		
	
		
		
			
				
					
					|  |  |  |               it "correctly derives and saves weekly total shortfall" do |  |  |  |               it "correctly derives and saves weekly total shortfall" do | 
			
		
	
		
		
			
				
					
					|  |  |  |                 case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 8) |  |  |  |                 case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 1, hb: 8) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] |  |  |  |                 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(case_log.wtshortfall).to eq(130.0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(130.0) |  |  |  |                 expect(record_from_db["wtshortfall"]).to eq(130.0) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |