diff --git a/CHANGELOG.md b/CHANGELOG.md index 270c9dfcd..d8b59f0d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog Fab-manager +- Fix a bug: unable to build accounting lines if no invoices - Fix a security issue: updated json5 to 1.0.2 to fix [CVE-2022-46175](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-46175) ## v5.6.0 2023 January 5 diff --git a/lib/tasks/fablab/setup.rake b/lib/tasks/fablab/setup.rake index 360f9f76d..e9c613bfc 100644 --- a/lib/tasks/fablab/setup.rake +++ b/lib/tasks/fablab/setup.rake @@ -12,9 +12,7 @@ namespace :fablab do desc 'add missing VAT rate to history' task :add_vat_rate, %i[rate date] => :environment do |_task, args| - unless args.rate && args.date - raise 'Missing argument. Usage exemple: rails fablab:setup:add_vat_rate[20,2014-01-01]. Use 0 to disable' - end + raise 'Missing argument. Usage exemple: rails fablab:setup:add_vat_rate[20,2014-01-01]. Use 0 to disable' unless args.rate && args.date if args.rate == '0' setting = Setting.find_by(name: 'invoice_VAT-active') @@ -129,7 +127,7 @@ namespace :fablab do desc 'generate acconting lines' task build_accounting_lines: :environment do - start_date = Invoice.order(created_at: :asc).first&.created_at + start_date = Invoice.order(created_at: :asc).first&.created_at || DateTime.current end_date = DateTime.current AccountingLine.where(date: start_date..end_date).destroy_all Accounting::AccountingService.new.build(start_date&.beginning_of_day, end_date.end_of_day)