mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 14:33:59 +00:00
Merge branch 'vapor/production' into dillon/90-e-invoice-e-1
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Bookings\Processors\RegenerateInvoiceBookingProcessor;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -34,7 +35,15 @@ class ProcessBookingForEInvoiceV2CommandJob implements ShouldQueue
|
||||
Log::info(Carbon::now() . ': Start job - Processing single booking for E-Invoice.');
|
||||
$start = new Carbon();
|
||||
|
||||
(App()->make(RegenerateInvoiceBookingProcessor::class))->execute($this->booking);
|
||||
$documents = $this->booking->documents()->whereIn('document_type', [DocumentType::PURCHASE_ORDER, DocumentType::INVOICE, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->get();
|
||||
|
||||
if ($documents->isEmpty()) {
|
||||
Log::info("Processing for E-Invoice, booking id : " . $this->booking->marking);
|
||||
(App()->make(RegenerateInvoiceBookingProcessor::class))->execute($this->booking);
|
||||
}
|
||||
else{
|
||||
Log::info("NO Processing for E-Invoice, booking id : " . $this->booking->marking);
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Bookings\Processors\RegenerateInvoiceBookingProcessor;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Booking;
|
||||
use App\Models\KeyValuePair;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class ProcessPaymentReportV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var array */
|
||||
private $details;
|
||||
|
||||
/**
|
||||
* ProcessPaymentReportV2CommandJob constructor.
|
||||
* @param array $details
|
||||
*/
|
||||
public function __construct(array $details)
|
||||
{
|
||||
$this->details = $details;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Processing single record from 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] Import.');
|
||||
$start = new Carbon();
|
||||
|
||||
$docNo = $this->details['docno'] ?? null;
|
||||
$docDate = $this->details['docdate'] ?? null;
|
||||
$debtorCode = $this->details['debtorcode'] ?? null;
|
||||
$description = $this->details['description'] ?? null;
|
||||
$paymentMethod = $this->details['paymentmethod'] ?? null;
|
||||
$paymentAmt = $this->details['paymentamt'] ?? null;
|
||||
$knockOffDocNo = $this->details['knockoffdocno'] ?? null;
|
||||
|
||||
Log::info("Processing Payment Report:", [
|
||||
'DocNo' => $docNo,
|
||||
'DocDate' => $docDate,
|
||||
'DebtorCode' => $debtorCode,
|
||||
'Description' => $description,
|
||||
'PaymentMethod' => $paymentMethod,
|
||||
'PaymentAmt' => $paymentAmt,
|
||||
'KnockOffDocNo' => $knockOffDocNo,
|
||||
]);
|
||||
|
||||
if($knockOffDocNo){
|
||||
$kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->where('value', $knockOffDocNo)->first();
|
||||
if($kvp){
|
||||
$booking = $kvp->owner;
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT, $docNo);
|
||||
}
|
||||
// if($eInvoiceValidationLink){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Processing single record from 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] Import. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
|
||||
|
||||
private function updateOrCreateKeyValuePair($booking, $key, $value)
|
||||
{
|
||||
$keyValuePairObject = new KeyValuePairObject($key, $value);
|
||||
$metadata = $booking->attributesKVP()->where('key', $key)->first();
|
||||
|
||||
if ($metadata) {
|
||||
(App()->make(UpdatesKeyValuePair::class))->execute($metadata, $keyValuePairObject);
|
||||
} else {
|
||||
(App()->make(CreatesKeyValuePair::class))->execute($booking, $keyValuePairObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Bookings\Processors\RegenerateInvoiceBookingProcessor;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Booking;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var array */
|
||||
private $details;
|
||||
|
||||
/**
|
||||
* ProcessSalesInvoiceReportV2CommandJob constructor.
|
||||
* @param array $details
|
||||
*/
|
||||
public function __construct(array $details)
|
||||
{
|
||||
$this->details = $details;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Processing single record for E-Invoice from Sales Invoice Report Import.');
|
||||
$start = new Carbon();
|
||||
|
||||
$docNo = $this->details['docno'] ?? null;
|
||||
$docDate = $this->details['docdate'] ?? null;
|
||||
$debtorCode = $this->details['debtorcode'] ?? null;
|
||||
$ref = $this->details['ref'] ?? null;
|
||||
$shipInfo = $this->details['shipinfo'] ?? null;
|
||||
$accNo = $this->details['accno'] ?? null;
|
||||
$detailDescription = $this->details['detaildescription'] ?? null;
|
||||
$furtherDescription = $this->details['furtherdescription'] ?? null;
|
||||
$classification = $this->details['classification'] ?? null;
|
||||
$deptNo = $this->details['deptno'] ?? null;
|
||||
$qty = $this->details['qty'] ?? null;
|
||||
$unitPrice = $this->details['unitprice'] ?? null;
|
||||
$submitEinvoice = $this->details['submiteinvoice'] ?? null;
|
||||
$consolidatedEinvoice = $this->details['consolidatedeinvoice'] ?? null;
|
||||
$eInvoiceValidationLink = $this->details['einvoicevalidationlink'] ?? null;
|
||||
|
||||
// Log for debugging
|
||||
Log::info("Processing Sales Invoice Report:", [
|
||||
'DocNo' => $docNo,
|
||||
'DocDate' => $docDate,
|
||||
'DebtorCode' => $debtorCode,
|
||||
'Ref' => $ref,
|
||||
'ShipInfo' => $shipInfo,
|
||||
'AccNo' => $accNo,
|
||||
'DetailDescription' => $detailDescription,
|
||||
'FurtherDescription' => $furtherDescription,
|
||||
'Classification' => $classification,
|
||||
'DeptNo' => $deptNo,
|
||||
'Qty' => $qty,
|
||||
'UnitPrice' => $unitPrice,
|
||||
'SubmitEinvoice' => $submitEinvoice,
|
||||
'ConsolidatedEinvoice' => $consolidatedEinvoice,
|
||||
'EInvoiceValidationLink' => $eInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$booking = Booking::where('marking', $ref)->first();
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo);
|
||||
}
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Processing single record for E-Invoice from Sales Invoice Report Import. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
|
||||
|
||||
private function updateOrCreateKeyValuePair($booking, $key, $value)
|
||||
{
|
||||
$keyValuePairObject = new KeyValuePairObject($key, $value);
|
||||
$metadata = $booking->attributesKVP()->where('key', $key)->first();
|
||||
|
||||
if ($metadata) {
|
||||
(App()->make(UpdatesKeyValuePair::class))->execute($metadata, $keyValuePairObject);
|
||||
} else {
|
||||
(App()->make(CreatesKeyValuePair::class))->execute($booking, $keyValuePairObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanCreateBookingRefund;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\UpdateRefundTransactionStatusLogic;
|
||||
@@ -58,6 +59,9 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/** @var CanCreateBookingRefund */
|
||||
private $canCreateBookingRefund;
|
||||
|
||||
/**
|
||||
* CreateBookingPaymentLogic constructor.
|
||||
* @param FetchesBookingQuotation $fetchBookingQuotation
|
||||
@@ -67,8 +71,9 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdateRefundTransactionStatusLogic $updateRefundTransactionStatusLogic
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
* @param CanCreateBookingRefund $canCreateBookingRefund
|
||||
*/
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, UpdateRefundTransactionStatusLogic $updateRefundTransactionStatusLogic, CreateRemarkProcessor $createRemarkProcessor)
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, UpdateRefundTransactionStatusLogic $updateRefundTransactionStatusLogic, CreateRemarkProcessor $createRemarkProcessor, CanCreateBookingRefund $canCreateBookingRefund)
|
||||
{
|
||||
$this->fetchBookingQuotation = $fetchBookingQuotation;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
@@ -77,6 +82,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updateRefundTransactionStatusLogic = $updateRefundTransactionStatusLogic;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
$this->canCreateBookingRefund = $canCreateBookingRefund;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,10 +99,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
|
||||
$invoice = $booking->transactions()->where('type', TransactionType::INVOICE)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->first();
|
||||
|
||||
//cief todo: 90 - move this into rules
|
||||
// if(auth()->user()->type === 3) {
|
||||
// throw new MalformedRequestException('You do not have the permission to refund the order.');
|
||||
// }
|
||||
// $this->canCreateBookingRefund->passes();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('RFD-');
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CanCreateBookingRefund extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
|
||||
if (in_array(Auth::user()->type, RoleTypes::ADMIN_ROLES)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BookingObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,13 @@ namespace App\Classes\Modules\Imports\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessPaymentReportV2CommandJob;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessSalesInvoiceReportV2CommandJob;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Imports\Services\AutoCountDataImport;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Models\Booking;
|
||||
@@ -44,7 +47,7 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Import Excel',
|
||||
'message' => 'You have successfully imported and updated booking details'
|
||||
'message' => 'You have successfully imported data from excel file'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -68,6 +71,13 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
throw new MalformedRequestException('Import function can only process one file at a time.');
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filePath = json_decode($file)->file_info->original->file;
|
||||
$import = new AutoCountDataImport($reportType);
|
||||
Excel::import($import, $filePath);
|
||||
}
|
||||
|
||||
/*
|
||||
foreach ($files as $file) {
|
||||
$collection = Excel::toCollection(null, json_decode($file)->file_info->original->file, null, null, true);
|
||||
|
||||
@@ -128,7 +138,7 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
throw new MalformedRequestException('Cannot process report type: ' . $reportType);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
@@ -182,15 +192,16 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
'EInvoiceValidationLink' => $eInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$booking = Booking::where('marking', $ref)->first();
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo);
|
||||
}
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
}
|
||||
}
|
||||
// $booking = Booking::where('marking', $ref)->first();
|
||||
// if($booking){
|
||||
// if($docNo != "" && $docNo != "<<New>>"){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo);
|
||||
// }
|
||||
// if($eInvoiceValidationLink){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// }
|
||||
// }
|
||||
ProcessSalesInvoiceReportV2CommandJob::dispatch($details);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,24 +230,25 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
|
||||
if($knockOffDocNo)
|
||||
{
|
||||
$kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->where('value', $knockOffDocNo)->first();
|
||||
if($kvp){
|
||||
$booking = $kvp->owner;
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT, $docNo);
|
||||
}
|
||||
// if($eInvoiceValidationLink){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// }
|
||||
}
|
||||
else{
|
||||
$unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
}
|
||||
ProcessPaymentReportV2CommandJob::dispatch($details);
|
||||
// $kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->where('value', $knockOffDocNo)->first();
|
||||
// if($kvp){
|
||||
// $booking = $kvp->owner;
|
||||
// if($booking){
|
||||
// if($docNo != "" && $docNo != "<<New>>"){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT, $docNo);
|
||||
// }
|
||||
// // if($eInvoiceValidationLink){
|
||||
// // $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// // }
|
||||
// }
|
||||
// else{
|
||||
// $unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// $unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Imports\Services;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithChunkReading;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessPaymentReportV2CommandJob;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessSalesInvoiceReportV2CommandJob;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkReading
|
||||
{
|
||||
protected $reportType;
|
||||
|
||||
public function __construct($reportType)
|
||||
{
|
||||
$this->reportType = $reportType;
|
||||
}
|
||||
|
||||
public function headingRow(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
*/
|
||||
public function collection(Collection $collection)
|
||||
{
|
||||
static $headerProcessed = false;
|
||||
foreach ($collection as $row) {
|
||||
if (!$headerProcessed) {
|
||||
$header = $row->keys()->map(fn($h) => strtolower(trim($h)))->toArray();
|
||||
$this->validateHeader($header, $this->reportType);
|
||||
$headerProcessed = true;
|
||||
}
|
||||
|
||||
if ($this->reportType === 'Sales Invoice Report') {
|
||||
ProcessSalesInvoiceReportV2CommandJob::dispatch($row->toArray());
|
||||
} elseif ($this->reportType === '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]') {
|
||||
ProcessPaymentReportV2CommandJob::dispatch($row->toArray());
|
||||
}
|
||||
else{
|
||||
throw new MalformedRequestException('Cannot process report type: ' . $this->reportType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function chunkSize(): int
|
||||
{
|
||||
return 1000;
|
||||
}
|
||||
|
||||
private function validateHeader(array $header, String $reportType)
|
||||
{
|
||||
$optionalColumn = 'einvoicevalidationlink';
|
||||
$salesInvoiceHeader = [
|
||||
'docno', 'docdate', 'debtorcode', 'ref', 'shipinfo', 'accno',
|
||||
'detaildescription', 'furtherdescription', 'classification',
|
||||
'deptno', 'qty', 'unitprice', 'submiteinvoice', 'consolidatedeinvoice'
|
||||
];
|
||||
$customersReportHeader = [
|
||||
'tin', 'identityno', 'name', 'identitytype', 'taxclassification', 'msiccode',
|
||||
'businessactivitydesc', 'debtorcode', 'tradename', 'address', 'postcode',
|
||||
'phone', 'emailaddress', 'city', 'countrycode', 'statecode'
|
||||
];
|
||||
$paymentReportHeader = [
|
||||
'docno',
|
||||
'docdate',
|
||||
'debtorcode',
|
||||
'description',
|
||||
'paymentmethod',
|
||||
'paymentamt',
|
||||
'knockoffdocno'
|
||||
];
|
||||
|
||||
if ($reportType === 'Sales Invoice Report' &&
|
||||
$header !== $salesInvoiceHeader &&
|
||||
$header !== [...$salesInvoiceHeader, $optionalColumn]) {
|
||||
throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.');
|
||||
}
|
||||
elseif ($reportType === 'Customers Report' && $header !== $customersReportHeader) {
|
||||
throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.');
|
||||
}
|
||||
elseif ($reportType === '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]' && $header !== $paymentReportHeader) {
|
||||
throw new MalformedRequestException('Uploaded Excel file format is incorrect. Column headers do not match expected format.');
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-5
@@ -14,8 +14,10 @@ use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\Modules\Transactions\Standards\Rules\CanUpdateRefundTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\RemarkRefundReason;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -54,6 +56,9 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
/** @var UpdateBookingAmountLogic */
|
||||
private $updateBookingAmountLogic;
|
||||
|
||||
/** @var CanUpdateRefundTransactionStatus */
|
||||
private $canUpdateRefundTransactionStatus;
|
||||
|
||||
/**
|
||||
* CreatePaymentVerificationDocumentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
@@ -64,8 +69,9 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
* @param CalculatesBookingPayableAmount $calculatesBookingPayableAmount
|
||||
* @param CalculatesBookingRefundAmount $calculatesBookingRefundAmount
|
||||
* @param UpdateBookingAmountLogic $updateBookingAmountLogic
|
||||
* @param CanUpdateRefundTransactionStatus $canUpdateRefundTransactionStatus
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument, CreditWalletProcessor $creditWalletProcessor, CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingRefundAmount $calculatesBookingRefundAmount, UpdateBookingAmountLogic $updateBookingAmountLogic)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument, CreditWalletProcessor $creditWalletProcessor, CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingRefundAmount $calculatesBookingRefundAmount, UpdateBookingAmountLogic $updateBookingAmountLogic, CanUpdateRefundTransactionStatus $canUpdateRefundTransactionStatus)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
@@ -75,6 +81,7 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
$this->calculatesBookingPayableAmount = $calculatesBookingPayableAmount;
|
||||
$this->calculatesBookingRefundAmount = $calculatesBookingRefundAmount;
|
||||
$this->updateBookingAmountLogic = $updateBookingAmountLogic;
|
||||
$this->canUpdateRefundTransactionStatus = $canUpdateRefundTransactionStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,10 +91,7 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
//cief todo: 90 - move this into rules
|
||||
// if(auth()->user()->type === 3) {
|
||||
// throw new MalformedRequestException('You do not have the permission to refund the order.');
|
||||
// }
|
||||
// $this->canUpdateRefundTransactionStatus->passes();
|
||||
|
||||
$refundTransaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Models\Booking;
|
||||
use App\Models\SegmentConstant;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateInvoiceTransactionProcessor
|
||||
@@ -214,8 +215,23 @@ class CreateInvoiceTransactionProcessor
|
||||
|
||||
$booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::BILL);
|
||||
|
||||
$transaction = $booking->transactions()->payments()->where('status', ApprovalStatus::COMPLETED)->first()
|
||||
->transactions()->where('type', TransactionType::BILL)->first();
|
||||
$paymentTransaction = $booking->transactions()->payments()->where('status', ApprovalStatus::COMPLETED)->first();
|
||||
|
||||
$transaction = null;
|
||||
if($paymentTransaction){
|
||||
$transaction = $paymentTransaction->transactions()->where('type', TransactionType::BILL)->first();
|
||||
}
|
||||
else{ // Special handling for refund cases (When a refund is deleted via DeleteRefundTransactionLogic, a booking payment transaction is set to ApprovalStatus::APPROVED)
|
||||
$temp = $booking->transactions()->payments()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
// Lets check if there is a refund case
|
||||
$refund = $temp->transactions()->refunds()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
if($refund){
|
||||
$transaction = $temp;
|
||||
}
|
||||
else{
|
||||
throw new Exception("No payment found for booking '$booking->id'.");
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_object = new TransactionObject(
|
||||
$billNumber,
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CanUpdateRefundTransactionStatus extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
|
||||
if (in_array(Auth::user()->type, RoleTypes::ADMIN_ROLES)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BookingObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="number">EDO: {{ $transaction->bill_no }}</div>
|
||||
<div class="number">EDO: {{ str_replace(['EINV-', 'INV-'], 'EDO-', $transaction->bill_no) }}</div>
|
||||
|
||||
<div class="ref">REF: {{ $transaction->booking->marking }}</div>
|
||||
<div class="date">Date: {{
|
||||
|
||||
@@ -111,5 +111,12 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
|
||||
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</htmlpagefooter>
|
||||
@endsection
|
||||
|
||||
@@ -71,4 +71,12 @@
|
||||
Account Name: CIEF Worldwide Sdn Bhd<br>
|
||||
Account No: 568603010762<br>
|
||||
</div>
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
|
||||
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</htmlpagefooter>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user