Skip to content

Commit

Permalink
RST-5527 Display SOP code not BEC code (#1450)
Browse files Browse the repository at this point in the history
* Display SOP code not BEC code
* Return part payment if exists
  • Loading branch information
zaparka authored Jul 21, 2023
1 parent 10dfa01 commit c46249d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/models/views/reports/raw_data_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RawDataExport
id: 'id',
name: 'office',
jurisdiction: 'jurisdiction',
bec_code: 'BEC code',
sop_code: 'SOP code',
fee: 'fee',
estimated_amount_to_pay: 'estimated applicant pay',
estimated_cost: 'estimated cost',
Expand Down Expand Up @@ -130,7 +130,7 @@ def named_columns
offices.name AS name,
details.emergency_reason IS NOT NULL AS emergency,
jurisdictions.name AS jurisdiction,
business_entities.be_code AS bec_code,
business_entities.sop_code AS sop_code,
part_payments.outcome AS pp_outcome,
CASE WHEN applications.reference LIKE 'HWF%' THEN 'digital' ELSE 'paper' END AS source,
CASE WHEN de.id IS NULL THEN false ELSE true END AS granted,
Expand Down
7 changes: 6 additions & 1 deletion app/services/part_payment_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ def initialize(initiator, expires_in_days)
end

def decide!
@application.create_part_payment(expires_at: expires_at) if part_payment_needed?
create_part_payment if part_payment_needed?
end

private

def create_part_payment
return @application.part_payment if @application.part_payment
@application.create_part_payment(expires_at: expires_at)
end

def load_application
case @initiator
when EvidenceCheck
Expand Down
24 changes: 12 additions & 12 deletions spec/models/views/reports/raw_data_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

let(:office) { create(:office) }
let(:shared_parameters) { { office: office, business_entity: business_entity, decision_date: Time.zone.now } }
let(:business_entity) { create(:business_entity) }
let(:business_entity) { create(:business_entity, sop_code: 135864) }
let(:start_date) { Time.zone.today.-1.month }
let(:start_date_params) {
{ day: start_date.day, month: start_date.month, year: start_date.year }
Expand Down Expand Up @@ -122,7 +122,7 @@
full_no_ec
export = data.to_csv
jurisdiction = full_no_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.24,0.0,300.24,income,ABC123,,false,false,10,under,None,1,true,No,full,0.0,300.24,paper"
row = "#{jurisdiction},135864,300.24,0.0,300.24,income,ABC123,,false,false,10,under,None,1,true,No,full,0.0,300.24,paper"
expect(export).to include(row)
end
end
Expand All @@ -132,7 +132,7 @@
part_no_ec
export = data.to_csv
jurisdiction = part_no_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.0,50.0,250.0,income,ABC123,,false,false,2000,,NI number,3,true,No,part,50.0,250.0,paper"
row = "#{jurisdiction},135864,300.0,50.0,250.0,income,ABC123,,false,false,2000,,NI number,3,true,No,part,50.0,250.0,paper"
dob = part_no_ec.applicant.date_of_birth.to_fs
expect(export).to include(row)
expect(export).to include("True,JK123456A,,#{dob}")
Expand All @@ -142,7 +142,7 @@
part_no_ec_return_pp
export = data.to_csv
jurisdiction = part_no_ec_return_pp.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.45,50.6,249.85,income,ABC123,,false,false,2000,,NI number,3,true,No,part,300.45,0.0,paper"
row = "#{jurisdiction},135864,300.45,50.6,249.85,income,ABC123,,false,false,2000,,NI number,3,true,No,part,300.45,0.0,paper"
dob = part_no_ec_return_pp.applicant.date_of_birth.to_fs

expect(export).to include(row)
Expand All @@ -153,7 +153,7 @@
part_no_ec_none_pp
export = data.to_csv
jurisdiction = part_no_ec_none_pp.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.45,50.6,249.85,income,ABC123,,false,false,2000,,NI number,3,true,No,part,300.45,0.0,paper"
row = "#{jurisdiction},135864,300.45,50.6,249.85,income,ABC123,,false,false,2000,,NI number,3,true,No,part,300.45,0.0,paper"
dob = part_no_ec_none_pp.applicant.date_of_birth.to_fs
expect(export).to include(row)
expect(export).to include("True,JK123456A,,#{dob}")
Expand All @@ -165,7 +165,7 @@
none_no_ec
export = data.to_csv
jurisdiction = none_no_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.34,300.34,0.0,income,ABC123,,false,false,2000,,Home Office number,3,true,No,none,300.34,0.0,paper"
row = "#{jurisdiction},135864,300.34,300.34,0.0,income,ABC123,,false,false,2000,,Home Office number,3,true,No,none,300.34,0.0,paper"
expect(export).to include(row)
end
end
Expand All @@ -175,7 +175,7 @@
none_ec
export = data.to_csv
jurisdiction = none_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.34,0.0,300.34,income,ABC123,,false,false,2000,over,NI number,3,true,No,none,300.34,0.0,paper"
row = "#{jurisdiction},135864,300.34,0.0,300.34,income,ABC123,,false,false,2000,over,NI number,3,true,No,none,300.34,0.0,paper"
expect(export).to include(row)
end

Expand All @@ -185,7 +185,7 @@
none_ec
export = data.to_csv
jurisdiction = none_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.34,0.0,300.34,income,ABC123,,false,false,2000,over,NI number,3,true,Yes,none,300.34,0.0,paper"
row = "#{jurisdiction},135864,300.34,0.0,300.34,income,ABC123,,false,false,2000,over,NI number,3,true,Yes,none,300.34,0.0,paper"
expect(export).to include(row)
end

Expand All @@ -197,7 +197,7 @@
none_ec
export = data.to_csv
jurisdiction = none_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.34,0.0,300.34,income,ABC123,,false,false,2000,over,NI number,3,true,Yes,none,300.34,0.0,paper"
row = "#{jurisdiction},135864,300.34,0.0,300.34,income,ABC123,,false,false,2000,over,NI number,3,true,Yes,none,300.34,0.0,paper"
expect(export).to include(row)
end
end
Expand All @@ -208,7 +208,7 @@
none_ec.saving.update(over_61: true)
export = data.to_csv
jurisdiction = none_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.34,0.0,300.34,income,ABC123,,false,false,2000,over,NI number,3,true,Yes,none,300.34,0.0,paper"
row = "#{jurisdiction},135864,300.34,0.0,300.34,income,ABC123,,false,false,2000,over,NI number,3,true,Yes,none,300.34,0.0,paper"
expect(export).to include(row)
end
end
Expand All @@ -220,7 +220,7 @@
full_ec
export = data.to_csv
jurisdiction = full_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.0,0.0,300.0,income,ABC123,,false,false,10,,NI number,1,true,No,full,0.0,300.0,paper"
row = "#{jurisdiction},135864,300.0,0.0,300.0,income,ABC123,,false,false,10,,NI number,1,true,No,full,0.0,300.0,paper"
expect(export).to include(row)
end
end
Expand All @@ -230,7 +230,7 @@
part_ec
export = data.to_csv
jurisdiction = part_ec.detail.jurisdiction.name
row = "#{jurisdiction},SD123,300.0,50.0,250.0,income,ABC123,,false,false,2000,,NI number,3,true,No,part,100.0,200.0,paper"
row = "#{jurisdiction},135864,300.0,50.0,250.0,income,ABC123,,false,false,2000,,NI number,3,true,No,part,100.0,200.0,paper"
expect(export).to include(row)
end
end
Expand Down
18 changes: 18 additions & 0 deletions spec/services/part_payment_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@
it 'sets expiration on the payment' do
expect(decide.expires_at).to eql(current_time + expires_in_days.days)
end

context 'when there is already a part payment' do
let(:application) { create(:application_part_remission) }
let(:part_payment) { create(:part_payment, application: application) }
before do
part_payment
end

it 'does not create another part payment' do
part_payments = PartPayment.where(application_id: application.id)
expect(part_payments.count).to be(1)

decide
part_payments = PartPayment.where(application_id: application.id)
expect(part_payments.count).to be(1)
expect(part_payment.id).to eql(part_payments.last.id)
end
end
end

context 'when application is a part payment but is not decided' do
Expand Down

0 comments on commit c46249d

Please sign in to comment.