优化
This commit is contained in:
@@ -3,7 +3,7 @@ import { http } from '@/shared/api/http'
|
||||
import {
|
||||
adjustInboundFeeDetail, createInboundFeeDetail, deleteInboundFeeDetail, listInboundFeeDetails,
|
||||
listInboundFeeItemOptions, listInboundFeeSupplierOptions, reviewInboundFeeDetail,
|
||||
updateInboundFeeDetail, voidInboundFeeDetail, type SaveInboundFeeDetailRequest,
|
||||
updateInboundFeeDetail, uploadInboundFeePaymentVoucher, voidInboundFeeDetail, type SaveInboundFeeDetailRequest,
|
||||
} from './inboundFeeDetails'
|
||||
|
||||
vi.mock('@/shared/api/http', async () => {
|
||||
@@ -19,7 +19,7 @@ describe('inbound fee-detail API', () => {
|
||||
})
|
||||
|
||||
it('maps the complete write contract and optimistic version', async () => {
|
||||
const payload: SaveInboundFeeDetailRequest = { feeItemId: '31', direction: 'PAYABLE', businessDate: '2026-08-12', unitPrice: 12.5, currency: 'CNY', amount: 125, supplierId: '41', remark: '验收' }
|
||||
const payload: SaveInboundFeeDetailRequest = { feeItemId: '31', direction: 'PAYABLE', businessDate: '2026-08-12', unitPrice: 12.5, currency: 'CNY', amount: 125, supplierId: '41', settlementMode: 'DIRECT_PAID', paidAt: '2026-08-12T10:30:00', paymentMethod: 'BANK_TRANSFER', paymentReferenceNo: 'BANK-31', paymentVoucherFileIds: ['9001'], remark: '验收' }
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', message: 'success', data: [] })
|
||||
vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: null })
|
||||
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: payload })
|
||||
@@ -34,6 +34,14 @@ describe('inbound fee-detail API', () => {
|
||||
expect(http.delete).toHaveBeenCalledWith('/platform/v1/inbounds/88/fee-details/11', { params: { accountId: '100' } })
|
||||
})
|
||||
|
||||
it('reuses the scoped FINANCE_VOUCHER upload and fails closed on customer mismatch', async () => {
|
||||
vi.mocked(http.post).mockResolvedValueOnce({ code: '200', data: { fileId: 9001, tenantId: 100, fileName: '付款凭证.pdf' } })
|
||||
await expect(uploadInboundFeePaymentVoucher('100', new File(['x'], '付款凭证.pdf'))).resolves.toEqual({ fileId: '9001', fileName: '付款凭证.pdf' })
|
||||
expect(http.post).toHaveBeenCalledWith('/platform/finance/v1/vouchers', expect.any(FormData), { params: { customerId: '100' }, headers: { 'Content-Type': 'multipart/form-data' } })
|
||||
vi.mocked(http.post).mockResolvedValueOnce({ code: '200', data: { fileId: 9002, tenantId: 101, fileName: '错客户.pdf' } })
|
||||
await expect(uploadInboundFeePaymentVoucher('100', new File(['x'], '错客户.pdf'))).rejects.toThrow('付款凭证与当前客户不匹配')
|
||||
})
|
||||
|
||||
it('keeps an empty supplier category as null and rejects an unknown non-empty category', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', data: { records: [
|
||||
{ id: 31, feeTypeName: '拖车费', feeCode: 'TRUCKING', supplierCategory: 'TRUCKING', warehousePayable: true },
|
||||
|
||||
Reference in New Issue
Block a user