mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 21:43:57 +00:00
Merge branch 'dillon/90-e-invoice-f-2' into vapor/development
This commit is contained in:
@@ -4,7 +4,8 @@ namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessSalesInvoiceReportV2CommandJob;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBooking;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\UpdateBookingSalesInvoiceDTO;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBookingSalesInvoice;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -23,19 +24,19 @@ class UpdateBookingSalesInvoiceLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateBooking */
|
||||
private $canUpdateBooking;
|
||||
/** @var CanUpdateBookingSalesInvoice */
|
||||
private $canUpdateBookingSalesInvoice;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateBookingSalesInvoiceLogic constructor.
|
||||
* @param CanUpdateBooking $canUpdateBooking
|
||||
* @param CanUpdateBookingSalesInvoice $canUpdateBookingSalesInvoice
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateBooking $canUpdateBooking
|
||||
CanUpdateBookingSalesInvoice $canUpdateBookingSalesInvoice
|
||||
)
|
||||
{
|
||||
$this->canUpdateBooking = $canUpdateBooking;
|
||||
$this->canUpdateBookingSalesInvoice = $canUpdateBookingSalesInvoice;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,26 +47,27 @@ class UpdateBookingSalesInvoiceLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$data = [
|
||||
'docno' => $request->input('DocNo'),
|
||||
'docdate' => $request->input('DocDate'),
|
||||
'debtorcode' => $request->input('DebtorCode'),
|
||||
'ref' => $request->input('Ref'),
|
||||
'shipinfo' => $request->input('ShipInfo'),
|
||||
'accno' => $request->input('AccNo'),
|
||||
'detaildescription' => $request->input('DetailDescription'),
|
||||
'furtherdescription' => $request->input('FurtherDescription'),
|
||||
'classification' => $request->input('Classification'),
|
||||
'deptno' => $request->input('DeptNo'),
|
||||
'qty' => $request->input('Qty'),
|
||||
'unitprice' => $request->input('UnitPrice'),
|
||||
'submiteinvoice' => $request->input('SubmitEinvoice'),
|
||||
'consolidatedeinvoice' => $request->input('ConsolidatedEinvoice'),
|
||||
'einvoicevalidationlink' => $request->input('EInvoiceValidationLink'),
|
||||
'docno' => $request->input('docno', $request->input('DocNo')),
|
||||
'docdate' => $request->input('docdate', $request->input('DocDate')),
|
||||
'debtorcode' => $request->input('debtorcode', $request->input('DebtorCode')),
|
||||
'ref' => $request->input('ref', $request->input('Ref')),
|
||||
'shipinfo' => $request->input('shipinfo', $request->input('ShipInfo')),
|
||||
'accno' => $request->input('accno', $request->input('AccNo')),
|
||||
'detaildescription' => $request->input('detaildescription', $request->input('DetailDescription')),
|
||||
'furtherdescription' => $request->input('furtherdescription', $request->input('FurtherDescription')),
|
||||
'classification' => $request->input('classification', $request->input('Classification')),
|
||||
'deptno' => $request->input('deptno', $request->input('DeptNo')),
|
||||
'qty' => $request->input('qty', $request->input('Qty')),
|
||||
'unitprice' => $request->input('unitprice', $request->input('UnitPrice')),
|
||||
'submiteinvoice' => $request->input('submiteinvoice', $request->input('SubmitEinvoice')),
|
||||
'consolidatedeinvoice' => $request->input('consolidatedeinvoice', $request->input('ConsolidatedEinvoice')),
|
||||
'einvoicevalidationlink' => $request->input('einvoicevalidationlink', $request->input('EInvoiceValidationLink')),
|
||||
];
|
||||
|
||||
Log::info('UpdateBookingSalesInvoiceLogic: ' . json_encode($data));
|
||||
$dto = new UpdateBookingSalesInvoiceDTO($data);
|
||||
$this->canUpdateBookingSalesInvoice->passes($dto);
|
||||
|
||||
// ProcessSalesInvoiceReportV2CommandJob::dispatch($data);
|
||||
ProcessSalesInvoiceReportV2CommandJob::dispatch($dto->toArray());
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class UpdateBookingSalesInvoiceDTO implements DataTransferObject
|
||||
{
|
||||
private ?string $docNo;
|
||||
private ?string $docDate;
|
||||
private ?string $debtorCode;
|
||||
private ?string $ref;
|
||||
private ?string $shipInfo;
|
||||
private ?string $accNo;
|
||||
private ?string $detailDescription;
|
||||
private ?string $furtherDescription;
|
||||
private ?string $classification;
|
||||
private ?string $deptNo;
|
||||
private float $qty;
|
||||
private float $unitPrice;
|
||||
private bool $submitEinvoice;
|
||||
private bool $consolidatedEinvoice;
|
||||
private ?string $einvoiceValidationLink;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->docNo = $data['docno'];
|
||||
$this->docDate = $data['docdate'];
|
||||
$this->debtorCode = $data['debtorcode'];
|
||||
$this->ref = $data['ref'] ?? null;
|
||||
$this->shipInfo = $data['shipinfo'] ?? null;
|
||||
$this->accNo = $data['accno'] ?? null;
|
||||
$this->detailDescription = $data['detaildescription'] ?? null;
|
||||
$this->furtherDescription = $data['furtherdescription'] ?? null;
|
||||
$this->classification = $data['classification'] ?? null;
|
||||
$this->deptNo = $data['deptno'] ?? null;
|
||||
$this->qty = (float) ($data['qty'] ?? 0);
|
||||
$this->unitPrice = (float) ($data['unitprice'] ?? 0);
|
||||
$this->submitEinvoice = filter_var($data['submiteinvoice'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$this->consolidatedEinvoice = filter_var($data['consolidatedeinvoice'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$this->einvoiceValidationLink = $data['einvoicevalidationlink'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDocNo(): ?string
|
||||
{
|
||||
return $this->docNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDocDate(): ?string
|
||||
{
|
||||
return $this->docDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDebtorCode(): ?string
|
||||
{
|
||||
return $this->debtorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRef(): ?string
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getShipInfo(): ?string
|
||||
{
|
||||
return $this->shipInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAccNo(): ?string
|
||||
{
|
||||
return $this->accNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDetailDescription(): ?string
|
||||
{
|
||||
return $this->detailDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFurtherDescription(): ?string
|
||||
{
|
||||
return $this->furtherDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getClassification(): ?string
|
||||
{
|
||||
return $this->classification;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDeptNo(): ?string
|
||||
{
|
||||
return $this->deptNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getQty(): float
|
||||
{
|
||||
return $this->qty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getUnitPrice(): float
|
||||
{
|
||||
return $this->unitPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getSubmitEinvoice(): bool
|
||||
{
|
||||
return $this->submitEinvoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getConsolidatedEinvoice(): bool
|
||||
{
|
||||
return $this->consolidatedEinvoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEinvoiceValidationLink(): ?string
|
||||
{
|
||||
return $this->einvoiceValidationLink;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'docno' => $this->docNo,
|
||||
'docdate' => $this->docDate,
|
||||
'debtorcode' => $this->debtorCode,
|
||||
'ref' => $this->ref,
|
||||
'shipinfo' => $this->shipInfo,
|
||||
'accno' => $this->accNo,
|
||||
'detaildescription' => $this->detailDescription,
|
||||
'furtherdescription' => $this->furtherDescription,
|
||||
'classification' => $this->classification,
|
||||
'deptno' => $this->deptNo,
|
||||
'qty' => $this->qty,
|
||||
'unitprice' => $this->unitPrice,
|
||||
'submiteinvoice' => $this->submitEinvoice,
|
||||
'consolidatedeinvoice' => $this->consolidatedEinvoice,
|
||||
'einvoicevalidationlink' => $this->einvoiceValidationLink,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Bookings\Standards\Validators\BookingSalesInvoiceValidation;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\UpdateBookingSalesInvoiceDTO;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CanUpdateBookingSalesInvoice extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var BookingSalesInvoiceValidation */
|
||||
private $bookingSalesInvoiceValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateBookingSalesInvoice constructor.
|
||||
* @param UpdateBookingSalesInvoiceDTO $bookingSalesInvoiceValidation
|
||||
*/
|
||||
public function __construct(BookingSalesInvoiceValidation $bookingSalesInvoiceValidation)
|
||||
{
|
||||
$this->bookingSalesInvoiceValidation = $bookingSalesInvoiceValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UpdateBookingSalesInvoiceDTO $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->bookingSalesInvoiceValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UpdateBookingSalesInvoiceDTO $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\UpdateBookingSalesInvoiceDTO;
|
||||
|
||||
class BookingSalesInvoiceValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param UpdateBookingSalesInvoiceDTO $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'docno' => $object->getDocNo(),
|
||||
'docdate' => $object->getDocDate(),
|
||||
'debtorcode' => $object->getDebtorCode(),
|
||||
'ref' => $object->getRef(),
|
||||
'shipinfo' => $object->getShipInfo(),
|
||||
'accno' => $object->getAccNo(),
|
||||
'detaildescription' => $object->getDetailDescription(),
|
||||
'furtherdescription' => $object->getFurtherDescription(),
|
||||
'classification' => $object->getClassification(),
|
||||
'deptno' => $object->getDeptNo(),
|
||||
'qty' => $object->getQty(),
|
||||
'unitprice' => $object->getUnitPrice(),
|
||||
'submiteinvoice' => $object->getSubmitEinvoice(),
|
||||
'consolidatedeinvoice' => $object->getConsolidatedEinvoice(),
|
||||
'einvoicevalidationlink' => $object->getEinvoiceValidationLink(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'docno' => 'required|string',
|
||||
'docdate' => 'required|date',
|
||||
'debtorcode' => 'required|string',
|
||||
'ref' => 'required|string',
|
||||
'shipinfo' => 'required|string',
|
||||
'einvoicevalidationlink' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user