Код:
async function change_plan(): Promise {
const plan = await Context.data.companies_plan!.fetch();
const promises: Promise[] = [];
const allPlans = await Promise.all(plan.data.employee_plans!.map(async f => f.plan_sotrudnika.fetch()));
for (const row of plan.data.employee_plans!) {
// const ePlan = await row.plan_sotrudnika!.fetch();
const ePlan = allPlans.find(f => f.id === row.plan_sotrudnika.id);
if (ePlan && ePlan.data.planned_amount!.asFloat() !== row.plan!.asFloat()) {
ePlan.data.planned_amount = row.plan;
promises.push(ePlan.save())
}
};
await Promise.all(promises)