mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-22 05:53:58 +00:00
Merge branch 'dillon/accounting-bank-mapping' into 'development'
Dillon/accounting bank mapping See merge request CIEFWorldwideSdnBhd/exchange-2.0!137
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Imports;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Imports\Services\GenericImport;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Segment;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment;
|
||||
use App\Classes\Modules\Companies\Processors\AssignSegmentProcessor;
|
||||
use App\Models\Company;
|
||||
use App\Models\SeasonalSegment;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class ImportStatementInvoiceController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function import(Request $request)
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$object = new DocumentObject('', $request->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'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Imports;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Imports\Services\GenericImport;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Segment;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment;
|
||||
use App\Classes\Modules\Companies\Processors\AssignSegmentProcessor;
|
||||
use App\Models\Company;
|
||||
use App\Models\SeasonalSegment;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class ImportStatementReceiptsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function import(Request $request)
|
||||
{
|
||||
$object = new DocumentObject('', $request->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) {
|
||||
// if has date column
|
||||
// $transactionDate = $this->changeExcelDate($row['date']);
|
||||
}
|
||||
}
|
||||
|
||||
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'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user