rails up to 7.0and ruby to 2.7.2
mv lib to app/lib due to upgrade removing concerns from autoload path resolve zeitwerk issues make foodsoft run for dev on rails 7 and ruby 2.7 fix mail file permission bug fix database_config fix articles controller test ActiveModell::Error bump Gemfile.lock
This commit is contained in:
parent
d7591d46b9
commit
fb8ccfea4a
53 changed files with 583 additions and 594 deletions
32
app/lib/bank_transaction_reference.rb
Normal file
32
app/lib/bank_transaction_reference.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
class BankTransactionReference
|
||||
# parses a string from a bank transaction field
|
||||
def self.parse(data)
|
||||
m = /(^|[^\w.])FS(?<group>\d+)(\.(?<user>\d+))?(?<parts>([A-Za-z]+\d+(\.\d+)?)+)([^\w.]|$)/.match(data)
|
||||
return unless m
|
||||
|
||||
parts = {}
|
||||
m[:parts].scan(/([A-Za-z]+)(\d+(\.\d+)?)/) do |category, value|
|
||||
value = value.to_f
|
||||
value += parts[category] if parts[category]
|
||||
parts[category] = value
|
||||
end
|
||||
|
||||
ret = { group: m[:group].to_i, parts: parts }
|
||||
ret[:user] = m[:user].to_i if m[:user]
|
||||
ret
|
||||
end
|
||||
|
||||
def self.js_code_for_user(user)
|
||||
%{
|
||||
function(items) {
|
||||
var ret = "FS#{user.ordergroup.id}.#{user.id}";
|
||||
for (var key in items) {
|
||||
if (items.hasOwnProperty(key)) {
|
||||
ret += key + items[key];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue