foreach ($exportImportTables as $store_id => $store_guid) {
if (isset($motivations[$store_id])) {
- $writeOffs = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.summ'])
+ $writeOffs = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.price'])
->rightJoin('write_offs_products wop', 'wop.write_offs_id = wo.id')
->where(['between', 'wo.date', $monthStart, $monthEnd])
->andWhere(['wo.store_id' => $store_guid])
if (($data['type'] ?? '') == $key) {
$value = ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0)
* ($data['quantity'] ?? 0);
- $sum += $value > 0 ? $value : ($data['summ'] ?? 0);
+ $sum += $value > 0 ? $value : ($data['price'] ?? 0) * ($data['quantity'] ?? 0);
}
}
$exportImportTable = ExportImportTable::find()->select(['export_val'])->where(['entity' => 'city_store', 'entity_id' => $storeId, 'export_id' => 1])->one();
if ($exportImportTable) {
- $writeOffs = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.summ'])
+ $writeOffs = WriteOffs::find()->alias('wo')->select(['wo.type', 'wo.date', 'wop.product_id', 'wop.quantity', 'wop.price'])
->rightJoin('write_offs_products wop', 'wop.write_offs_id = wo.id')
->where(['between', 'wo.date', $startDate, $endDate])
->andWhere(['wo.store_id' => $exportImportTable->export_val])
foreach($writeOffs as $data) {
$value = ($selfCostProductMap[date("Y-m-d", strtotime($data['date']))][$data['product_id']] ?? 0)
* ($data['quantity'] ?? 0);
- $sum += $value > 0 ? $value : ($data['summ'] ?? 0);
+ $sum += $value > 0 ? $value : ($data['price'] ?? 0) * ($data['quantity'] ?? 0);
}
return $sum;