From: marina Date: Wed, 18 Dec 2024 08:42:27 +0000 (+0300) Subject: Merge branch 'develop' into feature-zozirova-erp_256-send_doc_on_1c X-Git-Tag: 1.7~150^2~2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=767c6141965fd59af107bc0fbb95996c4649adf9;p=erp24_rep%2Fyii-erp24%2F.git Merge branch 'develop' into feature-zozirova-erp_256-send_doc_on_1c --- 767c6141965fd59af107bc0fbb95996c4649adf9 diff --cc erp24/api2/controllers/DataController.php index b2b5989f,c72aa219..5428a424 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@@ -440,91 -405,13 +444,91 @@@ class DataController extends BaseContro } } catch (Exception $e3) { - file_put_contents(self::OUT_DIR . '/log_created_waybill_incoming_error.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e3->getMessage(). ' file: '. $e3->getFile() . ' line: '. $e3->getLine(), FILE_APPEND); + file_put_contents(self::OUT_DIR . '/log_created_waybill_incoming_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e3->getMessage() . ' file: ' . $e3->getFile() . ' line: ' . $e3->getLine(), FILE_APPEND); } - return compact('waybillIncoming', 'waybillIncomingIds'); + return compact('waybillIncoming', 'waybillIncomingIds', 'waybillIncomingResult'); } - private function getCreateEmployee() : array { + + private function getResortingDoc(): array + { + $replacementInvoice = []; + $replacementInvoicesIds = []; + $replacementInvoiceResult = []; + + try { + $replacementInvoice = ReplacementInvoice::find() + ->select(['id', 'guid', 'shift_transfer_id', 'store_guid', 'number', 'date', 'comment', 'quantity', 'summ']) + ->andWhere(['status' => WriteOffsErp::STATUS_CONFIRM]) + ->indexBy('id') + ->asArray() + ->all(); + + if (!empty($replacementInvoice)) { + $replacementInvoicesIds = array_column($replacementInvoice, 'id'); + $shiftTransferIds = array_column($replacementInvoice, 'shift_transfer_id'); + + $products = EqualizationRemains::find() + ->where(['in', 'shift_transfer_id', $shiftTransferIds]) + ->asArray() + ->all(); + + $replacementInvoiceProducts = []; + + foreach ($products as $product) { + $replacementInvoiceProducts[$product['']][] = [ + 'product_id' => $product->product_id, + 'color' => Products1cAdditionalCharacteristics::findOne([ + 'property_id' => '5880b25c-809f-11ef-84ea-ac1f6b1b7573', + 'product_id' => $product->product_id])->value ?? '', + 'price' => $product->product_price, + 'new_product_id' => $product->product_replacement_id, + 'new_color' => Products1cAdditionalCharacteristics::findOne([ + 'property_id' => '5880b25c-809f-11ef-84ea-ac1f6b1b7573', + 'product_id' => $product->product_replacement_id])->value ?? '', + 'new_price' => $product->product_replacement_price, + 'quantity' => $product->product_replacement_count, + ]; + } + + $replacementInvoiceTemp = $replacementInvoice; + foreach ($replacementInvoiceTemp as $key => $row) { + $replacementInvoiceProductsRow = []; + if (!isset($replacementInvoice[$key]['items'])) { + $replacementInvoice[$key]['items'] = []; + } + if (array_key_exists($row['id'], $replacementInvoiceProducts)) { + $replacementInvoiceProductsRow = $replacementInvoiceProducts[$row['id']]; + } + if (!empty($replacementInvoiceProductsRow)) { + $replacementInvoice[$key]['items'] = $replacementInvoiceProductsRow; + } + } + + foreach ($replacementInvoice as $row) { + $replacementInvoiceResult[] = [ + 'id' => $row['guid'], + 'store_id' => $row['store_guid'], + 'type' => 'ревизия при передаче смены', + 'cause' => 'Документ пересортицы при передаче смены в ERP ' . $row['number'], + 'items' => $row['items'], + 'summ' => $row['summ'], + 'comment' => $row['comment'], + ]; + } + } + + } catch (Exception $e3) { + file_put_contents(self::OUT_DIR . '/log_created_replacement_invoice_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e3->getMessage() . ' file: ' . $e3->getFile() . ' line: ' . $e3->getLine(), FILE_APPEND); + } + + return compact('replacementInvoice', 'replacementInvoicesIds', 'replacementInvoiceResult'); + } + + + private function getCreateEmployee(): array + { $employeeOnShiftArray = EmployeeOnShift::find() ->where([ 'status' => EmployeeOnShift::STATUS_ACCEPT,