input('files'), '', ApprovalStatus::APPROVED, 'imports'); $file = json_decode($object->getFiles()[0])->file_info->original->file; $import = new GenericImport(); Excel::import($import, $file); $excelRows = $import->rows; $excelRows = $excelRows->toArray(); foreach ($excelRows as $row) { dd($row); // $row['debtor_code'] // attempt 1 - try map by amount and date // $transactionDate = $this->changeExcelDate($row['date']); // $transaction = Transaction::where('original_amount', $row['total'])->whereDate('created_at', $transactionDate)->get(); // if ($transaction) { // // check company // // $company = Company::where('debtor', $row['debtor_code'])->first(); // // dd($company); // // try to verify is it the correct transaction // } // Shipping Info // TOPUP -> map with transaction.bill_no if (str_starts_with($row['shipping_info'], 'TOPUP')) { // find in exchange first, if cannont then find in izyim // (App()->make(ChecksBillNumber::class))->execute($bill_no, 'exchange'); } // if 5 digits -> exchange booking reference // find transation // find statement_transaction_owners, and fill up the details // if <5 digits, find the transaction id (order number in izyim), find the payment in izyim // find transation // find statement_transaction_owners, and fill up the details // dd([ // 'type' => $statementTransactionOwnerType, // 'system' => $system, // // 'owner_type' => Transaction::class, // // todo-new: make sure owner_type is a class // 'owner_type' => $owner_type, // 'owner_id' => $owner_id, // 'owner_reference' => $owner_reference // ]); // $bankStatementTransaction->owners()->firstOrCreate([ // 'type' => $statementTransactionOwnerType, // 'system' => $system, // // 'owner_type' => Transaction::class, // // todo-new: make sure owner_type is a class // 'owner_type' => $owner_type, // 'owner_id' => $owner_id, // 'owner_reference' => $owner_reference // ]); } } public function changeExcelDate($date) { $unixTime = (($date - 25569) * 86400); $date = new DateTime("@$unixTime"); return $date->format('Y-m-d'); // Change the format to 'Y-m-d' } }