Skip to content

Commit 3214b94

Browse files
committed
Fix rubocop warnings
1 parent 9bf1941 commit 3214b94

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

app/models/facility.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@ def show_multi_add_products?(product_scope, user)
169169
private
170170

171171
def set_journal_mask
172-
max_number = Facility.all
173-
.pluck(:journal_mask)
174-
.filter_map { |mask| mask&.match(/^C(\d{2,3})$/)&.[](1)&.to_i }
175-
.max
176-
177-
next_number = max_number ? max_number + 1 : 1
178-
self.journal_mask = format("C%0#{next_number < 100 ? 2 : 3}d", next_number)
172+
f = Facility.all.order(journal_mask: :desc).first
173+
self.journal_mask = if f&.journal_mask&.match(/^C(\d{2,3})$/)
174+
next_number = Regexp.last_match(1).to_i + 1
175+
format("C%0#{next_number < 100 ? 2 : 3}d", next_number)
176+
else
177+
"C01"
178+
end
179179
end
180180

181181
end

0 commit comments

Comments
 (0)