fix: 修复结算单查看没有考虑替身合同问题 (#1475)

Reviewed-on: daoyoucloud/tachybase#1475
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-08-21 17:10:43 +08:00 committed by sealday
parent 7d77549630
commit 96ae769d99
3 changed files with 34 additions and 7 deletions

View File

@ -419,11 +419,11 @@ export const useFilterBlockActionProps = () => {
const storedFilter = block.service.params?.[1]?.filters || {};
const filter = {
formValues: {},
formValues: { ...form.values },
customValues: {},
customFilter: {},
};
if (Object.keys(form.values)?.includes('__custom')) {
if (Object.keys(filter.formValues)?.includes('__custom')) {
const values = { ...form.values };
delete values['__custom'];
filter.formValues = { ...values };
@ -438,7 +438,6 @@ export const useFilterBlockActionProps = () => {
storedFilter[uid] = removeNullCondition(
transformToFilter(filter.formValues, fieldSchema, getCollectionJoinField, name),
);
const mergedFilter = mergeFilter([
...Object.values(storedFilter).map((filter) => removeNullCondition(filter)),
block.defaultFilter,

View File

@ -58,8 +58,11 @@ export class SettlementController {
type: QueryTypes.SELECT,
});
const utcOffset = ctx.get('X-Timezone');
const { calc, contracts } = await this.settlmentService.settlement(settlement as any, utcOffset);
const { calc, contracts: settlementContracts } = await this.settlmentService.settlement(
settlement as any,
utcOffset,
);
const contracts = { ...settlementContracts, ...settlementContracts['alternative_contract'][0] };
const cache = ctx.app.cacheManager.getCache('@hera/plugin-rental') as Cache;
const key = stringify({ calc, contracts, result: systemSetting });
@ -98,7 +101,11 @@ export class SettlementController {
type: QueryTypes.SELECT,
});
const utcOffset = ctx.get('X-Timezone');
const { calc, contracts } = await this.settlmentService.settlement(settlement as any, utcOffset);
const { calc, contracts: settlementContracts } = await this.settlmentService.settlement(
settlement as any,
utcOffset,
);
const contracts = { ...settlementContracts, ...settlementContracts['alternative_contract'][0] };
const excel = { calc, contracts, result: systemSetting };
ctx.body = excel;
}

View File

@ -48,6 +48,17 @@ SELECT
WHERE
contracts."updatedById" = u.id
)
) || JSONB_SET(
TO_JSONB(contracts),
'{alternative_contract}',
(
SELECT
COALESCE(JSONB_AGG(c3), '{}'::jsonb)
FROM
contracts c3
WHERE
c3.id = settlements.contract_id
)
)
) AS contracts,
(
@ -83,7 +94,17 @@ FROM
settlement_items."type" = :type
OR settlement_items."type" = 'fee'
)
JOIN contracts ON contracts."id" = settlements.contract_id
JOIN contracts ON contracts."id" = (
SELECT
CASE
WHEN c.project_id IS NULL THEN c.alternative_contract_id
ELSE c.id
END AS result_id
FROM
contracts c
WHERE
c.id = settlements.contract_id
)
WHERE
settlements.id = :settlementsId
GROUP BY