Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
znarf committed Feb 27, 2024
1 parent f19b03c commit 244b8f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 9 additions & 2 deletions server/models/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ interface TransactionModelStaticInterface {
}>;
createPlatformTipDebtTransactions(args: {
platformTipTransaction: TransactionInterface;
transaction: TransactionCreationAttributes;
}): Promise<TransactionInterface>;
createPaymentProcessorFeeTransactions(
transaction: TransactionCreationAttributes,
Expand Down Expand Up @@ -956,14 +957,17 @@ Transaction.createDoubleEntry = async (transaction: TransactionCreationAttribute
*/
Transaction.createPlatformTipDebtTransactions = async ({
platformTipTransaction,
transaction,
}: {
platformTipTransaction: TransactionInterface;
transaction: TransactionCreationAttributes;
}): Promise<TransactionInterface> => {
if (platformTipTransaction.type === DEBIT) {
throw new Error('createPlatformTipDebtTransactions must be given a CREDIT transaction');
}

const host = await Transaction.fetchHost(platformTipTransaction);
// This should be the host of the original transaction
const host = await Transaction.fetchHost(transaction);

// Create debt transaction
const platformTipDebtTransactionData = {
Expand Down Expand Up @@ -1075,7 +1079,10 @@ Transaction.createPlatformTipTransactions = async (

let platformTipDebtTransaction;
if (!transaction.data.isPlatformRevenueDirectlyCollected) {
platformTipDebtTransaction = await Transaction.createPlatformTipDebtTransactions({ platformTipTransaction });
platformTipDebtTransaction = await Transaction.createPlatformTipDebtTransactions({
platformTipTransaction,
transaction,
});
}

// If we have platformTipInHostCurrency available, we trust it, otherwise we compute it
Expand Down
3 changes: 1 addition & 2 deletions test/server/lib/payments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ describe('server/lib/payments', () => {
hostFeeInHostCurrency: 250,
paymentProcessorFeeInHostCurrency: 175,
description: 'Monthly subscription to Webpack',
platformTipAmount: 500,
data: { charge: { id: 'ch_refunded_charge' } },
data: { charge: { id: 'ch_refunded_charge' }, platformTip: 500 },
});

// Should have 8 transactions:
Expand Down

0 comments on commit 244b8f1

Please sign in to comment.