mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
fix up group transactions bulk purchase orders
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
use App\Classes\Jobs\GenerateGroupTransactionsWhiteForm;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
@@ -52,70 +53,60 @@ class RecoverGroupTransactionTableSeeder extends Seeder
|
||||
)
|
||||
->orderBy('id')->get();
|
||||
|
||||
foreach ($transaction_group as $group) {
|
||||
$transactions = Transaction::
|
||||
where('type', 3)
|
||||
->where('issuer', $group->issuer)
|
||||
->where('currency_rate', $group->currency_rate)
|
||||
->where(DB::raw("DATE_FORMAT(created_at, '%Y-%m-%d %H:%i')"), $group->new_date)
|
||||
->get();
|
||||
foreach ($transaction_group as $group) {
|
||||
$transactions = Transaction::
|
||||
where('type', 3)
|
||||
->where('issuer', $group->issuer)
|
||||
->where('currency_rate', $group->currency_rate)
|
||||
->where(DB::raw("DATE_FORMAT(created_at, '%Y-%m-%d %H:%i')"), $group->new_date)
|
||||
->get();
|
||||
|
||||
$group = new Group();
|
||||
$group->save();
|
||||
$group = new Group();
|
||||
$group->save();
|
||||
|
||||
$issuer = '';
|
||||
$date = now();
|
||||
$receiver = '';
|
||||
$amount = 0;
|
||||
$original_amount = 0;
|
||||
$currency_id = 0;
|
||||
$original_currency_id = '';
|
||||
$currency_rate = '';
|
||||
$tax = 0;
|
||||
$service_charge = 0;
|
||||
$issuer = '';
|
||||
$date = now();
|
||||
$receiver = '';
|
||||
$amount = 0;
|
||||
$original_amount = 0;
|
||||
$currency_id = 0;
|
||||
$original_currency_id = '';
|
||||
$currency_rate = '';
|
||||
$tax = 0;
|
||||
$service_charge = 0;
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
$group->transactions()->sync($transaction->id, false);
|
||||
$issuer = $transaction->issuer;
|
||||
$date = $transaction->created_at;
|
||||
$receiver = $transaction->receiver;
|
||||
$amount += $transaction->amount;
|
||||
$original_amount += $transaction->original_amount;
|
||||
$currency_id = $transaction->currency_id;
|
||||
$original_currency_id = $transaction->original_currency_id;
|
||||
$currency_rate = $transaction->currency_rate;
|
||||
$tax += $transaction->tax;
|
||||
$service_charge += $transaction->service_charge;
|
||||
}
|
||||
|
||||
$group->issuer = $issuer;
|
||||
$group->receiver = $receiver;
|
||||
$group->amount = $amount;
|
||||
$group->original_amount = $original_amount;
|
||||
$group->currency_id = $currency_id;
|
||||
$group->original_currency_id = $original_currency_id;
|
||||
$group->currency_rate = $currency_rate;
|
||||
$group->tax = $tax;
|
||||
$group->service_charge = $service_charge;
|
||||
$group->created_at = $date;
|
||||
$group->updated_at = $date;
|
||||
|
||||
$group->update();
|
||||
|
||||
// $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $group->transactions, 'transferFeeTransactions' => $group->transferFees, 'supplier' => $group->issuerCompany]);
|
||||
//
|
||||
// $object = new DocumentObject(
|
||||
// DocumentType::CURRENCY_VENDOR_ORDER,
|
||||
// [chunk_split('data:application/pdf;base64,'.base64_encode($pdf->output()))],
|
||||
// '',
|
||||
// ApprovalStatus::COMPLETED,
|
||||
// 'currency_vendor_order'
|
||||
// );
|
||||
//
|
||||
// /** @var Document $document */
|
||||
// $document = $this->createsDocument->execute($group, $object);
|
||||
// $this->createsFile->execute($document, $object);
|
||||
foreach ($transactions as $transaction) {
|
||||
$group->transactions()->sync($transaction->id, false);
|
||||
$issuer = $transaction->issuer;
|
||||
$date = $transaction->created_at;
|
||||
$receiver = $transaction->receiver;
|
||||
$amount += $transaction->amount;
|
||||
$original_amount += $transaction->original_amount;
|
||||
$currency_id = $transaction->currency_id;
|
||||
$original_currency_id = $transaction->original_currency_id;
|
||||
$currency_rate = $transaction->currency_rate;
|
||||
$tax += $transaction->tax;
|
||||
$service_charge += $transaction->service_charge;
|
||||
}
|
||||
|
||||
$group->issuer = $issuer;
|
||||
$group->receiver = $receiver;
|
||||
$group->amount = $amount;
|
||||
$group->original_amount = $original_amount;
|
||||
$group->currency_id = $currency_id;
|
||||
$group->original_currency_id = $original_currency_id;
|
||||
$group->currency_rate = $currency_rate;
|
||||
$group->tax = $tax;
|
||||
$group->service_charge = $service_charge;
|
||||
$group->status = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$group->created_at = $date;
|
||||
$group->updated_at = $date;
|
||||
|
||||
$group->update();
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
GenerateGroupTransactionsWhiteForm::dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Company;
|
||||
use App\Models\Transaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateSuppliersReferenceSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::beginTransaction();
|
||||
|
||||
$suppliers = Company::where('business_type', \App\Classes\ValueObjects\Constants\BusinessType::CURRENCY_VENDOR)->get();
|
||||
|
||||
foreach ($suppliers as $supplier) {
|
||||
if(in_array($supplier->name, ['ATVANTIC IMPORT EXPORT SDN BHD', 'Atvantic - JACK'])) $supplier->reference = 'ATVANTIC IMPORT EXPORT SDN BHD (1309816-P)';
|
||||
if(in_array($supplier->name, ['BK GEMILANG SDN BHD', 'BK GEMILANG - JACK'])) $supplier->reference = 'BK GEMILANG SDN BHD (1403513-U)';
|
||||
if(in_array($supplier->name, ['YSN - Teh', 'YSN Solution Trading Sdn Bhd - Teh', 'YSN Solution Trading Sdn Bhd', 'YSN SOLUTION TRADING SDN BHD - Jack'])) $supplier->reference = 'YSN Solution Trading Sdn Bhd (1393892-D)';
|
||||
if(in_array($supplier->name, ['RACK SOLUTION INDUSTRIES SDN BHD'])) $supplier->reference = 'RACK SOLUTION INDUSTRIES SDN BHD (954723-W)';
|
||||
if(in_array($supplier->name, ['RACK SOLUTION INDUSTRIES SDN BHD'])) $supplier->reference = 'RACK SOLUTION INDUSTRIES SDN BHD (954723-W)';
|
||||
if(in_array($supplier->name, ['OFY UNION SDN BHD'])) $supplier->reference = 'OFY UNION SDN BHD (1410695-H)';
|
||||
if(in_array($supplier->name, ['Simply Infantry Sdn. Bhd.', 'SIMPLY INFANTRY SDN. BHD. - JACK'])) $supplier->reference = 'Simply Infantry Sdn. Bhd. (14393131-W)';
|
||||
if(in_array($supplier->name, ['HIGH HILL INTERNATIONAL MARKETING SDN BHD', 'HIGH HILL INTERNATIONAL SDN BHD - JACK'])) $supplier->reference = 'HIGH HILL INTERNATIONAL MARKETING SDN BHD (1419836-X)';
|
||||
if(in_array($supplier->name, ['CNT CARGO SDN BHD', 'CNT CARGO SDN BHD - JACK'])) $supplier->reference = 'CNT CARGO SDN BHD 202101036178(1436478-V)';
|
||||
if(in_array($supplier->name, ['WEST EXPRESS INTERNATIONAL TRADING SDN BHD'])) $supplier->reference = 'WEST EXPRESS INTERNATIONAL TRADING SDN BHD (1432178-T)';
|
||||
if(in_array($supplier->name, ['CIEF WORLDWIDE SDN. BHD.'])) $supplier->reference = 'CIEF WORLDWIDE SDN. BHD. (1134596-M)';
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user