From 7e80221aa12704a748c939e1d187589700e4a51c Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Fri, 18 Nov 2022 10:34:13 +0200 Subject: [PATCH] Fixed dates for yearly domains in monthly invoices --- app/models/concerns/invoice/book_keeping.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/invoice/book_keeping.rb b/app/models/concerns/invoice/book_keeping.rb index 895b763cf8..2c9b8a5ca2 100644 --- a/app/models/concerns/invoice/book_keeping.rb +++ b/app/models/concerns/invoice/book_keeping.rb @@ -59,8 +59,9 @@ def divide_by_quantity_and_years(quantity, duration, item, lines) duration.times do |dur| single_item_dup = single_item.dup - single_item_dup['start_date'] = (issue_date + dur.year).end_of_month.strftime('%Y-%m-%d') - single_item_dup['end_date'] = (issue_date + (dur + 1).year).end_of_month.strftime('%Y-%m-%d') + date = (issue_date + dur.year).end_of_month.strftime('%Y-%m-%d') + single_item_dup['start_date'] = date + single_item_dup['end_date'] = date single_item_dup['price'] = (item['price'].to_f / duration).round(2) lines << single_item_dup end