mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-29 01:13:59 +00:00
1688 PO Automation Project
This commit is contained in:
+19
-22
@@ -78,6 +78,7 @@ class ImportPurchaseOrderTransactionLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request, $id = ''): JsonResponse
|
||||
{
|
||||
$products = []; // Initialize
|
||||
if ($request->has('products') && is_array($request->input('products'))) {
|
||||
$this->canETLPurchaseOrder->passes();
|
||||
|
||||
@@ -100,32 +101,28 @@ class ImportPurchaseOrderTransactionLogic extends AbstractControllerLogic
|
||||
$products = $this->etlPurchaseOrderTransactionProcessor->execute($products, $productsMetadata);
|
||||
}
|
||||
} else {
|
||||
$files = $request->file('files');
|
||||
$products = []; // Initialize
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
foreach ($object->getFiles() as $file) {
|
||||
$collection = Excel::toCollection(null, json_decode($file)->file_info->original->file, null, null, true);
|
||||
|
||||
if ($files) {
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
foreach ($object->getFiles() as $file) {
|
||||
$collection = Excel::toCollection(null, json_decode($file)->file_info->original->file, null, null, true);
|
||||
$sheet = $collection->first()->skip(1);
|
||||
|
||||
$sheet = $collection->first()->skip(1);
|
||||
$products = $sheet->map(function ($row) {
|
||||
Log::info($row);
|
||||
$stockCode = $row[0];
|
||||
$description = $row[1];
|
||||
$quantity = $row[2];
|
||||
$unit_price = $row[3];
|
||||
|
||||
$products = $sheet->map(function ($row) {
|
||||
Log::info($row);
|
||||
$stockCode = $row[0];
|
||||
$description = $row[1];
|
||||
$quantity = $row[2];
|
||||
$unit_price = $row[3];
|
||||
|
||||
return [
|
||||
'stockCode' => $stockCode,
|
||||
'description' => $description,
|
||||
'quantity' => $quantity,
|
||||
'unit_price' => $unit_price
|
||||
];
|
||||
})->all();
|
||||
}
|
||||
return [
|
||||
'stockCode' => $stockCode,
|
||||
'description' => $description,
|
||||
'quantity' => $quantity,
|
||||
'unit_price' => $unit_price
|
||||
];
|
||||
})->all();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @var Booking $booking */
|
||||
|
||||
Reference in New Issue
Block a user