diff --git a/app/models/wallet_transaction.rb b/app/models/wallet_transaction.rb index 87311ce6b..9ad84a30f 100644 --- a/app/models/wallet_transaction.rb +++ b/app/models/wallet_transaction.rb @@ -8,17 +8,14 @@ class WalletTransaction < ApplicationRecord belongs_to :wallet belongs_to :reservation # what was paid with the wallet - has_one :invoice - has_one :payment_schedule + has_one :invoice, dependent: :nullify + has_one :payment_schedule, dependent: :nullify # how the wallet was credited has_one :invoice_item, as: :object, dependent: :destroy - validates_inclusion_of :transaction_type, in: %w[credit debit] - validates :invoicing_profile, :wallet, presence: true + validates :transaction_type, inclusion: { in: %w[credit debit] } - def user - invoicing_profile.user - end + delegate :user, to: :invoicing_profile def original_invoice invoice_item.invoice diff --git a/test/fixtures/order_activities.yml b/test/fixtures/order_activities.yml new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml new file mode 100644 index 000000000..5f1cffd10 --- /dev/null +++ b/test/fixtures/order_items.yml @@ -0,0 +1,130 @@ +order_item_1: + id: 1 + order_id: 1 + orderable_type: Product + orderable_id: 18 + amount: 4000 + quantity: 1 + is_offered: + created_at: '2022-09-20 15:14:05.605885' + updated_at: '2022-09-20 15:14:05.605885' +order_item_2: + id: 2 + order_id: 1 + orderable_type: Product + orderable_id: 13 + amount: 500 + quantity: 1 + is_offered: + created_at: '2022-09-20 15:14:09.022448' + updated_at: '2022-09-20 15:14:09.022448' +order_item_3: + id: 3 + order_id: 2 + orderable_type: Product + orderable_id: 15 + amount: 1500 + quantity: 4 + is_offered: + created_at: '2022-09-20 15:14:34.899658' + updated_at: '2022-09-20 15:14:34.899658' +order_item_11: + id: 11 + order_id: 5 + orderable_type: Product + orderable_id: 18 + amount: 4000 + quantity: 3 + is_offered: + created_at: '2022-09-28 08:31:30.377083' + updated_at: '2022-10-04 08:34:25.130457' +order_item_16: + id: 16 + order_id: 9 + orderable_type: Product + orderable_id: 23 + amount: 119 + quantity: 1 + is_offered: + created_at: '2022-10-04 12:35:39.730968' + updated_at: '2022-10-04 12:35:39.730968' +order_item_17: + id: 17 + order_id: 9 + orderable_type: Product + orderable_id: 22 + amount: 200 + quantity: 1 + is_offered: + created_at: '2022-10-04 12:35:40.562076' + updated_at: '2022-10-04 12:35:40.562076' +order_item_18: + id: 18 + order_id: 10 + orderable_type: Product + orderable_id: 23 + amount: 119 + quantity: 1 + is_offered: + created_at: '2022-10-04 13:54:19.042858' + updated_at: '2022-10-04 13:54:19.042858' +order_item_19: + id: 19 + order_id: 10 + orderable_type: Product + orderable_id: 15 + amount: 1500 + quantity: 1 + is_offered: + created_at: '2022-10-04 13:54:22.649153' + updated_at: '2022-10-04 13:54:22.649153' +order_item_20: + id: 20 + order_id: 11 + orderable_type: Product + orderable_id: 11 + amount: 1000 + quantity: 1 + is_offered: + created_at: '2022-10-04 14:03:59.721736' + updated_at: '2022-10-04 14:03:59.721736' +order_item_21: + id: 21 + order_id: 12 + orderable_type: Product + orderable_id: 20 + amount: 1 + quantity: 2 + is_offered: + created_at: '2022-10-04 14:05:23.583721' + updated_at: '2022-10-04 14:17:41.866526' +order_item_22: + id: 22 + order_id: 12 + orderable_type: Product + orderable_id: 18 + amount: 4000 + quantity: 1 + is_offered: + created_at: '2022-10-04 14:17:33.257776' + updated_at: '2022-10-04 14:17:33.257776' +order_item_23: + id: 23 + order_id: 14 + orderable_type: Product + orderable_id: 18 + amount: 4000 + quantity: 3 + is_offered: + created_at: '2022-10-04 14:31:51.106853' + updated_at: '2022-10-04 14:31:54.194063' +order_item_24: + id: 24 + order_id: 15 + orderable_type: Product + orderable_id: 17 + amount: 3000 + quantity: 1 + is_offered: + created_at: '2022-10-04 14:35:29.003092' + updated_at: '2022-10-04 14:35:29.003092' diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/product_categories.yml b/test/fixtures/product_categories.yml new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/product_stock_movements.yml b/test/fixtures/product_stock_movements.yml new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml new file mode 100644 index 000000000..e69de29bb