feat(settlement): 门店未出账手动提现与总部审核(OPT-010)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,6 +15,9 @@ import {
|
||||
classifyRedeemClientError,
|
||||
generateRedeemPendingNo,
|
||||
REDEEM_WEAKNET_FAIL_THRESHOLD,
|
||||
sumUnbilledPayoutAmount,
|
||||
validateStoreWithdraw,
|
||||
pickPayoutsForWithdrawAmount,
|
||||
} from './index';
|
||||
|
||||
describe('calcBenefitAmount', () => {
|
||||
@@ -235,3 +238,58 @@ describe('generateRedeemPendingNo', () => {
|
||||
expect(REDEEM_WEAKNET_FAIL_THRESHOLD).toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sumUnbilledPayoutAmount', () => {
|
||||
it('sums payout amounts', () => {
|
||||
expect(sumUnbilledPayoutAmount([{ payoutAmount: 60 }, { payoutAmount: 40.5 }])).toBe(100.5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateStoreWithdraw', () => {
|
||||
const base = {
|
||||
whitelistEnabled: true,
|
||||
availableAmount: 1000,
|
||||
requestAmount: 200,
|
||||
todayApplied: 0,
|
||||
dailyLimit: 5000,
|
||||
hasPendingRequest: false,
|
||||
hasBankAccount: true,
|
||||
};
|
||||
|
||||
it('rejects non-whitelist stores', () => {
|
||||
expect(validateStoreWithdraw({ ...base, whitelistEnabled: false }).ok).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects when daily limit exceeded', () => {
|
||||
expect(
|
||||
validateStoreWithdraw({ ...base, todayApplied: 4900, requestAmount: 200, dailyLimit: 5000 }).ok,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects pending request / missing bank / over available', () => {
|
||||
expect(validateStoreWithdraw({ ...base, hasPendingRequest: true }).ok).toBe(false);
|
||||
expect(validateStoreWithdraw({ ...base, hasBankAccount: false }).ok).toBe(false);
|
||||
expect(validateStoreWithdraw({ ...base, requestAmount: 1001 }).ok).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts valid request', () => {
|
||||
expect(validateStoreWithdraw(base).ok).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('pickPayoutsForWithdrawAmount', () => {
|
||||
it('picks FIFO exact match', () => {
|
||||
const rows = [{ payoutAmount: 60 }, { payoutAmount: 40 }, { payoutAmount: 30 }];
|
||||
const r = pickPayoutsForWithdrawAmount(rows, 100);
|
||||
expect(r.ok).toBe(true);
|
||||
if (r.ok) {
|
||||
expect(r.selected).toHaveLength(2);
|
||||
expect(r.amount).toBe(100);
|
||||
}
|
||||
});
|
||||
|
||||
it('rejects non-exact match', () => {
|
||||
const rows = [{ payoutAmount: 60 }, { payoutAmount: 40 }];
|
||||
expect(pickPayoutsForWithdrawAmount(rows, 50).ok).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user