diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index 07071d2ca..6ece87147 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -150,8 +150,8 @@ order_15: reference: '005900-10-22' state: ready total: 3000 - created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> - updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + created_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + updated_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> wallet_amount: wallet_transaction_id: payment_method: local @@ -168,8 +168,8 @@ order_16: reference: '005901-<%= DateTime.current.utc.strftime('%m') %>-<%= DateTime.current.utc.strftime('%d') %>' state: cart total: 0 - created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> - updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + created_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + updated_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> wallet_amount: wallet_transaction_id: payment_method: @@ -186,8 +186,8 @@ order_17: reference: '005902-<%= DateTime.current.utc.strftime('%m') %>-<%= DateTime.current.utc.strftime('%d') %>' state: cart total: 0 - created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> - updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + created_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + updated_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> wallet_amount: wallet_transaction_id: payment_method: @@ -204,8 +204,8 @@ order_18: reference: '005902-<%= DateTime.current.utc.strftime('%m') %>-<%= DateTime.current.utc.strftime('%d') %>' state: cart total: 500 - created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> - updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + created_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + updated_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> wallet_amount: wallet_transaction_id: payment_method: @@ -222,8 +222,8 @@ order_19: reference: '005903-<%= DateTime.current.utc.strftime('%m') %>-<%= DateTime.current.utc.strftime('%d') %>' state: cart total: 261500 - created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> - updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + created_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + updated_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> wallet_amount: wallet_transaction_id: payment_method: @@ -240,8 +240,8 @@ order_20: reference: '005904-<%= DateTime.current.utc.strftime('%m') %>-<%= DateTime.current.utc.strftime('%d') %>' state: cart total: 262500 - created_at: <%= DateTime.current.utc.change({:hour => 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> - updated_at: <%= DateTime.current.utc.change({:hour => 15}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + created_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> + updated_at: <%= DateTime.current.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %> wallet_amount: wallet_transaction_id: payment_method: diff --git a/test/services/payment_document_service_test.rb b/test/services/payment_document_service_test.rb index abbea89de..f422d8b3d 100644 --- a/test/services/payment_document_service_test.rb +++ b/test/services/payment_document_service_test.rb @@ -15,7 +15,7 @@ class PaymentDocumentServiceTest < ActiveSupport::TestCase test 'invoice for local payment' do invoice = sample_reservation_invoice(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}001", invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", invoice.order_number end test 'invoice with custom format' do @@ -41,19 +41,19 @@ class PaymentDocumentServiceTest < ActiveSupport::TestCase test 'invoice for online card payment' do invoice = sample_reservation_invoice(@acamus, @acamus) assert_equal "#{Time.current.strftime('%y%m')}001/VL", invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", invoice.order_number end test 'refund' do invoice = sample_reservation_invoice(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}001", invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", invoice.order_number refund = invoice.build_avoir(payment_method: 'wallet', invoice_items_ids: invoice.invoice_items.map(&:id)) refund.save refund.reload assert_equal "#{Time.current.strftime('%y%m')}002/A", refund.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", refund.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", refund.order_number end test 'payment schedule' do @@ -62,31 +62,31 @@ class PaymentDocumentServiceTest < ActiveSupport::TestCase assert_equal "#{Time.current.strftime('%y%m')}001/E", schedule.reference first_item = schedule.ordered_items.first assert_equal "#{Time.current.strftime('%y%m')}001", first_item.invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", first_item.invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", first_item.invoice.order_number second_item = schedule.ordered_items[1] PaymentScheduleService.new.generate_invoice(second_item, payment_method: 'check') assert_equal "#{Time.current.strftime('%y%m')}002", second_item.invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", second_item.invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", second_item.invoice.order_number third_item = schedule.ordered_items[2] PaymentScheduleService.new.generate_invoice(third_item, payment_method: 'check') assert_equal "#{Time.current.strftime('%y%m')}003", third_item.invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", third_item.invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", third_item.invoice.order_number fourth_item = schedule.ordered_items[3] PaymentScheduleService.new.generate_invoice(fourth_item, payment_method: 'check') assert_equal "#{Time.current.strftime('%y%m')}004", fourth_item.invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", fourth_item.invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", fourth_item.invoice.order_number fifth_item = schedule.ordered_items[2] PaymentScheduleService.new.generate_invoice(fifth_item, payment_method: 'check') assert_equal "#{Time.current.strftime('%y%m')}005", fifth_item.invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", fifth_item.invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", fifth_item.invoice.order_number end test 'order' do cart = Cart::FindOrCreateService.new(users(:user_2)).call(nil) cart = Cart::AddItemService.new.call(cart, Product.find_by(slug: 'panneaux-de-mdf'), 1) Checkout::PaymentService.new.payment(cart, @admin, nil) - assert_equal "000018-#{Time.current.strftime('%m-%y')}", cart.reference # here reference = order number - assert_equal "000018-#{Time.current.strftime('%m-%y')}", cart.invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", cart.reference # here reference = order number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", cart.invoice.order_number assert_equal "#{Time.current.strftime('%y%m')}001", cart.invoice.reference end @@ -95,94 +95,94 @@ class PaymentDocumentServiceTest < ActiveSupport::TestCase invoice = sample_reservation_invoice(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}001", invoice.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", invoice.order_number refund = invoice.build_avoir(payment_method: 'wallet', invoice_items_ids: invoice.invoice_items.map(&:id)) refund.save refund.reload assert_equal "#{Time.current.strftime('%y%m')}002/A", refund.reference - assert_equal "000018-#{Time.current.strftime('%m-%y')}", refund.order_number + assert_equal "000023-#{Time.current.strftime('%m-%y')}", refund.order_number invoice = sample_reservation_invoice(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}003", invoice.reference - assert_equal "000019-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000024-#{Time.current.strftime('%m-%y')}", invoice.order_number invoice = sample_reservation_invoice(@acamus, @acamus) assert_equal "#{Time.current.strftime('%y%m')}004/VL", invoice.reference - assert_equal "000020-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000025-#{Time.current.strftime('%m-%y')}", invoice.order_number invoice = sample_reservation_invoice(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}005", invoice.reference - assert_equal "000021-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000026-#{Time.current.strftime('%m-%y')}", invoice.order_number invoice = sample_reservation_invoice(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}006", invoice.reference - assert_equal "000022-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000027-#{Time.current.strftime('%m-%y')}", invoice.order_number invoice = sample_reservation_invoice(@acamus, @acamus) assert_equal "#{Time.current.strftime('%y%m')}007/VL", invoice.reference - assert_equal "000023-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000028-#{Time.current.strftime('%m-%y')}", invoice.order_number invoice = sample_reservation_invoice(@acamus, @acamus) assert_equal "#{Time.current.strftime('%y%m')}008/VL", invoice.reference - assert_equal "000024-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000029-#{Time.current.strftime('%m-%y')}", invoice.order_number refund = invoice.build_avoir(payment_method: 'wallet', invoice_items_ids: invoice.invoice_items.map(&:id)) refund.save refund.reload assert_equal "#{Time.current.strftime('%y%m')}009/A", refund.reference - assert_equal "000024-#{Time.current.strftime('%m-%y')}", refund.order_number + assert_equal "000029-#{Time.current.strftime('%m-%y')}", refund.order_number invoice = sample_reservation_invoice(@acamus, @acamus) assert_equal "#{Time.current.strftime('%y%m')}010/VL", invoice.reference - assert_equal "000025-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000030-#{Time.current.strftime('%m-%y')}", invoice.order_number invoice2 = sample_reservation_invoice(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}011", invoice2.reference - assert_equal "000026-#{Time.current.strftime('%m-%y')}", invoice2.order_number + assert_equal "000031-#{Time.current.strftime('%m-%y')}", invoice2.order_number refund = invoice.build_avoir(payment_method: 'wallet', invoice_items_ids: invoice.invoice_items.map(&:id)) refund.save refund.reload assert_equal "#{Time.current.strftime('%y%m')}012/A", refund.reference - assert_equal "000025-#{Time.current.strftime('%m-%y')}", refund.order_number + assert_equal "000030-#{Time.current.strftime('%m-%y')}", refund.order_number refund = invoice2.build_avoir(payment_method: 'wallet', invoice_items_ids: invoice.invoice_items.map(&:id)) refund.save refund.reload assert_equal "#{Time.current.strftime('%y%m')}013/A", refund.reference - assert_equal "000026-#{Time.current.strftime('%m-%y')}", refund.order_number + assert_equal "000031-#{Time.current.strftime('%m-%y')}", refund.order_number schedule = sample_schedule(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}001/E", schedule.reference assert_equal "#{Time.current.strftime('%y%m')}014", schedule.ordered_items.first.invoice.reference - assert_equal "000027-#{Time.current.strftime('%m-%y')}", schedule.ordered_items.first.invoice.order_number + assert_equal "000032-#{Time.current.strftime('%m-%y')}", schedule.ordered_items.first.invoice.order_number schedule = sample_schedule(users(:user_2), users(:user_2)) assert_equal "#{Time.current.strftime('%y%m')}002/E", schedule.reference assert_equal "#{Time.current.strftime('%y%m')}015/VL", schedule.ordered_items.first.invoice.reference - assert_equal "000028-#{Time.current.strftime('%m-%y')}", schedule.ordered_items.first.invoice.order_number + assert_equal "000033-#{Time.current.strftime('%m-%y')}", schedule.ordered_items.first.invoice.order_number invoice = sample_reservation_invoice(@acamus, @acamus) assert_equal "#{Time.current.strftime('%y%m')}016/VL", invoice.reference - assert_equal "000029-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000034-#{Time.current.strftime('%m-%y')}", invoice.order_number cart = Cart::FindOrCreateService.new(users(:user_2)).call(nil) cart = Cart::AddItemService.new.call(cart, Product.find_by(slug: 'panneaux-de-mdf'), 1) Checkout::PaymentService.new.payment(cart, @admin, nil) - assert_equal "000030-#{Time.current.strftime('%m-%y')}", cart.reference # here reference = order number - assert_equal "000030-#{Time.current.strftime('%m-%y')}", cart.invoice.order_number + assert_equal "000035-#{Time.current.strftime('%m-%y')}", cart.reference # here reference = order number + assert_equal "000035-#{Time.current.strftime('%m-%y')}", cart.invoice.order_number assert_equal "#{Time.current.strftime('%y%m')}017", cart.invoice.reference cart = Cart::FindOrCreateService.new(users(:user_2)).call(nil) cart = Cart::AddItemService.new.call(cart, Product.find_by(slug: 'panneaux-de-mdf'), 1) Checkout::PaymentService.new.payment(cart, @admin, nil) - assert_equal "000031-#{Time.current.strftime('%m-%y')}", cart.reference # here reference = order number - assert_equal "000031-#{Time.current.strftime('%m-%y')}", cart.invoice.order_number + assert_equal "000036-#{Time.current.strftime('%m-%y')}", cart.reference # here reference = order number + assert_equal "000036-#{Time.current.strftime('%m-%y')}", cart.invoice.order_number assert_equal "#{Time.current.strftime('%y%m')}018", cart.invoice.reference invoice = sample_reservation_invoice(@acamus, @admin) assert_equal "#{Time.current.strftime('%y%m')}019", invoice.reference - assert_equal "000032-#{Time.current.strftime('%m-%y')}", invoice.order_number + assert_equal "000037-#{Time.current.strftime('%m-%y')}", invoice.order_number end end