feat: fix 模版报错报错 (#971)

Co-authored-by: lyx <2027667395@qq.com>
Reviewed-on: daoyoucloud/tachybase#971
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: hello@lv <2256334253@qq.com>
Co-committed-by: hello@lv <2256334253@qq.com>
This commit is contained in:
hello@lv 2024-05-10 14:30:50 +08:00 committed by sealday
parent 19a4d15160
commit d21d032c11

View File

@ -92,7 +92,7 @@ export class RecordService {
if (!values) return;
if (values.new_contracts.length) {
const contracts = values.new_contracts.map((item) => item.contract).find((i) => i.record_category === '1');
if (contracts && values.items.length) {
if (contracts && values.items && values.items?.length > 0) {
const leaseRule = await this.db.getRepository('contract_plan_lease_items').find({
where: {
contract_id: contracts.id,
@ -187,6 +187,7 @@ export class RecordService {
items: [],
project_id: item.contract.dataValues.project_id,
};
if (!item.fees) return;
const stockItems = await Promise.all(
item.fees.map(async (fee) => {
if (typeof fee !== 'object') return;