]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Merge branch 'develop' into feature-zozirova-erp_256-send_doc_on_1c
authormarina <m.zozirova@gmail.com>
Wed, 18 Dec 2024 08:42:27 +0000 (11:42 +0300)
committermarina <m.zozirova@gmail.com>
Wed, 18 Dec 2024 08:42:27 +0000 (11:42 +0300)
1  2 
erp24/api2/controllers/DataController.php

index b2b5989f11806754634444b689c447d0c5bf1404,c72aa2194541658bab6666a2dd3e021fb2fda614..5428a4243302de4d1a6d3fc17a4dca468734ee70
@@@ -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,