Skip to content

Commit c7e7067

Browse files
authored
Merge pull request #1227 from Crown-Commercial-Service/feature/nrmi-250-include-email-in-invoice
Feature/nrmi 250 include email in invoice
2 parents 7879682 + 382af45 commit c7e7067

6 files changed

Lines changed: 42 additions & 10 deletions

app/models/workday/submit_invoice.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def invoice_memo
6767
end
6868

6969
def submitted_by_note_content
70-
submission.submitted_by.name if submission.submitted_by.present?
70+
"#{submission.submitted_by.name} : #{submission.submitted_by.email}" if submission.submitted_by.present?
7171
end
7272

7373
def line_item_description

app/models/workday/submit_reversal_invoice.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ def initialize(submission, user = nil)
1313
attr_reader :user
1414

1515
def line_item_description
16-
"Reversal of invoice adjustment for #{task_period_in_words} management charge"
16+
# rubocop:disable Layout/LineLength
17+
"Reversal of invoice #{submission.invoice_details[:invoice_number]} adjustment for #{task_period_in_words} management charge"
18+
# rubocop:enable Layout/LineLength
1719
end
1820

1921
def total_spend
2022
-super
2123
end
2224

2325
def submitted_by_note_content
24-
user&.name
26+
"#{user&.name} : #{user&.email}"
2527
end
2628
end
2729
end

app/models/workday/submit_reversal_invoice_adjustment.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ def initialize(submission, user = nil)
1515
attr_reader :user
1616

1717
def line_item_description
18-
"Reversal of invoice for #{task_period_in_words} management charge"
18+
"Reversal of invoice #{submission.invoice_details[:invoice_number]} for #{task_period_in_words} management charge"
1919
end
2020

2121
def total_spend
2222
-super
2323
end
2424

2525
def submitted_by_note_content
26-
user&.name
26+
"#{user&.name} : #{user&.email}"
2727
end
2828
end
2929
end

spec/models/workday/submit_invoice_request_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
end
5151

5252
it 'sets Note_Data with the name of the user who submitted the Submission' do
53-
expect(text_at_xpath('//ns0:Note_Data//ns0:Note_Content')).to eq 'Forename Surname'
53+
expect(text_at_xpath('//ns0:Note_Data//ns0:Note_Content')).to eq "Forename Surname : #{user.email}"
5454
end
5555

5656
it 'sets the invoice as submitted' do

spec/models/workday/submit_reversal_invoice_adjustment_spec.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
submitted_by: user,
1010
task: task)
1111
end
12+
let!(:submission_invoice) { FactoryBot.create(:submission_invoice, submission: submission) }
1213
let(:framework) { submission.framework }
1314
let(:task) { FactoryBot.create(:task, period_month: 12, period_year: 2018, status: :in_progress) }
1415
let(:supplier) { submission.supplier }
@@ -19,6 +20,20 @@
1920
revenue_category_ids: { framework.short_name => 'Revenue_Category_WID' }
2021
)
2122
allow(Workday::CommercialAgreements).to receive(:new).and_return(commercial_agreements)
23+
24+
customer_invoice = instance_double(
25+
Workday::CustomerInvoice,
26+
invoice_details: {
27+
invoice_amount: '0.20',
28+
invoice_date: '2018-12-31-00:00',
29+
invoice_number: 'CINV-00000001',
30+
payment_status: 'Paid'
31+
}
32+
)
33+
34+
# rubocop:disable Layout/LineLength
35+
allow(Workday::CustomerInvoice).to receive(:new).with(submission_invoice.workday_reference).and_return(customer_invoice)
36+
# rubocop:enable Layout/LineLength
2237
end
2338

2439
it_behaves_like 'a workday request'
@@ -51,7 +66,7 @@
5166
end
5267

5368
it 'sets Note_Data with the name of the user who submitted the correction submission' do
54-
expect(text_at_xpath('//ns0:Note_Data//ns0:Note_Content')).to eq 'ForenameR SurnameR'
69+
expect(text_at_xpath('//ns0:Note_Data//ns0:Note_Content')).to eq "ForenameR SurnameR : #{correcting_user.email}"
5570
end
5671

5772
it 'sets the invoice adjustment as submitted' do
@@ -63,7 +78,7 @@
6378
it 'sets Line_Item_Description with a description of the charge' do
6479
expect(
6580
text_at_xpath('//ns0:Customer_Invoice_Line_Replacement_Data//ns0:Line_Item_Description')
66-
).to eq 'Reversal of invoice for December 2018 management charge'
81+
).to eq 'Reversal of invoice CINV-00000001 for December 2018 management charge'
6782
end
6883

6984
it 'sets Analytical_Amount as the negative value of the total spend for the submission' do

spec/models/workday/submit_reversal_invoice_spec.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
submitted_by: user,
1010
task: task)
1111
end
12+
let!(:submission_invoice) { FactoryBot.create(:submission_invoice, submission: submission) }
1213
let(:framework) { submission.framework }
1314
let(:task) { FactoryBot.create(:task, period_month: 12, period_year: 2018) }
1415
let(:supplier) { submission.supplier }
@@ -19,6 +20,20 @@
1920
revenue_category_ids: { framework.short_name => 'Revenue_Category_WID' }
2021
)
2122
allow(Workday::CommercialAgreements).to receive(:new).and_return(commercial_agreements)
23+
24+
customer_invoice = instance_double(
25+
Workday::CustomerInvoice,
26+
invoice_details: {
27+
invoice_amount: '0.20',
28+
invoice_date: '2018-12-31-00:00',
29+
invoice_number: 'CINV-00000001',
30+
payment_status: 'Paid'
31+
}
32+
)
33+
34+
# rubocop:disable Layout/LineLength
35+
allow(Workday::CustomerInvoice).to receive(:new).with(submission_invoice.workday_reference).and_return(customer_invoice)
36+
# rubocop:enable Layout/LineLength
2237
end
2338

2439
it_behaves_like 'a workday request'
@@ -51,7 +66,7 @@
5166
end
5267

5368
it 'sets Note_Data with the name of the user who submitted the correction submission' do
54-
expect(text_at_xpath('//ns0:Note_Data//ns0:Note_Content')).to eq 'ForenameR SurnameR'
69+
expect(text_at_xpath('//ns0:Note_Data//ns0:Note_Content')).to eq "ForenameR SurnameR : #{correcting_user.email}"
5570
end
5671

5772
it 'sets the invoice as submitted' do
@@ -63,7 +78,7 @@
6378
it 'sets Line_Item_Description with a description of the charge' do
6479
expect(
6580
text_at_xpath('//ns0:Customer_Invoice_Line_Replacement_Data//ns0:Line_Item_Description')
66-
).to eq 'Reversal of invoice adjustment for December 2018 management charge'
81+
).to eq 'Reversal of invoice CINV-00000001 adjustment for December 2018 management charge'
6782
end
6883

6984
it 'sets Analytical_Amount as the negative value of the total spend for the submission' do

0 commit comments

Comments
 (0)