Skip to content

Commit d426e1b

Browse files
committed
Change WalletTransactions::RecreditService to also copy purchase_order_number to new wallet_transaction record
1 parent d01ddc4 commit d426e1b

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

app/services/wallet_transactions/recredit_service.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def call
2727
params: {
2828
wallet_id: wallet.id,
2929
granted_credits: wallet_transaction.credit_amount.to_s,
30+
purchase_order_number: wallet_transaction.purchase_order_number,
3031
reset_consumed_credits: true,
3132
voided_invoice_id: wallet_transaction.invoice_id
3233
}

spec/services/invoices/void_service_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,15 @@
9999

100100
context "when the invoice has applied credits from the wallet" do
101101
let(:wallet) { create(:wallet, credits_balance: 100, balance_cents: 100) }
102-
let(:wallet_transaction) { create(:wallet_transaction, wallet:, invoice:, transaction_type: "outbound", amount: 100, credit_amount: 100) }
102+
let(:wallet_transaction) do
103+
create(:wallet_transaction,
104+
wallet:,
105+
invoice:,
106+
purchase_order_number: "PO-123",
107+
transaction_type: "outbound",
108+
amount: 100,
109+
credit_amount: 100)
110+
end
103111

104112
before do
105113
wallet_transaction
@@ -111,6 +119,7 @@
111119
expect(WalletTransactions::RecreditService).to have_received(:call).with(wallet_transaction: wallet_transaction)
112120
expect(wallet.wallet_transactions.count).to eq(2)
113121
expect(wallet.reload.credits_balance).to eq(200)
122+
expect(wallet.wallet_transactions.inbound.last.purchase_order_number).to eq(wallet_transaction.purchase_order_number)
114123
end
115124
end
116125

spec/services/wallet_transactions/recredit_service_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
create(:wallet_transaction,
5353
wallet:,
5454
invoice: voided_invoice,
55+
purchase_order_number: "PO-123",
5556
transaction_type: :outbound,
5657
credit_amount: 5.0)
5758
end
@@ -64,6 +65,7 @@
6465
voided_invoice_id: voided_invoice.id,
6566
transaction_type: "inbound",
6667
transaction_status: "granted",
68+
purchase_order_number: wallet_transaction.purchase_order_number,
6769
credit_amount: wallet_transaction.credit_amount
6870
)
6971
end

0 commit comments

Comments
 (0)