}
}
+ public static function getWriteOffsItems() {
+ return [
+ WriteOffsErp::WRITE_OFFS_TYPE_BRAK,
+ WriteOffsErp::WRITE_OFFS_TYPE_DELIVERY_BRAK,
+ WriteOffsErp::WRITE_OFFS_TYPE_DUE_TO_EQUIPMENT_FAILURE_BRAK,
+ WriteOffsErp::WRITE_OFFS_TYPE_RESORTING_DOES_NOT_COUNT_TOWARDS_COST,
+ ];
+ }
+
/**
* {@inheritdoc}
*/
->indexBy('type')
->asArray()->all();
- foreach ($writeOffs as $key => $data) {
+ foreach (MotivationCostsItem::getWriteOffsItems() as $key) {
+ $data = $writeOffs[$key] ?? [];
$motivationItemType = MotivationCostsItem::writeOffsToMotivationItemMap($key);
- if (empty($motivationItemType)) {
- continue;
- }
$motivationCostsItem = MotivationCostsItem::find()->where(['name' => $motivationItemType])->one();
/** @var $motivationCostsItem MotivationCostsItem */
if ($motivation) {
$motivationValue->value_id = $motivationCostsItem->code;
$motivationValue->value_type = $motivationCostsItem->data_type;
}
- $motivationValue->value_float = $data['total'];
+ $motivationValue->value_float = $data['total'] ?? 0;
$motivationValue->save();
if ($motivationValue->getErrors()) {
throw new \Exception(Json::encode($motivationValue->getErrors()));