mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'development' into laravel-dusk
This commit is contained in:
@@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
|
||||
class DownloadBookingDocumentLogic
|
||||
{
|
||||
@@ -26,9 +27,9 @@ class DownloadBookingDocumentLogic
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
Auth::login(User::findOrFail(1));
|
||||
$zip_file = $request->input('type').'.zip';
|
||||
$document_type = str_replace(' ', '', $request->input('type'));
|
||||
$zip_file = $document_type.'.zip';
|
||||
$attachment = storage_path().'/app/documents/collections/' . $zip_file;
|
||||
|
||||
$zip = new ZipArchive();
|
||||
@@ -36,19 +37,40 @@ class DownloadBookingDocumentLogic
|
||||
|
||||
$bookings = Booking::where('status', ApprovalStatus::COMPLETED)
|
||||
->whereDate('created_at', '>=', Carbon::parse($request->input('startDate')))
|
||||
->whereDate('created_at', '<=', Carbon::parse($request->input('endDate')))->whereHas('transactions', function ($query) use ($request){
|
||||
->whereDate('created_at', '<=', Carbon::parse($request->input('endDate')))
|
||||
->whereHas('transactions', function ($query) use ($request){
|
||||
return $query->where('type', TransactionType::PAYMENT)->whereHas('transactions', function ($query) use ($request){
|
||||
return $query->where('type', TransactionType::BILL)->where('issuer', $request->input('supplier'));
|
||||
});
|
||||
})->get();
|
||||
|
||||
|
||||
if (!count($bookings)) throw new MalformedRequestException('No available file to download');
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
$file = $booking->documents()->where('document_type', $request->input('type'))->first()->files()->first();
|
||||
$zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
}
|
||||
|
||||
if ($document_type == 'INVOICEPODO' || $document_type == 'INVOICEPODOSDO') {
|
||||
$invoice_file = $booking->documents()->where('document_type', DocumentType::INVOICE)->first()->files()->first();
|
||||
$purchase_file = $booking->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()->files()->first();
|
||||
$deliver_file = $booking->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()->files()->first();
|
||||
if ($document_type == 'INVOICEPODOSDO') {
|
||||
$supplier_deliver_order_file = $booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first();
|
||||
}
|
||||
|
||||
$zip->addFile(Storage::disk('documents')->path($invoice_file->file->file_info->original->file), 'invoice-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
|
||||
$zip->addFile(Storage::disk('documents')->path($purchase_file->file->file_info->original->file), 'purchase-order-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
|
||||
$zip->addFile(Storage::disk('documents')->path($deliver_file->file->file_info->original->file), 'deliver-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
|
||||
$zip->addFile(Storage::disk('documents')->path($supplier_deliver_order_file->file->file_info->original->file), 'supplier-deliver-order-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
}
|
||||
else {
|
||||
$file = $booking->documents()->where('document_type', $document_type)->first()->files()->first();
|
||||
$zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
}
|
||||
|
||||
}
|
||||
$zip->close();
|
||||
while (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
|
||||
@@ -46,9 +46,10 @@ class CreateCompanyProcessor
|
||||
public function execute(Request $request, int $businessType = BusinessType::IMPORTER, ?int $companyType = CompanyType::COMPANY_BUSINESS, ?int $status = ApprovalStatus::PENDING_SUBMISSION): Model {
|
||||
|
||||
$companyName = $companyType === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name');
|
||||
$companyReference = $request->input('company_reference') ? $request->input('company_reference') : mt_rand(1000, 9999).(new GeneratesInitials())->name($companyName)->length(3)->generate();
|
||||
$company_object = new CompanyObject(
|
||||
$companyName,
|
||||
mt_rand(1000, 9999).(new GeneratesInitials())->name($companyName)->length(3)->generate(),
|
||||
$companyReference,
|
||||
$businessType, $companyType, $status);
|
||||
|
||||
$this->canCreateCompany->passes($company_object);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Booking;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateInvoiceTransactionProcessor
|
||||
{
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFile;
|
||||
|
||||
/**
|
||||
* CreateInvoiceTransactionProcessor constructor.
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
*/
|
||||
public function __construct(CreatesDocument $createsDocument, CreatesFiles $createsFile)
|
||||
{
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Booking $booking
|
||||
* @return void
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($transaction, $po_order_transaction, $supplier, $document_type)
|
||||
{
|
||||
$lowercaseDocumentType = strtolower($document_type);
|
||||
|
||||
if ($document_type !== DocumentType::SUPPLIER_DELIVER_ORDER) {
|
||||
|
||||
$order_pdf = LaravelMpdf::loadView('pages.pdfs.' . $lowercaseDocumentType, ['invoice_transaction' => $transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
$document_type,
|
||||
[chunk_split('data:application/pdf;base64,' . base64_encode($order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
$lowercaseDocumentType . 's'
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
$document_type,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
$lowercaseDocumentType . 's'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
}
|
||||
}
|
||||
@@ -55,15 +55,12 @@ class CreateInvoiceTransactionProcessor
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFile;
|
||||
|
||||
/** @var UpdatesBookingStatus */
|
||||
private $updatesBookingStatus;
|
||||
|
||||
/** @var CreateInvoiceDocumentProcessor */
|
||||
private $invoiceDocumentProcessor;
|
||||
|
||||
/**
|
||||
* CreateInvoiceTransactionProcessor constructor.
|
||||
* @param ListsTransactions $listsTransactions
|
||||
@@ -75,11 +72,10 @@ class CreateInvoiceTransactionProcessor
|
||||
* @param FetchesServiceConfigurations $fetchesServiceConfigurations
|
||||
* @param CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
* @param UpdatesBookingStatus $updatesBookingStatus
|
||||
* @param CreateInvoiceDocumentProcessor $invoiceDocumentProcessor
|
||||
*/
|
||||
public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount, FetchesServiceConfigurations $fetchesServiceConfigurations, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesBookingStatus $updatesBookingStatus)
|
||||
public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount, FetchesServiceConfigurations $fetchesServiceConfigurations, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, UpdatesBookingStatus $updatesBookingStatus, CreateInvoiceTransactionProcessor $invoiceDocumentProcessor)
|
||||
{
|
||||
$this->listsTransactions = $listsTransactions;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
@@ -90,9 +86,8 @@ class CreateInvoiceTransactionProcessor
|
||||
$this->fetchesServiceConfigurations = $fetchesServiceConfigurations;
|
||||
$this->calculatesBookingCurrencyAverageRate = $calculatesBookingCurrencyAverageRate;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->updatesBookingStatus = $updatesBookingStatus;
|
||||
$this->invoiceDocumentProcessor = $invoiceDocumentProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +96,7 @@ class CreateInvoiceTransactionProcessor
|
||||
* @return void
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Booking $booking)
|
||||
public function execute(Booking $booking)
|
||||
{
|
||||
|
||||
if ($booking->status === ApprovalStatus::COMPLETED) {
|
||||
@@ -116,7 +111,7 @@ class CreateInvoiceTransactionProcessor
|
||||
return;
|
||||
}
|
||||
// confirm that all payments has been transferred
|
||||
if($this->calculatesBookingTransferredAmount->execute($booking) !== $this->calculatesBookingPaidAmount->execute($booking)){
|
||||
if ($this->calculatesBookingTransferredAmount->execute($booking) !== $this->calculatesBookingPaidAmount->execute($booking)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,7 +122,7 @@ class CreateInvoiceTransactionProcessor
|
||||
|
||||
$constants = SegmentConstant::where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->id', $booking->service->id)->first();
|
||||
|
||||
if($constants->detail->is_billable && !$po_order_transaction) {
|
||||
if ($constants->detail->is_billable && !$po_order_transaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -170,42 +165,14 @@ class CreateInvoiceTransactionProcessor
|
||||
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||
|
||||
$purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.purchase_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::PURCHASE_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'purchase_orders'
|
||||
);
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
// purchase order
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $po_order_transaction, $supplier, DocumentType::PURCHASE_ORDER);
|
||||
|
||||
$deliver_order_pdf = LaravelMpdf::loadView('pages.pdfs.deliver_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::DELIVER_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($deliver_order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'delivery_orders'
|
||||
);
|
||||
// deliver order
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $po_order_transaction, $supplier, DocumentType::DELIVER_ORDER);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
|
||||
|
||||
$invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'invoices'
|
||||
);
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
// invoice
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $po_order_transaction, $supplier, DocumentType::INVOICE);
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('SPDO-');
|
||||
|
||||
@@ -233,16 +200,8 @@ class CreateInvoiceTransactionProcessor
|
||||
);
|
||||
$supplier_deliver_order_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
|
||||
|
||||
$supplier_order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $supplier_deliver_order_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SUPPLIER_DELIVER_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'supplier_delivery_orders'
|
||||
);
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
// supply deliver order
|
||||
$this->invoiceDocumentProcessor->execute($supplier_deliver_order_transaction, $po_order_transaction, $supplier, DocumentType::SUPPLIER_DELIVER_ORDER);
|
||||
|
||||
$this->updatesBookingStatus->execute($booking, ApprovalStatus::COMPLETED);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,14 @@ export default {
|
||||
type: 'INVOICE',
|
||||
supplier: null
|
||||
},
|
||||
documents: ['INVOICE', 'PURCHASE_ORDER', 'DELIVER_ORDER', 'SUPPLIER_DELIVER_ORDER'],
|
||||
documents: [
|
||||
'INVOICE',
|
||||
'PURCHASE_ORDER',
|
||||
'DELIVER_ORDER',
|
||||
'SUPPLIER_DELIVER_ORDER',
|
||||
'INVOICE + PO + DO',
|
||||
'INVOICE + PO + DO + SDO'
|
||||
],
|
||||
selectedDocumentStatus: false
|
||||
}
|
||||
},
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@
|
||||
<div class="btn btn-xs btn-outline-primary btn-block text-left b-rad-none p-t-0 p-b-0 p-l-15 p-r-15" @click="selectedSupplier.status = !selectedSupplier.status">
|
||||
<div class="row">
|
||||
<div class="col p-t-5 p-b-5 fs-9">
|
||||
{{selectedSupplier.name}}
|
||||
{{selectedSupplier.name}} - {{selectedSupplier.reference}}
|
||||
</div>
|
||||
<div class="col-auto b-l b-success">
|
||||
<div class="row h-100 align-items-center">
|
||||
@@ -31,7 +31,7 @@
|
||||
<div class="col b-b b-grey p-t-10 p-b-10 pointer hover-t-10 p-b-10" :class="[{'bg-primary-light': selectedSupplier.id === supplier.id}, {'text-white': selectedSupplier.id === supplier.id}, {'hover-primary': selectedSupplier.id !== supplier.id}, {'pointer': selectedSupplier.id !== supplier.id}]" @click="updateSupplier(supplier)">
|
||||
<div class="row align-items-center justify-content-center">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10">{{supplier.name}}</div>
|
||||
<div class="font-heading fs-10">{{supplier.name}} - {{supplier.reference}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-10">{{item.name}}</div>
|
||||
<div class="font-heading all-caps fs-10">{{item.name}} - {{item.reference}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,14 @@
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.company_reference">
|
||||
<label>Reference</label>
|
||||
<input type="text" class="form-control" v-model="parameters.company_reference">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
@@ -43,6 +51,7 @@
|
||||
return {
|
||||
parameters: {
|
||||
company_name: '',
|
||||
company_reference: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -50,7 +59,10 @@
|
||||
parameters: {
|
||||
company_name: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
company_reference: {
|
||||
required: true
|
||||
},
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
|
||||
Reference in New Issue
Block a user