fix(supply-chain): include no-sales SPUs in all dropship issues
(cherry picked from commit 9d32b57e970905fdee7b3194ceb9df4894eb517e) (cherry picked from commit ac885932d082a371ddb16d982a8acdea6dc28588)
This commit is contained in:
parent
3d7c519b3c
commit
26a6a28aa0
@ -55,7 +55,7 @@ describe('SupplyChainDropshipIssueRepository', () => {
|
||||
]))
|
||||
})
|
||||
|
||||
it('onlyPerformance=false drops the performance gate from the query', async () => {
|
||||
it('includes SPUs without sales records in both the all-SPU page and total', async () => {
|
||||
queryRaw
|
||||
.mockResolvedValueOnce([])
|
||||
.mockResolvedValueOnce([{ total: 0 }])
|
||||
@ -67,9 +67,29 @@ describe('SupplyChainDropshipIssueRepository', () => {
|
||||
offset: 0,
|
||||
})
|
||||
|
||||
for (const [query] of queryRaw.mock.calls) {
|
||||
const text = queryText(query)
|
||||
expect(text).not.toContain('spp."monthPerformance" > 0')
|
||||
expect(text).toContain('LEFT JOIN perf ON perf."barcode" = df.barcode')
|
||||
expect(text).toContain('COALESCE(sum(perf."monthPerformance"), 0) AS "monthPerformance"')
|
||||
}
|
||||
expect(queryText(queryRaw.mock.calls[0][0]))
|
||||
.toContain('ORDER BY spp."monthPerformance" DESC')
|
||||
})
|
||||
|
||||
it('includes SPUs without sales records in all-SPU column filter options', async () => {
|
||||
queryRaw.mockResolvedValueOnce([{ value: 'DF-C1YMJ0009' }])
|
||||
const repository = new SupplyChainDropshipIssueRepositoryClass()
|
||||
|
||||
await expect(repository.listColumnFilterValues({
|
||||
field: 'spu',
|
||||
filters: { onlyPerformance: false },
|
||||
})).resolves.toEqual(['DF-C1YMJ0009'])
|
||||
|
||||
const text = queryText(queryRaw.mock.calls[0][0])
|
||||
expect(text).not.toContain('spp."monthPerformance" > 0')
|
||||
expect(text).toContain('ORDER BY spp."monthPerformance" DESC')
|
||||
expect(text).toContain('LEFT JOIN perf ON perf."barcode" = df.barcode')
|
||||
expect(text).toContain('COALESCE(sum(perf."monthPerformance"), 0) AS "monthPerformance"')
|
||||
})
|
||||
|
||||
it('creatorSpus with no matching styles yields an empty result condition', async () => {
|
||||
|
||||
@ -186,15 +186,15 @@ function spuCte(monthStart: string, monthEnd: string) {
|
||||
GROUP BY d."barcode"
|
||||
),
|
||||
spp AS (
|
||||
SELECT df.spu, sum(perf."monthPerformance") AS "monthPerformance"
|
||||
SELECT df.spu, COALESCE(sum(perf."monthPerformance"), 0) AS "monthPerformance"
|
||||
FROM df
|
||||
JOIN perf ON perf."barcode" = df.barcode
|
||||
LEFT JOIN perf ON perf."barcode" = df.barcode
|
||||
GROUP BY df.spu
|
||||
)
|
||||
`
|
||||
}
|
||||
|
||||
// 当月无业绩的 SPU 整行不显示:命中条件合并进基础候选集,
|
||||
// 默认不显示当月无正业绩的 SPU:命中条件合并进基础候选集,
|
||||
// 列表、总数和列头候选值口径保持一致。
|
||||
const SPU_MONTH_PERFORMANCE_CONDITION = Prisma.sql`spp."monthPerformance" > 0`
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user