mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
add wallet transaction id to order
This commit is contained in:
parent
8059512f19
commit
939927fb73
@ -12,4 +12,9 @@ class Order < ApplicationRecord
|
||||
enum payment_state: PAYMENT_STATES.zip(PAYMENT_STATES).to_h
|
||||
|
||||
validates :token, :state, presence: true
|
||||
|
||||
def set_wallet_transaction(amount, transaction_id)
|
||||
self.wallet_amount = amount
|
||||
self.wallet_transaction_id = transaction_id
|
||||
end
|
||||
end
|
||||
|
@ -106,9 +106,9 @@ class WalletService
|
||||
# wallet debit success
|
||||
raise DebitWalletError unless wallet_transaction
|
||||
|
||||
payment.set_wallet_transaction(wallet_amount, wallet_transaction.id) unless payment.is_a? Order
|
||||
payment.set_wallet_transaction(wallet_amount, wallet_transaction.id)
|
||||
else
|
||||
payment.set_wallet_transaction(wallet_amount, nil) unless payment.is_a? Order
|
||||
payment.set_wallet_transaction(wallet_amount, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,6 @@
|
||||
class AddWalletAmountAndWalletTransactionIdToOrder < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :orders, :wallet_amount, :integer
|
||||
add_column :orders, :wallet_transaction_id, :integer
|
||||
end
|
||||
end
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_08_26_085923) do
|
||||
ActiveRecord::Schema.define(version: 2022_08_26_090821) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "fuzzystrmatch"
|
||||
@ -468,6 +468,8 @@ ActiveRecord::Schema.define(version: 2022_08_26_085923) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "payment_state"
|
||||
t.integer "wallet_amount"
|
||||
t.integer "wallet_transaction_id"
|
||||
t.index ["statistic_profile_id"], name: "index_orders_on_statistic_profile_id"
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user