'number' => 'ЕРП_НС_' . date("Y-m-d_H-i") . '_' . $model->id
]);
- WaybillWriteOffsProducts::setData($model, $shiftTransfer);
-
- $summaries = WaybillWriteOffsProducts::find()
- ->andWhere(['waybill_write_offs_id' => $model->id])
- ->select([
- 'total_product_count' => 'sum(product_count)',
- 'total_summ' => 'sum(summ)',
- 'total_summ_self_cost' => 'sum(summ_self_cost)'
- ])
- ->asArray()
- ->one();
-
- if ($summaries) {
- $model->updateAttributes([
- 'quantity' => $summaries['total_product_count'],
- 'summ' => $summaries['total_summ'],
- 'summ_self_cost' => $summaries['total_summ_self_cost']
- ]);
- }
- } catch (\Exception $exception) {
- throw new \Exception($exception);
- }
-
- try{
- $model->save();
-
- $model->updateAttributes([
- 'number' => 'ЕРП_ПН_' . date("Y-m-d_H-i") . '_' . $model->id
- ]);
-
WaybillIncomingProducts::setData($model, $shiftTransfer);
$summaries = WaybillIncomingProducts::find()
'summ_self_cost' => $summaries['total_summ_self_cost']
]);
}
- } catch (\Throwable $exception) {
+ } catch (\Exception $exception) {
throw new \Exception($exception);
}
}