Skip to content

Commit 7719b9a

Browse files
committed
Merge branch 'release/v1.9.4'
2 parents 10bac31 + ba9eddf commit 7719b9a

File tree

7 files changed

+129
-27
lines changed

7 files changed

+129
-27
lines changed

.bundler-audit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
ignore:
3+
- GHSA-96qw-h329-v5rg

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ gem "premailer-rails", "~> 1.12"
7979
gem "money"
8080

8181
# aws storage account
82-
gem "aws-sdk-s3", require: false
82+
gem "aws-sdk-s3", ">= 1.208.0", require: false
8383

8484
# Ransack gem for advanced searching
8585
gem "ransack", "~> 4.1"
@@ -137,7 +137,7 @@ gem "rubyzip"
137137

138138
gem "ahoy_matey"
139139

140-
gem "httparty"
140+
gem "httparty", ">= 0.24.0"
141141

142142
# Use google calendar for integration with Miru
143143
gem "google-api-client", require: "google/apis/calendar_v3"

Gemfile.lock

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,24 @@ GEM
114114
activerecord (>= 3.2, < 8.0)
115115
rake (>= 10.4, < 14.0)
116116
ast (2.4.2)
117-
aws-eventstream (1.2.0)
118-
aws-partitions (1.850.0)
119-
aws-sdk-core (3.186.0)
120-
aws-eventstream (~> 1, >= 1.0.2)
121-
aws-partitions (~> 1, >= 1.651.0)
122-
aws-sigv4 (~> 1.5)
117+
aws-eventstream (1.4.0)
118+
aws-partitions (1.1206.0)
119+
aws-sdk-core (3.241.4)
120+
aws-eventstream (~> 1, >= 1.3.0)
121+
aws-partitions (~> 1, >= 1.992.0)
122+
aws-sigv4 (~> 1.9)
123+
base64
124+
bigdecimal
123125
jmespath (~> 1, >= 1.6.1)
124-
aws-sdk-kms (1.62.0)
125-
aws-sdk-core (~> 3, >= 3.165.0)
126-
aws-sigv4 (~> 1.1)
127-
aws-sdk-s3 (1.119.0)
128-
aws-sdk-core (~> 3, >= 3.165.0)
126+
logger
127+
aws-sdk-kms (1.121.0)
128+
aws-sdk-core (~> 3, >= 3.241.4)
129+
aws-sigv4 (~> 1.5)
130+
aws-sdk-s3 (1.212.0)
131+
aws-sdk-core (~> 3, >= 3.241.4)
129132
aws-sdk-kms (~> 1)
130-
aws-sigv4 (~> 1.4)
131-
aws-sigv4 (1.5.2)
133+
aws-sigv4 (~> 1.5)
134+
aws-sigv4 (1.12.1)
132135
aws-eventstream (~> 1, >= 1.0.2)
133136
babel-source (5.8.35)
134137
babel-transpiler (0.7.0)
@@ -173,6 +176,7 @@ GEM
173176
crass (1.0.6)
174177
css_parser (1.21.1)
175178
addressable
179+
csv (3.3.5)
176180
data_migrate (9.3.0)
177181
activerecord (>= 6.1)
178182
railties (>= 6.1)
@@ -300,7 +304,8 @@ GEM
300304
http-accept (1.7.0)
301305
http-cookie (1.1.0)
302306
domain_name (~> 0.5)
303-
httparty (0.21.0)
307+
httparty (0.24.2)
308+
csv
304309
mini_mime (>= 1.0.0)
305310
multi_xml (>= 0.5.2)
306311
httpclient (2.8.3)
@@ -378,7 +383,8 @@ GEM
378383
i18n (>= 0.6.4, <= 2)
379384
msgpack (1.6.0)
380385
multi_json (1.15.0)
381-
multi_xml (0.6.0)
386+
multi_xml (0.8.1)
387+
bigdecimal (>= 3.1, < 5)
382388
multipart-post (2.3.0)
383389
mutex_m (0.3.0)
384390
net-imap (0.5.12)
@@ -722,7 +728,7 @@ DEPENDENCIES
722728
administrate
723729
ahoy_matey
724730
annotate
725-
aws-sdk-s3
731+
aws-sdk-s3 (>= 1.208.0)
726732
bootsnap (>= 1.4.4)
727733
bullet (~> 7.1)
728734
bundler-audit
@@ -743,7 +749,7 @@ DEPENDENCIES
743749
foreman
744750
google-api-client
745751
hash_dot
746-
httparty
752+
httparty (>= 0.24.0)
747753
image_processing (>= 1.2)
748754
jbuilder (~> 2.11)
749755
letter_opener

app/models/invoice_line_item.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def formatted_date
7373
private
7474

7575
def unlock_timesheet_entry
76-
if invoice.draft?
77-
timesheet_entry.update!(locked: false)
78-
end
76+
return unless invoice.draft? && timesheet_entry.present?
77+
78+
timesheet_entry.update!(locked: false)
7979
end
8080
end

app/services/timeoff_entries/index_service.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ def calculate_leave_balance
6868
net_days = net_hours.abs / @working_hours_per_day
6969
extra_hours = net_hours.abs % @working_hours_per_day
7070

71-
if net_hours.abs < @working_hours_per_day
72-
label = "#{net_hours} hours"
73-
else
74-
label = "#{net_days} days #{extra_hours} hours"
75-
end
71+
label = "#{net_days} days #{extra_hours} hours"
7672

7773
summary_object = {
7874
id: leave_type.id,

spec/models/invoice_line_item_spec.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,63 @@
2121

2222
describe "callbacks" do
2323
it { is_expected.to callback(:unlock_timesheet_entry).before(:destroy) }
24+
25+
describe "#unlock_timesheet_entry" do
26+
let(:company) { create(:company) }
27+
let(:client) { create(:client, company:) }
28+
let(:invoice) { create(:invoice, company:, client:, status: :draft) }
29+
let(:timesheet_entry) { create(:timesheet_entry, locked: true) }
30+
31+
context "when invoice is in draft status" do
32+
context "when timesheet_entry is present" do
33+
let(:invoice_line_item) do
34+
create(:invoice_line_item, invoice:, timesheet_entry:)
35+
end
36+
37+
it "unlocks the timesheet entry on destroy" do
38+
expect(timesheet_entry.locked).to be true
39+
invoice_line_item.destroy
40+
expect(timesheet_entry.reload.locked).to be false
41+
end
42+
end
43+
44+
context "when timesheet_entry is nil" do
45+
let(:invoice_line_item) do
46+
create(:invoice_line_item, invoice:, timesheet_entry: nil)
47+
end
48+
49+
it "does not raise an error on destroy" do
50+
expect { invoice_line_item.destroy }.not_to raise_error
51+
end
52+
end
53+
end
54+
55+
context "when invoice is not in draft status" do
56+
let(:sent_invoice) { create(:invoice, company:, client:, status: :sent) }
57+
58+
context "when timesheet_entry is present" do
59+
let(:invoice_line_item) do
60+
create(:invoice_line_item, invoice: sent_invoice, timesheet_entry:)
61+
end
62+
63+
it "does not unlock the timesheet entry on destroy" do
64+
expect(timesheet_entry.locked).to be true
65+
invoice_line_item.destroy
66+
expect(timesheet_entry.reload.locked).to be true
67+
end
68+
end
69+
70+
context "when timesheet_entry is nil" do
71+
let(:invoice_line_item) do
72+
create(:invoice_line_item, invoice: sent_invoice, timesheet_entry: nil)
73+
end
74+
75+
it "does not raise an error on destroy" do
76+
expect { invoice_line_item.destroy }.not_to raise_error
77+
end
78+
end
79+
end
80+
end
2481
end
2582

2683
describe "Associations" do

spec/requests/internal_api/v1/invoices/update_spec.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,46 @@
2828
expect(json_response["reference"]).to eq("foo")
2929
end
3030

31+
context "when removing invoice line items without timesheet entries" do
32+
let(:invoice) { company.invoices.first }
33+
let!(:line_item_1) { create(:invoice_line_item, invoice:, timesheet_entry: nil) }
34+
let!(:line_item_2) { create(:invoice_line_item, invoice:, timesheet_entry: nil) }
35+
36+
it "successfully removes line items" do
37+
send_request :patch, internal_api_v1_invoice_path(
38+
id: invoice.id, params: {
39+
invoice: {
40+
invoice_line_items_attributes: [
41+
{ id: line_item_1.id, _destroy: true },
42+
{ id: line_item_2.id, _destroy: true }
43+
]
44+
}
45+
}), headers: auth_headers(user)
46+
expect(response).to have_http_status(:ok)
47+
expect(invoice.reload.invoice_line_items).not_to include(line_item_1, line_item_2)
48+
end
49+
end
50+
51+
context "when removing invoice line items with timesheet entries" do
52+
let(:invoice) { company.invoices.first }
53+
let(:timesheet_entry) { create(:timesheet_entry, locked: true) }
54+
let!(:line_item) { create(:invoice_line_item, invoice:, timesheet_entry:) }
55+
56+
it "successfully removes line items and unlocks timesheet entries" do
57+
send_request :patch, internal_api_v1_invoice_path(
58+
id: invoice.id, params: {
59+
invoice: {
60+
invoice_line_items_attributes: [
61+
{ id: line_item.id, _destroy: true }
62+
]
63+
}
64+
}), headers: auth_headers(user)
65+
expect(response).to have_http_status(:ok)
66+
expect(invoice.reload.invoice_line_items).not_to include(line_item)
67+
expect(timesheet_entry.reload.locked).to be false
68+
end
69+
end
70+
3171
context "when client doesn't exist" do
3272
it "throws 404" do
3373
send_request :patch, internal_api_v1_invoice_path(

0 commit comments

Comments
 (0)