mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82568269a6 | |||
| 01925913fa | |||
| 1e7060c111 | |||
| d4bc3c55b6 | |||
| fa82b6f185 | |||
| 5ac234cb34 | |||
| 9f834faa10 |
@@ -2,8 +2,6 @@
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/tests/_output
|
||||
/tests/_support
|
||||
/vendor
|
||||
**/.idea/
|
||||
.env
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
image: php:7.4
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq
|
||||
- apt-get install -y libonig-dev
|
||||
- apt-get install -y libxml2-dev
|
||||
- apt-get install -y libzip-dev
|
||||
- apt-get install -y libgd-dev
|
||||
|
||||
#install php depandancies
|
||||
- docker-php-ext-install mbstring xml zip gd
|
||||
|
||||
# Install composer package manager
|
||||
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||
- chmod +x /usr/local/bin/composer
|
||||
|
||||
#jobs
|
||||
build_job:
|
||||
stage: build
|
||||
script:
|
||||
- composer install
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
test_job:
|
||||
stage: test
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
# - php artisan migrate
|
||||
#- php artisan db:seed
|
||||
- php artisan test
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanFetchUser;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Http\Resources\UserCompanyResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchUserByEmailLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Fetch Users',
|
||||
'message' => 'You have successfully retrieved the user by email'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchUser */
|
||||
private $canFetchUser;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/**
|
||||
* FetchUserByEmailLogic constructor.
|
||||
* @param CanFetchUser $canFetchUser
|
||||
* @param FetchesUser $fetchessUser
|
||||
*/
|
||||
public function __construct(CanFetchUser $canFetchUser, FetchesUser $fetchesUser)
|
||||
{
|
||||
$this->canFetchUser = $canFetchUser;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->canFetchUser->passes();
|
||||
|
||||
$query = $this->fetchesUser->execute(['email' => $request->route('email')]);
|
||||
|
||||
return $this->resourceResponse(new UserCompanyResource($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -94,6 +94,11 @@ class CallbackBillplzLogic
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
if ($transaction->type == 'topUp') {
|
||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
|
||||
$this->multipleInvoicesWithOnePaymentLogic->verifypayment($transaction->id, $transaction->amount);
|
||||
}
|
||||
|
||||
if($billPlz->state === 'due') {
|
||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class CreatesBillplzBill
|
||||
public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) {
|
||||
try{
|
||||
// config('billplz.maybank')
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||
$requestBody = [
|
||||
'collection_id' => config('billplz.collection_id'),
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
@@ -34,7 +34,13 @@ class CreatesBillplzBill
|
||||
'reference_1' => $bankCode ? $bankCode : '',
|
||||
'reference_2_label' => 'Bill Number',
|
||||
'reference_2' => $billNumber
|
||||
]);
|
||||
];
|
||||
|
||||
if (in_array(app()->environment(), ['development', 'staging', 'production'])) {
|
||||
$response = Http::withBasicAuth(config('billplz.api_key') . ':', '')->post(config('billplz.base_url') . '/api/v3/bills', $requestBody);
|
||||
} else {
|
||||
$response = Http::withoutVerifying()->withBasicAuth(config('billplz.api_key') . ':', '')->post(config('billplz.base_url') . '/api/v3/bills', $requestBody);
|
||||
}
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListCompanyModuleInvoicesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Company Module Invoices',
|
||||
'message' => 'You have successfully retrieved a list of Invoices'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsTransactions */
|
||||
private $listsTransactions;
|
||||
|
||||
/**
|
||||
* ListCompanyModuleInvoicesLogic constructor.
|
||||
* @param ListsTransactions $listsTransactions
|
||||
*/
|
||||
public function __construct(ListsTransactions $listsTransactions)
|
||||
{
|
||||
$this->listsTransactions = $listsTransactions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$filterArray = [
|
||||
"per_page" => 10,
|
||||
"order_by" => (object)[
|
||||
"column" => 'id',
|
||||
"DESC" => true,
|
||||
],
|
||||
"status_in" => [2],
|
||||
"receiver" => intval($request->route('company_module_id')),
|
||||
"type" => TransactionType::SHIPPING_INVOICE
|
||||
];
|
||||
|
||||
// $this->canListTransactions->passes();
|
||||
|
||||
$query = $this->listsTransactions->execute($filterArray);
|
||||
|
||||
return $this->collectionResponse(TransactionResource::collection($query));
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleName;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyDebtor;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyNameAndDebtorLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Company Name and Debtor',
|
||||
'message' => 'You have successfully updated the Company'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateCompany */
|
||||
private $canUpdateCompany;
|
||||
|
||||
/** @var UpdatesCompany */
|
||||
private $updatesCompany;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyDebtor */
|
||||
private $updatesCompanyDebtor;
|
||||
|
||||
/** @var UpdatesCompanyModuleName */
|
||||
private $updatesCompanyModuleName;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyDebtor $updatesCompanyDebtor
|
||||
* @param UpdatesCompanyModuleName $updatesCompanyModuleName
|
||||
*/
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany, UpdatesCompanyDebtor $updatesCompanyDebtor, UpdatesCompanyModuleName $updatesCompanyModuleName)
|
||||
{
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyDebtor = $updatesCompanyDebtor;
|
||||
$this->updatesCompanyModuleName = $updatesCompanyModuleName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('type'));
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->updatesCompanyModuleName->execute($query->companyModules()->first(), $object->getName());
|
||||
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
if ($request->input('debtor') || $query->first()->debtor !== null) {
|
||||
$this->updatesCompanyDebtor->execute($query, $request->input('debtor'));
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesCompanyDebtor extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $model
|
||||
* @param CompanyObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, ?string $debtor)
|
||||
{
|
||||
$model->debtor = $debtor;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Company;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ExportsCustomerTotalOrderByYear implements FromCollection, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'CompanyId',
|
||||
'CompanyName',
|
||||
'CompanyReference',
|
||||
'TotalCbm'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->whereHas('containers', function($container){
|
||||
return $container->where('loading_date', '>=', Carbon::parse('01-01-' . $this->request->route('year')))
|
||||
->where('loading_date', '<=', Carbon::parse('31-12-' . $this->request->route('year')));
|
||||
})->get();
|
||||
|
||||
$packingLists = $packingLists->groupBy(function ($packingList){
|
||||
return $packingList->owner->company_module_id;
|
||||
})->sortByDesc(function($companyModule){
|
||||
return $companyModule->sum(function($packingList){
|
||||
return $packingList->packages->sum(function ($package){
|
||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
});
|
||||
});
|
||||
})->take(10);
|
||||
return $packingLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $row
|
||||
* @return array
|
||||
*/
|
||||
public function map($row): array
|
||||
{
|
||||
|
||||
$companyModule = $row[0]->owner->companyModule;
|
||||
$marking = $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
|
||||
$cbm = $row->sum(function($packingList){
|
||||
return $packingList->packages->sum(function ($package){
|
||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
});
|
||||
});
|
||||
|
||||
return [
|
||||
$companyModule->company_id,
|
||||
$companyModule->name,
|
||||
$marking,
|
||||
$cbm
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Customer Marking',
|
||||
'Order Number'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Order::whereHas('addresses', function($address) {
|
||||
$address->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('packingLists', function($packingLists) {
|
||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($order): array
|
||||
{
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
|
||||
return [
|
||||
$marking,
|
||||
$order->reference,
|
||||
];
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ use Illuminate\Http\Request;
|
||||
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
@@ -23,7 +23,7 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateSupplierTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use App\Models\Transaction;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Standards\Rules\CanCreateTransaction;
|
||||
use App\Classes\Modules\Transactions\Standards\Rules\CanCreateTransactionDetail;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Http\Resources\TransactionDetailResource;
|
||||
|
||||
use App\Classes\Modules\Receipts\Standards\Rules\CanCreateReceipt;
|
||||
use App\Classes\Modules\Receipts\Standards\Rules\CanCreateReceiptDetail;
|
||||
use App\Classes\Modules\Receipts\DataTransferObjects\ReceiptObject;
|
||||
use App\Classes\Modules\Receipts\DataTransferObjects\ReceiptDetailObject;
|
||||
use App\Classes\Modules\Receipts\Services\CreatesReceipt;
|
||||
use App\Classes\Modules\Receipts\Services\CreatesReceiptDetail;
|
||||
use App\Classes\Modules\Receipts\Services\GeneratesReceiptBillNo;
|
||||
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\Modules\Currencies\Services\RateCalculatesCurrency;
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransactionDetail;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
|
||||
use App\Models\Transaction;
|
||||
use App\Models\multipleInvoicesWithOnePayment;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use APP\models\PackingList;
|
||||
|
||||
|
||||
|
||||
class multipleInvoicesWithOnePaymentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Transaction',
|
||||
'message' => 'You have successfully created a transaction'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNo;
|
||||
|
||||
/** @var CanCreateTransaction */
|
||||
private $canCreateTransaction;
|
||||
|
||||
private $fetchesCurrency;
|
||||
|
||||
private $rateCalculatesCurrency;
|
||||
|
||||
private $fetchesCompany;
|
||||
|
||||
private $createsTransaction;
|
||||
|
||||
private $canCreateTransactionDetail;
|
||||
|
||||
private $createsTransactionDetail;
|
||||
|
||||
private $fetchesTransaction;
|
||||
|
||||
private $fetchesTransactionDetail;
|
||||
|
||||
private $generatesReceiptBillNo;
|
||||
|
||||
/** @var CanCreateReceipt */
|
||||
private $canCreateReceipt;
|
||||
|
||||
private $createsReceipt;
|
||||
|
||||
private $canCreateReceiptDetail;
|
||||
|
||||
private $createsReceiptDetail;
|
||||
|
||||
|
||||
public function __construct(
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNo, CanCreateTransaction $canCreateTransaction,
|
||||
FetchesCurrency $fetchesCurrency, RateCalculatesCurrency $rateCalculatesCurrency, FetchesCompany $fetchesCompany,
|
||||
CreatesTransaction $createsTransaction,
|
||||
CanCreateTransactionDetail $canCreateTransactionDetail, CreatesTransactionDetail $createsTransactionDetail,
|
||||
FetchesTransaction $fetchesTransaction , FetchesTransactionDetail $fetchesTransactionDetail,
|
||||
GeneratesReceiptBillNo $generatesReceiptBillNo, CanCreateReceipt $canCreateReceipt,
|
||||
CreatesReceipt $createsReceipt,
|
||||
CanCreateReceiptDetail $canCreateReceiptDetail, CreatesReceiptDetail $createsReceiptDetail
|
||||
){
|
||||
$this->generatesTransactionBillNo = $generatesTransactionBillNo;
|
||||
$this->canCreateTransaction = $canCreateTransaction;
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
$this->rateCalculatesCurrency = $rateCalculatesCurrency;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsTransaction =$createsTransaction;
|
||||
$this->canCreateTransactionDetail =$canCreateTransactionDetail;
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->fetchesTransactionDetail = $fetchesTransactionDetail;
|
||||
|
||||
$this->generatesReceiptBillNo = $generatesReceiptBillNo;
|
||||
$this->canCreateReceipt = $canCreateReceipt;
|
||||
$this->createsReceipt =$createsReceipt;
|
||||
$this->canCreateReceiptDetail =$canCreateReceiptDetail;
|
||||
$this->createsReceiptDetail = $createsReceiptDetail;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
|
||||
|
||||
public function logic( $transactionsArray) : JsonResponse
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$transactions = Transaction::whereIn('id', json_decode($transactionsArray))->where('type', TransactionType::SHIPPING_INVOICE)->get();
|
||||
$total = $transactions->sum('amount');
|
||||
$packingList =$transactions[1]->owner;
|
||||
$order = $packingList->owner;
|
||||
$companyModule = $order->companyModule;
|
||||
$company = $companyModule->company;
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($company->id, 1, (App()->make(GeneratesWalletCode::class))->execute());
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = (App()->make(CreatesWallet::class))->execute($object, $company);
|
||||
}
|
||||
|
||||
$billNumber = (App()->make(GeneratesTransactionBillNumber::class))->execute('TOPUP-');
|
||||
|
||||
if($total < 0) {
|
||||
throw new MalformedRequestException('Top up credit value must be greater than zero.');
|
||||
}
|
||||
$billPlzBill = (App()->make(CreatesBillplzBill::class))->execute($company->name, 'example@gmail.com', 'This payment is credit topup for company ref. ' . $company->reference, $total, $billNumber, 'bank code', true);
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $total, $total, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], 'test');
|
||||
|
||||
|
||||
$transaction = (App()->make(CreatesTransaction::class))->execute($wallet, $transaction_object);
|
||||
$result= (App()->make(UpdatesWalletBalance::class))->execute($wallet, $total);
|
||||
|
||||
foreach ($transactions as $key => $value) {
|
||||
multipleInvoicesWithOnePayment::create([ 'topUp_request_id' => $transaction->id, 'transaction_id' => $value->id ]);
|
||||
|
||||
}
|
||||
|
||||
// payment gateway api call
|
||||
|
||||
return $this->response([]); ;
|
||||
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
public function verifypayment( $topUp_transaction_id, $amount) : JsonResponse
|
||||
{
|
||||
$totalamount =0;
|
||||
$topup = multipleInvoicesWithOnePayment::where('topUp_request_id',$topUp_transaction_id)->get();
|
||||
|
||||
foreach ($topup as $key => $value) {
|
||||
$transaction = Transaction::where('id',$value->transaction_id)->frist();
|
||||
$totalamount += $transaction->amount;
|
||||
(App()->make(updatesTransactionStatus::class))->execute($transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$transaction_object = new TransactionObject($transaction->bill_no, TransactionType::PAYMENT, 1, $topUp_transaction_id, 1, PaymentMethodType::PAYMENT_GATEWAY, $transaction->amount, $transaction->amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], 'test');
|
||||
$transaction = (App()->make(CreatesTransaction::class))->execute($transaction, $transaction_object);
|
||||
|
||||
}
|
||||
$amount = $amount - $totalamount;
|
||||
Transaction::where('id', $topUp_transaction_id)->update(['amount'=> $amount]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Document;
|
||||
use App\Models\SegmentConstant;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateInvoiceTransactionProcessor
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreatesTransaction extends AbstractUpdateRelationshipRecord
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $packing_list, TransactionObject $object) {
|
||||
public function execute( $packing_list, TransactionObject $object) {
|
||||
$model = new Transaction();
|
||||
$model->bill_no = $object->getBillNo();
|
||||
$model->type = $object->getTransactionType();
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateCompanyWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Company Wallet',
|
||||
'message' => 'You have successfully created a company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canCreateCompanyWallet;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->canCreateCompanyWallet = $canCreateCompanyWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new WalletObject($request->input('company_id'), $request->input('currency_id'), $this->generatesWalletCode->execute());
|
||||
|
||||
$this->canCreateCompanyWallet->passes($object);
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$wallet = $this->createsWallet->execute($object, $company);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateWalletTransaction;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWalletTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletTransactionBillNo;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\Modules\Currencies\Services\RateCalculatesCurrency;
|
||||
/*
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanCreateUser;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUser;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use App\Http\Resources\UserResource;
|
||||
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompany;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompanyEmployee;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyEmployee;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyEmployeeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentCompanies\Standards\Rules\CanCreateSegmentCompany;
|
||||
use App\Classes\Modules\SegmentCompanies\Services\CreatesSegmentCompany;
|
||||
use App\Classes\Modules\SegmentCompanies\DataTransferObjects\SegmentCompanyObject;
|
||||
*/
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateWalletTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Wallet Transaction',
|
||||
'message' => 'You have successfully created a wallet transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesWalletTransaction */
|
||||
private $createsWalletTransaction;
|
||||
|
||||
/** @var GeneratesWalletTransactionBillNo */
|
||||
private $generatesWalletTransactionBillNo;
|
||||
|
||||
/** @var CanCreateWalletTransaction */
|
||||
private $canCreateWalletTransaction;
|
||||
|
||||
private $fetchesCurrency;
|
||||
|
||||
private $rateCalculatesCurrency;
|
||||
|
||||
private $fetchesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWalletTransaction $createsWalletTransaction
|
||||
* @param GeneratesWalletTransactionBillNo $generatesWalletTransactionBillNo
|
||||
* @param CanCreateWalletTransaction $canCreateWalletTransaction
|
||||
* @param FetchesCurrency $fetchesCurrency
|
||||
* @param RateCalculatesCurrency $rateCalculatesCurrency
|
||||
* @param FetchesWallet $fetchesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
CreatesWalletTransaction $createsWalletTransaction, GeneratesWalletTransactionBillNo $generatesWalletTransactionBillNo, CanCreateWalletTransaction $canCreateWalletTransaction,
|
||||
FetchesCurrency $fetchesCurrency,RateCalculatesCurrency $rateCalculatesCurrency, FetchesWallet $fetchesWallet
|
||||
)
|
||||
{
|
||||
$this->createsWalletTransaction = $createsWalletTransaction;
|
||||
$this->generatesWalletTransactionBillNo = $generatesWalletTransactionBillNo;
|
||||
$this->canCreateWalletTransaction = $canCreateWalletTransaction;
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
$this->rateCalculatesCurrency = $rateCalculatesCurrency;
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$wallet = $this->fetchesWallet->execute(['id' => $request->route('id')]);
|
||||
$conversion_currency = $this->fetchesCurrency->execute(['id' => $request->input('currency_id')]);
|
||||
$convertable_currency = $this->fetchesCurrency->execute(['id' => $wallet->currency_id]);//MYR
|
||||
|
||||
$convert_amount = $this->rateCalculatesCurrency->execute($conversion_currency, $convertable_currency, $request->input('amount'));
|
||||
$convert_rate = $this->rateCalculatesCurrency->execute_rate($conversion_currency, $convertable_currency);
|
||||
|
||||
|
||||
$object = new WalletTransactionObject(
|
||||
$wallet->id, $this->generatesWalletTransactionBillNo->execute(),$request->input('trans_type'),
|
||||
number_format( (float) $convert_amount, 5, '.', ''), $wallet->currency_id , number_format( (float) $request->input('amount'), 5, '.', ''),
|
||||
$request->input('currency_id'),number_format( (float) $convert_rate, 5, '.', '')
|
||||
);
|
||||
|
||||
$this->canCreateWalletTransaction->passes($object);
|
||||
|
||||
$wallet_transaction = $this->createsWalletTransaction->execute($object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new WalletTransactionResource($wallet_transaction));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
|
||||
class CreditWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Credit into Company Wallet',
|
||||
'message' => 'You have successfully credit company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/** @var CreditWalletProcessor */
|
||||
private $creditWalletProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
* @param CreditWalletProcessor $creditWalletProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
GeneratesWalletCode $generatesWalletCode,
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet,
|
||||
CreditWalletProcessor $creditWalletProcessor
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
$this->creditWalletProcessor = $creditWalletProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$reference = $request->input('reference');
|
||||
|
||||
$type = $request->input('transaction_type');
|
||||
|
||||
$wallet = $this->creditWalletProcessor->execute($company, $type, $amount, $reference);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\WalletResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DebitWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Debit into Company Wallet',
|
||||
'message' => 'You have successfully debit company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
$reference = $request->input('reference');
|
||||
|
||||
if (!$company->wallets()->first()) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
$wallet = $this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('DEBIT-NOTE-');
|
||||
|
||||
$transaction_object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::DEBIT_NOTE,
|
||||
1,
|
||||
$wallet->company->id,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$amount,
|
||||
$amount,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::APPROVED,
|
||||
[],
|
||||
$reference
|
||||
);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
$updateWalletAmount = $wallet->amount - $transaction->amount;
|
||||
|
||||
$walletOject = new WalletObject($wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
||||
|
||||
$wallet = $this->updatesWallet->execute($wallet, $walletOject);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ListWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'List Company Wallet',
|
||||
'message' => 'You have successfully list company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListWallet */
|
||||
private $listsWallet;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canListWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CanListWallet $canListWallet, ListsWallet $listsWallet)
|
||||
{
|
||||
$this->canListWallet = $canListWallet;
|
||||
$this->listsWallet = $listsWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
//$this->canListWallet->passes();
|
||||
|
||||
$query = $this->listsWallet->execute($this->listsWallet->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(WalletResource::collection($query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWalletTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TopUpWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'TopUp into Company Wallet',
|
||||
'message' => 'You have successfully created a topup request for company\'s wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
|
||||
/**
|
||||
* TopUpWalletLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesBillplzBill $createsBillplzBill
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, GeneratesWalletCode $generatesWalletCode, CreatesWallet $createsWallet, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesBillplzBill $createsBillplzBill, CreatesTransaction $createsTransaction)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
$user = $company->employees()->first();
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('TOPUP-');
|
||||
|
||||
if($amount < 0) {
|
||||
throw new MalformedRequestException('Top up credit value must be greater than zero.');
|
||||
}
|
||||
|
||||
$billPlzBill = $this->createsBillplzBill->execute($company->name, $user->email, 'This payment is credit topup for company ref. ' . $company->reference, $amount, $billNumber, $request->input('bank_code'), true);
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
return $this->resourceResponse(new WalletTransactionResource($transaction));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Transactions\Processors\UpdateWalletTransactionProcessor;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateStatusWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Status Transaction Company Wallet',
|
||||
'message' => 'You have successfully status transaction company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListWallet */
|
||||
private $fetchesWallet;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canListWallet;
|
||||
|
||||
/** @var UpdateWalletTransactionProcessor */
|
||||
private $updateWalletTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(FetchesWallet $fetchesWallet, UpdateWalletTransactionProcessor $updateWalletTransactionProcessor)
|
||||
{
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
$this->updateWalletTransactionProcessor = $updateWalletTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$status = ($request->route('status')=='approve') ? 2 : 4;
|
||||
|
||||
$wallet = $this->updateWalletTransactionProcessor->execute($request->route('transaction_id'), $status);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanWithdrawWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateWalletTransactionProcessor;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WithdrawWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Withdraw from Company Wallet',
|
||||
'message' => 'You have successfully withdraw company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesWallet */
|
||||
private $fetchesWallet;
|
||||
|
||||
/** @var CanWithdrawWallet */
|
||||
private $canWithdrawWallet;
|
||||
|
||||
/** @var CreateWalletTransactionProcessor */
|
||||
private $createWalletTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CanWithdrawWallet $canWithdrawWallet, FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor)
|
||||
{
|
||||
$this->canWithdrawWallet = $canWithdrawWallet;
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
$this->createWalletTransactionProcessor = $createWalletTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]);
|
||||
|
||||
$walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount'));
|
||||
|
||||
$this->canWithdrawWallet->passes($walletOject);
|
||||
|
||||
$transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::WITHDRAW);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class WalletObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $company_id;
|
||||
|
||||
/** @var int */
|
||||
private $currency_id;
|
||||
|
||||
/** @var int */
|
||||
private $code;
|
||||
|
||||
private $amount;
|
||||
|
||||
/**
|
||||
* WalletObject constructor.
|
||||
* @param int $company_id
|
||||
* @param int $currency
|
||||
* @param int $code
|
||||
*/
|
||||
public function __construct(int $company_id, int $currency, int $code, float $amount=0)
|
||||
{
|
||||
$this->company_id = $company_id;
|
||||
$this->currency_id = $currency;
|
||||
$this->code = $code;
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCompanyId(): int
|
||||
{
|
||||
return $this->company_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrency(): int
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCode(): int
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class WalletTransactionObject implements DataTransferObject
|
||||
{
|
||||
|
||||
private $wallet_id;
|
||||
|
||||
private $bill_no;
|
||||
|
||||
private $trans_type;
|
||||
|
||||
private $amount;
|
||||
|
||||
private $currency_id;
|
||||
|
||||
private $original_amount;
|
||||
|
||||
private $original_currency_id;
|
||||
|
||||
private $currency_rate;
|
||||
|
||||
public function __construct(
|
||||
int $wallet_id, int $bill_no,int $trans_type,
|
||||
float $amount, int $currency_id, int $original_amount,
|
||||
int $original_currency_id, float $currency_rate
|
||||
){
|
||||
$this->wallet_id = $wallet_id;
|
||||
$this->bill_no = $bill_no;
|
||||
$this->trans_type = $trans_type;
|
||||
$this->amount= $amount;
|
||||
$this->currency_id = $currency_id;
|
||||
$this->original_amount = $original_amount;
|
||||
$this->original_currency_id = $original_currency_id;
|
||||
$this->currency_rate = $currency_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWalletId(): int
|
||||
{
|
||||
return $this->wallet_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBillNo(): int
|
||||
{
|
||||
return $this->bill_no;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTransType(): int
|
||||
{
|
||||
return $this->trans_type;
|
||||
}
|
||||
|
||||
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrency(): int
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
|
||||
public function getOriginalAmount(): float
|
||||
{
|
||||
return $this->original_amount;
|
||||
}
|
||||
|
||||
public function getOriginalCurrency(): int
|
||||
{
|
||||
return $this->original_currency_id;
|
||||
}
|
||||
|
||||
public function getCurrencyRate(): float
|
||||
{
|
||||
return $this->currency_rate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Processors;
|
||||
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
|
||||
class CreditWalletProcessor
|
||||
{
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesWalletCode $generatesWalletCode,
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet
|
||||
)
|
||||
{
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param int $transactionType
|
||||
* @param float $amount
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company, int $transactionType, float $amount, string $reference)
|
||||
{
|
||||
if (!$company->wallets()->first()) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
$this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-');
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount);
|
||||
|
||||
$walletObject = new WalletObject($wallet->owner->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
||||
|
||||
$wallet = $this->updatesWallet->execute($wallet, $walletObject);
|
||||
|
||||
return $wallet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Models\Wallet;
|
||||
|
||||
class ChecksIfWalletCodeExists
|
||||
{
|
||||
|
||||
/** @var wallet */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* ChecksIfWalletCodeExists constructor.
|
||||
* @param Wallet $repository
|
||||
*/
|
||||
public function __construct(wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(int $code): bool {
|
||||
return $this->repository->where('code', $code)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Models\WalletTransaction;
|
||||
|
||||
class ChecksIfWalletTransactionBillNoExists
|
||||
{
|
||||
|
||||
private $repository;
|
||||
|
||||
public function __construct(WalletTransaction $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(int $bill_no): bool {
|
||||
return $this->repository->where('bill_no', $bill_no)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class CreatesWallet extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(WalletObject $object, Company $company) {
|
||||
$model = new Wallet();
|
||||
//$model->company_id = $object->getCompanyId();
|
||||
$model->code = $object->getCode();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
|
||||
return $this->handler($company->wallets(), $model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Models\WalletTransaction;
|
||||
|
||||
class CreatesWalletTransaction extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(WalletTransactionObject $object) {
|
||||
$model = new WalletTransaction();
|
||||
$model->wallet_id = $object->getWalletId();
|
||||
$model->bill_no = $object->getBillNo();
|
||||
$model->trans_type = $object->getTransType();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
$model->original_amount = $object->getOriginalAmount();
|
||||
$model->original_currency_id = $object->getOriginalCurrency();
|
||||
$model->currency_rate = $object->getCurrencyRate();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class FetchesWallet extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Wallet */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesWallet constructor.
|
||||
* @param Wallet $repository
|
||||
*/
|
||||
public function __construct(Wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
class GeneratesWalletCode
|
||||
{
|
||||
|
||||
/** @var ChecksIfWalletCodeExists */
|
||||
private $walletCodeExists;
|
||||
|
||||
/**
|
||||
* GeneratesWalletCode constructor.
|
||||
* @param ChecksIfWalletCodeExists $walletCodeExists
|
||||
*/
|
||||
public function __construct(ChecksIfWalletCodeExists $walletCodeExists)
|
||||
{
|
||||
$this->walletCodeExists = $walletCodeExists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function execute(): int {
|
||||
|
||||
$code = mt_rand(100000001, 999999999);
|
||||
return !$this->walletCodeExists->execute($code) ? $code : self::execute();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
class GeneratesWalletTransactionBillNo
|
||||
{
|
||||
|
||||
|
||||
private $walletTransationBillNoExists;
|
||||
|
||||
|
||||
public function __construct(ChecksIfWalletTransactionBillNoExists $walletTransationBillNoExists)
|
||||
{
|
||||
$this->walletTransationBillNoExists = $walletTransationBillNoExists;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function execute(): int {
|
||||
|
||||
$code = mt_rand(100000001, 999999999);
|
||||
return !$this->walletTransationBillNoExists->execute($code) ? $code : self::execute();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class ListsWallet extends AbstractListRecord
|
||||
{
|
||||
/** @var Booking */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsBookings constructor.
|
||||
* @param Booking $repository
|
||||
*/
|
||||
public function __construct(Wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesWallet extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, WalletObject $object) {
|
||||
$model->amount = $object->getAmount();
|
||||
$model->code = $object->getCode();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Wallet $model
|
||||
* @param $amount
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, $amount) {
|
||||
|
||||
$model->amount = $model->amount + $amount;
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\CompanyWalletValidation;
|
||||
|
||||
class CanCreateCompanyWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var CompanyWalletValidation */
|
||||
private $companyWalletValidation;
|
||||
|
||||
/**
|
||||
* CanCreateCompanyWallet constructor.
|
||||
* @param CompanyWalletValidation $companyWalletValidation
|
||||
*/
|
||||
public function __construct(CompanyWalletValidation $companyWalletValidation)
|
||||
{
|
||||
$this->companyWalletValidation = $companyWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->companyWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\WalletTransactionValidation;
|
||||
|
||||
class CanCreateWalletTransaction extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var WalletTransactionValidation */
|
||||
private $walletTransactionValidation;
|
||||
|
||||
|
||||
public function __construct(WalletTransactionValidation $walletTransactionValidation)
|
||||
{
|
||||
$this->walletTransactionValidation = $walletTransactionValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->walletTransactionValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\ListWalletValidation;
|
||||
|
||||
class CanListWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ListWalletValidation */
|
||||
private $listWalletValidation;
|
||||
|
||||
|
||||
public function __construct(ListWalletValidation $listWalletValidation)
|
||||
{
|
||||
$this->listWalletValidation = $listWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->listWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\TopUpWalletValidation;
|
||||
|
||||
class CanTopUpWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var TopUpWalletValidation */
|
||||
private $topUpWalletValidation;
|
||||
|
||||
|
||||
public function __construct(TopUpWalletValidation $topUpWalletValidation)
|
||||
{
|
||||
$this->topUpWalletValidation = $topUpWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->topUpWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\WithdrawWalletValidation;
|
||||
|
||||
class CanWithdrawWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var WithdrawWalletValidation */
|
||||
private $witdrawWalletValidation;
|
||||
|
||||
|
||||
public function __construct(WithdrawWalletValidation $witdrawWalletValidation)
|
||||
{
|
||||
$this->witdrawWalletValidation = $witdrawWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->witdrawWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
|
||||
class CompanyWalletValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'company_id' => $object->getCompanyId(),
|
||||
'currency_id' => $object->getCurrency(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'company_id' => 'required',
|
||||
'currency_id' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class ListWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class TopUpWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class WalletTransactionValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'wallet_id' => $object->getWalletId(),
|
||||
'currency_id' => $object->getCurrency(),
|
||||
'amount' => $object->getAmount(),
|
||||
'trans_type'=>$object->getTransType()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'wallet_id' => 'required',
|
||||
'currency_id' => 'required',
|
||||
'amount' => 'required',
|
||||
'trans_type'=>'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class WithdrawWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ final class TransactionType {
|
||||
|
||||
// public const PERFORMA = 4;
|
||||
|
||||
// public const TOP_UP = 5;
|
||||
public const TOP_UP = 5;
|
||||
|
||||
// public const REFUND = 6;
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Accounts;
|
||||
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\FetchUserByEmailLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchUserByEmailController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchUserByEmailLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchUserByEmailLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\ListCompanyModuleInvoicesLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListCompanyModuleInvoicesController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListCompanyModulesLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListCompanyModuleInvoicesLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyNameAndDebtorLogic;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyNameAndDebtorController extends Controller
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateCompanyNameAndDebtorLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Exports;
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsArrivedParcel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsParcel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsWarehousePackingList;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -35,11 +34,4 @@ class ExportArrivedParcelController
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function guangZhou2ToJohor(Request $request) {
|
||||
$exportsWarehousePackingList = new ExportsWarehousePackingList();
|
||||
$response = $exportsWarehousePackingList->download('guangzhou2-to-johor-summary.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Exports;
|
||||
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsCustomersOrderLatestDate;
|
||||
use App\Classes\Modules\Exports\Services\ExportsCustomerTotalOrderByYear;
|
||||
use App\Classes\Modules\Exports\Services\ExportsPaymentTransactions;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -32,11 +31,4 @@ class ExportCustomersToExcelController
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function totalOrders(Request $request){
|
||||
$exportsTotalOrders = new ExportsCustomerTotalOrderByYear($request);
|
||||
$response = $exportsTotalOrders->download('total-orders-' . $request->route('year') . '.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class DownloadOrderQrPdfController
|
||||
{
|
||||
@@ -51,12 +51,9 @@ class DownloadOrderQrPdfController
|
||||
if(strtolower($deliveryAddress->state->name) === 'sarawak' && !in_array(strtolower($deliveryAddress->district->name), ['limbang', 'lawas'])) {
|
||||
$warehousePrefix = 'KU/';
|
||||
}
|
||||
|
||||
if(strtolower($deliveryAddress->state->name) === 'johor') {
|
||||
$warehousePrefix = 'NX/';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'order' => $order,
|
||||
'marking' => $warehousePrefix.$deliveryPrefix.'CIEF/'.$customerMarking,
|
||||
|
||||
@@ -6,7 +6,7 @@ use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\multipleInvoicesWithOnePaymentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Transaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
|
||||
use APP\models\PackingList;
|
||||
use App\Models\multipleInvoicesWithOnePayment;
|
||||
use DB;
|
||||
|
||||
|
||||
class MultipleInvoiceOnePaymentController extends Controller
|
||||
{
|
||||
|
||||
public function getallivoiceid1($transactionsArray, multipleInvoicesWithOnePaymentLogic $logic): JsonResponse {
|
||||
|
||||
return $logic->logic($transactionsArray);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreateWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateWalletController
|
||||
{
|
||||
|
||||
public function create(Request $request, CreateWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreateWalletTransactionLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateWalletTransactionController
|
||||
{
|
||||
|
||||
public function create(Request $request, CreateWalletTransactionLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreditWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreditWalletController
|
||||
{
|
||||
|
||||
public function credit(Request $request, CreditWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\DebitWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DebitWalletController
|
||||
{
|
||||
|
||||
public function debit(Request $request, DebitWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\ListWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListWalletController
|
||||
{
|
||||
public function list(Request $request, ListWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\TopUpWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TopUpWalletController
|
||||
{
|
||||
|
||||
public function topUp(Request $request, TopUpWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\UpdateStatusWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateStatusWalletController
|
||||
{
|
||||
public function updateStatus(Request $request, UpdateStatusWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WalletReportController
|
||||
{
|
||||
public function walletsReport(Request $request): JsonResponse
|
||||
{
|
||||
return (new ApiResponseObject(
|
||||
'fetch service report Successful',
|
||||
'',
|
||||
HttpStatus::OK_WITH_MESSAGE,
|
||||
['data' => [
|
||||
'walletSum' => (float) Wallet::all()->sum('amount'),
|
||||
'outgoingSum' => (float) Transaction::where('type', TransactionType::PAYMENT)->where('owner_type', Wallet::class)->sum('amount'),
|
||||
'incomingSum' => (float) Transaction::whereIn('type', [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE])->where('owner_type', Wallet::class)->sum('amount'),
|
||||
]]
|
||||
))->handler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\WithdrawWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WithdrawWalletController
|
||||
{
|
||||
|
||||
public function withdraw(Request $request, WithdrawWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ class CompanyResource extends JsonResource
|
||||
'id' => $this->id,
|
||||
'hash_id' => Crypt::encryptString($this->id),
|
||||
'name' => $this->name,
|
||||
'debtor' => $this->debtor,
|
||||
'reference' => $this->reference,
|
||||
'type' => (int) $this->type,
|
||||
'business_type' => (int) $this->business_type,
|
||||
|
||||
@@ -29,7 +29,6 @@ class PackageResource extends JsonResource
|
||||
'weight' => $this->weight,
|
||||
'quantity' => $this->quantity,
|
||||
'cbm' => (($this->width / 100) * ($this->height / 100) * ($this->length / 100)) * $this->quantity,
|
||||
'reference' => $this->packingList->reference,
|
||||
'status' => $this->status,
|
||||
$this->mergeWhen($originalPackingList->owner instanceof Order, [
|
||||
'order' => New OrderResource($originalPackingList->owner)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserCompanyResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'reference' => $this->companyModule()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference,
|
||||
'type' => (int) $this->type,
|
||||
'status' => (int) $this->status,
|
||||
'email' => $this->email
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -102,4 +102,9 @@ class Company extends AbstractModel implements Documentable, Contactable
|
||||
return $this->hasManyDeep(Package::class, [CompanyModule::class, Order::class, PackingList::class], ['company_id', 'company_module_id', ['owner_type', 'owner_id'], 'packing_list_id'], ['id', 'id', null, 'id']);
|
||||
}
|
||||
|
||||
public function wallets(): morphMany
|
||||
{
|
||||
return $this->morphMany(Wallet::class, 'owner');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class Wallet extends AbstractModel implements Transactionable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'wallets';
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
public function owner(): morphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return morphMany
|
||||
*/
|
||||
public function transactions(): morphMany
|
||||
{
|
||||
return $this->morphMany(Transaction::class, 'owner');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
|
||||
class WalletTransaction extends AbstractModel
|
||||
{
|
||||
protected $table = 'wallet_transaction';
|
||||
|
||||
public function wallet(): HasOne
|
||||
{
|
||||
return $this->hasOne(Wallet::class, 'wallet_id', 'id');
|
||||
}
|
||||
|
||||
public function transaction(): HasOne
|
||||
{
|
||||
return $this->hasOne(Transaction::class, 'transaction_id', 'id');
|
||||
}
|
||||
|
||||
public function currency(): HasOne
|
||||
{
|
||||
return $this->hasOne(Currency::class, 'currency_id', 'id');
|
||||
}
|
||||
|
||||
public function original_currency(): HasOne
|
||||
{
|
||||
return $this->hasOne(Currency::class, 'original_currency_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class multipleInvoicesWithOnePayment extends AbstractModel
|
||||
{
|
||||
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'multiple_invoice_one_payments';
|
||||
|
||||
protected $fillable =[
|
||||
'topUp_request_id',
|
||||
'transaction_id'
|
||||
];
|
||||
}
|
||||
+2
-2
@@ -178,7 +178,7 @@ return [
|
||||
// Third Parties
|
||||
Spatie\Permission\PermissionServiceProvider::class,
|
||||
Barryvdh\DomPDF\ServiceProvider::class,
|
||||
Mccarlosen\LaravelMpdf\LaravelMpdfServiceProvider::class,
|
||||
Meneses\LaravelMpdf\LaravelMpdfServiceProvider::class,
|
||||
Maatwebsite\Excel\ExcelServiceProvider::class,
|
||||
],
|
||||
|
||||
@@ -233,7 +233,7 @@ return [
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
'PDF' => Barryvdh\DomPDF\Facade::class,
|
||||
'MPDF' => Mccarlosen\LaravelMpdf\Facades\LaravelMpdf::class,
|
||||
'MPDF' => Meneses\LaravelMpdf\Facades\LaravelMpdf::class,
|
||||
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
||||
],
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCompaniesWalletTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('wallets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('company_id')->unsigned();
|
||||
$table->string('code');
|
||||
$table->foreignId('currency_id')->unsigned();
|
||||
$table->decimal('amount', 20, 5)->default(0.00);
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('company_id')->references('id')->on('companies');
|
||||
$table->foreign('currency_id')->references('id')->on('currencies');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('wallets');
|
||||
}
|
||||
}
|
||||
@@ -13,14 +13,7 @@
|
||||
<div class="col-auto">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="changeCustomerName">
|
||||
<change-customer-name-form-component :section="'customerProfileSection'" :data="item"></change-customer-name-form-component>
|
||||
</modal-component>
|
||||
<div class="font-heading fs-20 light">{{item.name}}
|
||||
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary" data-type="changeCustomerName" >
|
||||
<i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="font-heading fs-20 light">{{item.name}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -39,12 +32,6 @@
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="row align-items-center parentContainer">
|
||||
<div class="col-auto padding-5 b-a b-grey b-rad-lg pointer m-r-15" @click="hrefPaymenBillingPage">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="35" height="35"
|
||||
viewBox="0 0 172 172"
|
||||
style=" fill:#000000;"><defs><linearGradient x1="69.875" y1="96.52694" x2="69.875" y2="108.37075" gradientUnits="userSpaceOnUse" id="color-1_44039_gr1"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="86" y1="21.05119" x2="86" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-2_44039_gr2"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="80.625" y1="21.05119" x2="80.625" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-3_44039_gr3"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="75.25" y1="21.05119" x2="75.25" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-4_44039_gr4"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="69.875" y1="21.05119" x2="69.875" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-5_44039_gr5"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="129" y1="21.05119" x2="129" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-6_44039_gr6"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="139.75" y1="21.05119" x2="139.75" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-7_44039_gr7"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="118.25" y1="21.05119" x2="118.25" y2="153.19019" gradientUnits="userSpaceOnUse" id="color-8_44039_gr8"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M86,104.8125c0,1.4835 -1.204,2.6875 -2.6875,2.6875h-26.875c-1.4835,0 -2.6875,-1.204 -2.6875,-2.6875v-5.375c0,-1.4835 1.204,-2.6875 2.6875,-2.6875h26.875c1.4835,0 2.6875,1.204 2.6875,2.6875z" fill="url(#color-1_44039_gr1)"></path><path d="M154.0045,83.57856c-1.58025,-1.87856 -3.913,-2.95356 -6.407,-2.95356h-5.16v-8.0625c0,-4.44513 -4.03125,-8.0625 -8.0625,-8.0625v-26.875c0,-2.96431 -2.41069,-5.375 -5.375,-5.375h-38.65162l-3.88881,-7.77762c-0.91375,-1.83288 -2.75469,-2.97237 -4.80794,-2.97237h-18.17825h-1.66088h-18.8125c-2.96431,0 -5.375,2.41069 -5.375,5.375v96.75h-21.5v13.4375c0,7.40944 6.02806,13.4375 13.4375,13.4375h91.375c7.40944,0 13.4375,-6.02806 13.4375,-13.4375v-18.8125h4.74344c6.80475,0 12.55869,-4.71119 13.68475,-11.20419l2.95625,-17.02263c0.39775,-2.29512 -0.23919,-4.644 -1.75494,-6.44463zM137.0625,72.5625v8.0625h-16.125v-8.0625c0,-1.4835 1.20669,-2.6875 2.6875,-2.6875h10.75c1.4835,0 2.6875,1.204 2.6875,2.6875zM129,43h-5.375v-5.375h5.375zM81.65163,26.875l2.6875,5.375h-15.49344l-2.6875,-5.375zM60.15163,26.875l3.88881,7.78031c0.91913,1.83019 2.76275,2.96969 4.81063,2.96969h49.39894v5.375h-75.25v-16.125zM29.5625,145.125c-4.44513,0 -8.0625,-3.61469 -8.0625,-8.0625v-8.0625h86v8.0625c0,3.02344 1.00244,5.375 2.69288,8.0625zM129,137.0625c0,4.44512 -3.61738,8.0625 -8.0625,8.0625c-4.44512,0 -8.0625,-3.61738 -8.0625,-8.0625v-13.4375h-69.875v-75.25h86v16.125h-5.375c-4.44512,0 -8.0625,3.61737 -8.0625,8.0625v8.0625h-5.16c-2.494,0 -4.82675,1.075 -6.407,2.95356c-1.51306,1.80062 -2.15269,4.1495 -1.75225,6.44194l2.95625,17.02531c1.12606,6.493 6.87731,11.20419 13.68475,11.20419h10.11575zM150.46237,89.10138l-2.95625,17.02531c-0.67725,3.91031 -4.20325,6.74831 -8.38769,6.74831h-20.23419c-4.18444,0 -7.71044,-2.838 -8.38769,-6.74831l-2.95625,-17.028c-0.172,-0.99706 0.28219,-1.72 0.57244,-2.064c0.55362,-0.65575 1.38675,-1.03469 2.28975,-1.03469h37.195c0.903,0 1.73613,0.37894 2.29244,1.03738c0.28756,0.344 0.74444,1.06425 0.57244,2.064z" fill="url(#color-2_44039_gr2)"></path><path d="M53.75,59.125h53.75v5.375h-53.75z" fill="url(#color-3_44039_gr3)"></path><path d="M53.75,69.875h43v5.375h-43z" fill="url(#color-4_44039_gr4)"></path><path d="M53.75,80.625h32.25v5.375h-32.25z" fill="url(#color-5_44039_gr5)"></path><path d="M126.3125,91.375h5.375v16.125h-5.375z" fill="url(#color-6_44039_gr6)"></path><path d="M137.0625,91.375h5.375v10.75h-5.375z" fill="url(#color-7_44039_gr7)"></path><path d="M115.5625,91.375h5.375v10.75h-5.375z" fill="url(#color-8_44039_gr8)"></path></g></g></svg>
|
||||
</div>
|
||||
<div class="col-auto padding-5 b-a b-grey b-rad-lg pointer requestModal" data-type="assignSegment">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="30" height="30"
|
||||
@@ -194,10 +181,7 @@
|
||||
delay: 1000
|
||||
});
|
||||
$(this.$refs.copyButton).tooltip('show');
|
||||
},
|
||||
hrefPaymenBillingPage(){
|
||||
window.location.href = route('customer.payment-and-billing', this.item.company_module.marking);
|
||||
},
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<template>
|
||||
<div class="row m-b-15 align-items-end">
|
||||
<div class="col-auto">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10 muted all-caps">Name</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-11">{{this.item.name}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2 text-right">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10 muted all-caps">Reference</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-11">{{this.item.reference}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a :href="route('customer.profile', this.item.reference)" target="_blank">
|
||||
<button type="button" class="btn btn-xs btn-primary fs-11">Open in new tab</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
export default {
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
+104
-91
File diff suppressed because one or more lines are too long
@@ -19,12 +19,6 @@
|
||||
<p class="bold m-b-5 fs-12">{{item.description}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10 align-items-center" v-if="$store.getters.isAdmin">
|
||||
<div class="col-auto">
|
||||
<p class="no-margin all-caps fs-10 lh-10 light">Reference</p>
|
||||
<p class="no-margin fs-12">{{item.reference}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-t b-b b-grey m-b-15">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
@@ -180,4 +174,4 @@
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
@@ -67,14 +67,6 @@
|
||||
<p class="no-margin bold text-info fs-12"><a :href="route('customer.profile', item.order.company_module.marking)">{{item.order.company_module.marking}}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5" v-if="$store.getters.isAdmin">
|
||||
<div class="col-auto p-r-5">
|
||||
<p class="no-margin all-caps fs-10 light">Reference</p>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<p class="no-margin bold text-info fs-12">{{item.reference}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5">
|
||||
<div class="col-auto p-r-5">
|
||||
<p class="no-margin all-caps fs-10 light">Order Number</p>
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
<template>
|
||||
<div class="row" style="width: 450px; margin: auto;" @keyup.enter="submitForm">
|
||||
<div class="col bg-white padding-40 b-rad-lg">
|
||||
<div class="row m-b-10">
|
||||
<div class="col text-center">
|
||||
<h3>Edit Company Details</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component class="m-b-15" :validator="$v.parameters.name">
|
||||
<label class="text-primary">Name</label>
|
||||
<input class="form-control" v-model="parameters.name">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component class="m-b-15" :validator="$v.parameters.debtor">
|
||||
<label class="text-primary">Debtor Code</label>
|
||||
<input class="form-control" v-model="parameters.debtor">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-15">
|
||||
<div class="col-auto p-r-5">
|
||||
<div class="btn btn-lg btn-default b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-primary w-100 btn-lg" @click="submitForm">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required, minLength } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
parameters: {
|
||||
id: this.data.id,
|
||||
name: this.data.name,
|
||||
debtor: this.data.debtor,
|
||||
reference: this.data.reference,
|
||||
type: this.data.type,
|
||||
}
|
||||
};
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
name: {
|
||||
required,
|
||||
minLength: minLength(8)
|
||||
},
|
||||
debtor: {
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
successHandler(response) {
|
||||
window.location.replace(this.route('customers', response.payload.data.reference));
|
||||
},
|
||||
submitForm() {
|
||||
this.submit(this.route('api.company.update.nameAndDebtor', this.data.id), 'put', this.section, true, true)
|
||||
}
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
|
||||
</script>
|
||||
+6
-10
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="row m-b-15 m-l-5 m-r-10">
|
||||
<div class="col bg-white rounded b-a" :class="{'b-white': !selected, 'b-primary': selected, 'bg-primary-lighter': selected}">
|
||||
<div class="col bg-master-lightest rounded" :class="{'b-gray': !selected, 'b-primary': selected, 'bg-primary-lighter': selected}">
|
||||
<div class="row">
|
||||
<div class="col padding-20">
|
||||
<div class="row align-items-center">
|
||||
@@ -8,27 +8,23 @@
|
||||
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps">Invoice No</p>
|
||||
<div>{{ item.bill_no }}</div>
|
||||
<h5 class="no-margin">{{ item.bill_no }}</h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps">Order</p>
|
||||
<div><a :href="route('order.show', item.order.reference)">{{item.order.reference}}</a></div>
|
||||
<h5 class="no-margin">{{ item.created_at }}</h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps">Invoice Date</p>
|
||||
<div>{{ item.created_at }}</div>
|
||||
<h5 class="no-margin">Status</h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps">Amount</p>
|
||||
<div>MYR {{ item.amount.toFixed(2) }}</div>
|
||||
<h5 class="no-margin">MYR {{ item.amount.toFixed(2) }}</h5>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div v-if="item.documents.length">
|
||||
<div v-for="file in item.documents[0].files" v-bind:key="file.id" class="col-auto no-padding">
|
||||
<document-file-viewer-component :file="file">
|
||||
<template slot="button">
|
||||
<div class="btn btn-success no-border muted">
|
||||
<div class="btn bg-grey no-border muted">
|
||||
<i class="fa fa-file-pdf-o"></i>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
<template>
|
||||
<div class="row" @keyup.enter="fetchReport">
|
||||
<div class="col">
|
||||
<div class="row m-b-15">
|
||||
<div class="col-8 p-r-0">
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<div class="form-group no-margin form-group-default b-rad-none">
|
||||
<label class="text-primary">Email</label>
|
||||
<input type="text" class="form-control" v-model="email" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-0">
|
||||
<div class="btn btn-primary b-rad-none" @click="fetchReport()">
|
||||
<i class="fa fa-search lh-40"></i>
|
||||
</div>
|
||||
<div class="btn btn-secondary b-rad-none" @click="resetSearch()">
|
||||
<i class="fa fa-remove lh-40"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="search">
|
||||
<div class="col bg-white padding-25">
|
||||
<p v-if="!userCompany">{{ message }}</p>
|
||||
<loading-component v-if="isLoading"></loading-component>
|
||||
<user-company-component v-if="userCompany" :data="userCompany"></user-company-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
import LoadingComponent from "../../general/elements/LoadingComponent";
|
||||
export default {
|
||||
components: {LoadingComponent},
|
||||
data(){
|
||||
return {
|
||||
section: 'searchUserCompanyByEmailSection',
|
||||
isLoading: false,
|
||||
search: false,
|
||||
email: '',
|
||||
userCompany: null,
|
||||
message: 'Searching...'
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
marking: {},
|
||||
},
|
||||
methods: {
|
||||
fetchReport(){
|
||||
this.isLoading = true;
|
||||
this.search = true;
|
||||
this.userCompany = null;
|
||||
this.message = 'Searching...';
|
||||
this.submit(route('api.account.user.company', this.email), 'get', this.section, false, false);
|
||||
},
|
||||
successHandler(response){
|
||||
this.isLoading = false;
|
||||
this.report = response.payload.data;
|
||||
if(response.payload.data != undefined)
|
||||
this.userCompany = response.payload.data;
|
||||
else
|
||||
this.message = 'Customer not found';
|
||||
},
|
||||
errorHandler(response){
|
||||
this.isLoading = false;
|
||||
this.userCompany = null;
|
||||
this.message = 'Customer not found';
|
||||
},
|
||||
resetSearch() {
|
||||
this.userCompany = null;
|
||||
this.search = false;
|
||||
this.email = '';
|
||||
message: 'Searching...';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -3,7 +3,6 @@
|
||||
<div class="row" :class="[{'d-flex': $store.getters.isAdmin}]" v-if="$store.getters.isAdmin">
|
||||
<div class="col">
|
||||
<customer-activity-report-section-component></customer-activity-report-section-component>
|
||||
<search-customer-by-email-component></search-customer-by-email-component>
|
||||
<div class="row" v-show="!$store.getters.isShowing('customerActivityReportSection')">
|
||||
<div class="col">
|
||||
<customer-report-section-component></customer-report-section-component>
|
||||
|
||||
@@ -5,9 +5,135 @@
|
||||
<br><br>
|
||||
<div class="separator"><strong><i>{{ $invoice_transaction->bill_no }}</i></strong></div>
|
||||
</htmlpageheader>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="header-logo">
|
||||
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
|
||||
</td>
|
||||
<td class="header-cief-address">
|
||||
<span class="company-name">
|
||||
<strong>
|
||||
CIEF WORLDWIDE SDN BHD
|
||||
</strong>
|
||||
</span>
|
||||
<span class="company-reg">(1134596-M)</span><br>
|
||||
No. 72-3, Jalan Jalil 1,<br>
|
||||
The Earth Bukit Jalil,<br>
|
||||
57000 Kuala Lumpur<br>
|
||||
Tel: 03-8082 1252
|
||||
</td>
|
||||
<td class="header-details">
|
||||
<div class="title" style="font-size: 20px; text-transform: uppercase;">
|
||||
<strong>
|
||||
Invoice
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
@include('pages.pdfs.shipping_invoice_inner', ['invoice_transaction' => $invoice_transaction])
|
||||
<div class="number">Invoice No: {{ $invoice_transaction->bill_no }}</div>
|
||||
|
||||
@php
|
||||
$companyModule = $invoice_transaction->owner->owner->companyModule;
|
||||
@endphp
|
||||
|
||||
<div class="date">Date: {{ $invoice_transaction->created_at }}</div>
|
||||
<div class="ref">Order No: {{ $invoice_transaction->owner->owner->reference }}</div>
|
||||
<div class="ref">Container Ref: {{ $invoice_transaction->owner->containers()->first()->reference }}</div>
|
||||
{{--<div class="d-none">{{ $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference }}</div>--}}
|
||||
<div> </div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="bill-to">
|
||||
<span class="sub-title">
|
||||
Bill To
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="address">
|
||||
<div class="label">
|
||||
{{ $companyModule->name }}
|
||||
</div>
|
||||
<div class="address">
|
||||
@php
|
||||
$addresses = $companyModule->addresses()->where('status', '=', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->where('type', '=', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
@endphp
|
||||
{{ $addresses->street_one }}
|
||||
{{ $addresses->street_two }} ,
|
||||
{{ $addresses->district()->first()->name }},
|
||||
{{ $addresses->postcode }}
|
||||
{{ $addresses->state()->first()->name }},
|
||||
{{ $addresses->country()->first()->name }}
|
||||
</div>
|
||||
<div>
|
||||
@php
|
||||
$contact = $companyModule->contacts()->first();
|
||||
@endphp
|
||||
Phone: {{ $contact ? $contact->phone : '' }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="15%">Quantity</th>
|
||||
<th width="20%">Unit Price (RM)</th>
|
||||
<th width="20%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($invoice_transaction->transactionDetails as $key => $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td class="description">{!! $transaction_detail->name !!}</td>
|
||||
<td width="15%" class="center top" style="text-align: center">{{ round($transaction_detail->quantity, 3) }}</td>
|
||||
<td width="20%" class="center top" style="text-align: center">
|
||||
{{ round($transaction_detail->price, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ round($transaction_detail->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="subtotal">
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">
|
||||
{{ round($invoice_transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="3"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">
|
||||
{{ round($invoice_transaction->service_charge, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@if($invoice_transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="3"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($invoice_transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ round($invoice_transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td class="header-logo">
|
||||
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
|
||||
</td>
|
||||
<td class="header-cief-address">
|
||||
<span class="company-name">
|
||||
<strong>
|
||||
CIEF WORLDWIDE SDN BHD
|
||||
</strong>
|
||||
</span>
|
||||
<span class="company-reg">(1134596-M)</span><br>
|
||||
No. 72-3, Jalan Jalil 1,<br>
|
||||
The Earth Bukit Jalil,<br>
|
||||
57000 Kuala Lumpur<br>
|
||||
Tel: 03-8082 1252
|
||||
</td>
|
||||
<td class="header-details">
|
||||
<div class="title" style="font-size: 20px; text-transform: uppercase;">
|
||||
<strong>
|
||||
Invoice
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="number">Invoice No: {{ $invoice_transaction->bill_no }}</div>
|
||||
|
||||
@php
|
||||
$companyModule = $invoice_transaction->owner->owner->companyModule;
|
||||
@endphp
|
||||
|
||||
<div class="date">Date: {{ $invoice_transaction->created_at }}</div>
|
||||
<div class="ref">Order No: {{ $invoice_transaction->owner->owner->reference }}</div>
|
||||
<div class="ref">Container Ref: {{ $invoice_transaction->owner->containers()->first()->reference }}</div>
|
||||
{{--<div class="d-none">{{ $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference }}</div>--}}
|
||||
<div> </div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="bill-to">
|
||||
<span class="sub-title">
|
||||
Bill To
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="address">
|
||||
<div class="label">
|
||||
{{ $companyModule->name }}
|
||||
</div>
|
||||
<div class="address">
|
||||
@php
|
||||
$addresses = $companyModule->addresses()->where('status', '=', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->where('type', '=', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
@endphp
|
||||
{{ $addresses->street_one }}
|
||||
{{ $addresses->street_two }} ,
|
||||
{{ $addresses->district()->first()->name }},
|
||||
{{ $addresses->postcode }}
|
||||
{{ $addresses->state()->first()->name }},
|
||||
{{ $addresses->country()->first()->name }}
|
||||
</div>
|
||||
<div>
|
||||
@php
|
||||
$contact = $companyModule->contacts()->first();
|
||||
@endphp
|
||||
Phone: {{ $contact ? $contact->phone : '' }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="15%">Quantity</th>
|
||||
<th width="20%">Unit Price (RM)</th>
|
||||
<th width="20%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($invoice_transaction->transactionDetails as $key => $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td class="description">{!! $transaction_detail->name !!}</td>
|
||||
<td width="15%" class="center top" style="text-align: center">{{ round($transaction_detail->quantity, 3) }}</td>
|
||||
<td width="20%" class="center top" style="text-align: center">
|
||||
{{ round($transaction_detail->price, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ round($transaction_detail->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="subtotal">
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">
|
||||
{{ round($invoice_transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="3"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">
|
||||
{{ round($invoice_transaction->service_charge, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@if($invoice_transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="3"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($invoice_transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ round($invoice_transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -1,143 +0,0 @@
|
||||
@extends('layouts.base_pdf')
|
||||
@section('inner_content')
|
||||
@php
|
||||
$grandTotal = 0;
|
||||
$grandSubTotal = 0;
|
||||
@endphp
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td class="header-logo">
|
||||
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
|
||||
</td>
|
||||
<td class="header-cief-address">
|
||||
<span class="company-name">
|
||||
<strong>
|
||||
CIEF WORLDWIDE SDN BHD
|
||||
</strong>
|
||||
</span>
|
||||
<span class="company-reg">(1134596-M)</span><br>
|
||||
No. 72-3, Jalan Jalil 1,<br>
|
||||
The Earth Bukit Jalil,<br>
|
||||
57000 Kuala Lumpur<br>
|
||||
Tel: 03-8082 1252
|
||||
</td>
|
||||
<td class="header-details">
|
||||
<div class="title" style="font-size: 20px; text-transform: uppercase;">
|
||||
<strong>
|
||||
Summary
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
@php
|
||||
$companyModule = $invoice_transactions[0]->owner->owner->companyModule;
|
||||
@endphp
|
||||
|
||||
{{-- <div class="date">Date: {{ $invoice_transactions[0]->created_at }}</div> --}}
|
||||
<div class="date">Date: {{ \Carbon\Carbon::now() }}</div>
|
||||
<div> </div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="bill-to">
|
||||
<span class="sub-title">
|
||||
Bill To
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="address">
|
||||
<div class="label">
|
||||
{{ $companyModule->name }}
|
||||
</div>
|
||||
<div class="address">
|
||||
@php
|
||||
$addresses = $companyModule->addresses()->where('status', '=', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->where('type', '=', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
@endphp
|
||||
{{ $addresses->street_one }}
|
||||
{{ $addresses->street_two }} ,
|
||||
{{ $addresses->district()->first()->name }},
|
||||
{{ $addresses->postcode }}
|
||||
{{ $addresses->state()->first()->name }},
|
||||
{{ $addresses->country()->first()->name }}
|
||||
</div>
|
||||
<div>
|
||||
@php
|
||||
$contact = $companyModule->contacts()->first();
|
||||
@endphp
|
||||
Phone: {{ $contact ? $contact->phone : '' }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="description">Invoice No</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="15%">Quantity</th>
|
||||
<th width="20%">Unit Price (RM)</th>
|
||||
<th width="20%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($invoice_transactions as $key => $invoice_transaction)
|
||||
@foreach ($invoice_transaction->transactionDetails as $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td width="15%" class="center top">{{ $invoice_transaction->bill_no }}</td>
|
||||
<td class="description">{!! $transaction_detail->name !!}</td>
|
||||
<td width="15%" class="center top" style="text-align: center">{{ round($transaction_detail->quantity, 3) }}</td>
|
||||
<td width="15%" class="center top" style="text-align: center">
|
||||
{{ round($transaction_detail->price, 2) }}
|
||||
</td>
|
||||
<td width="15%" class="right top">
|
||||
{{ round($transaction_detail->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@php
|
||||
$grandSubTotal = $grandSubTotal + round($invoice_transaction->amount, 2);
|
||||
$grandTotal = $grandTotal + round($invoice_transaction->amount, 2);
|
||||
@endphp
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="subtotal">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">
|
||||
{{ round($grandSubTotal, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ round($grandTotal, 2) }}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
@foreach ($invoice_transactions as $transaction)
|
||||
<pagebreak />
|
||||
@include('pages.pdfs.shipping_invoice_inner', ['invoice_transaction' => $transaction])
|
||||
@endforeach
|
||||
|
||||
|
||||
<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
|
||||
@@ -35,7 +35,6 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'valid.token', 'prefix' => 'user', 'as' => 'user.'], function () {
|
||||
Route::get('/{email}', 'FetchUserByEmailController@fetch')->name('company');
|
||||
Route::post('/show', 'FetchUserController@fetch')->name('show');
|
||||
Route::get('/list', 'ListUsersController@list')->name('list');
|
||||
Route::put('/update/{id}', 'UpdateUserController@update')->name('update');
|
||||
|
||||
@@ -62,7 +62,11 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
|
||||
require __DIR__ . '/report.php';
|
||||
|
||||
require __DIR__ . '/wallet.php';
|
||||
|
||||
});
|
||||
|
||||
require __DIR__ . '/invoice.php';
|
||||
|
||||
require __DIR__ . '/announcement.php';
|
||||
});
|
||||
|
||||
+2
-1
@@ -8,7 +8,6 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
Route::post('/create', 'CreateCompanyController@create')->name('create');
|
||||
Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update');
|
||||
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
|
||||
Route::put('/name-and-debtor/update/{id}', 'UpdateCompanyNameAndDebtorController@update')->name('update.nameAndDebtor');
|
||||
|
||||
Route::post('/team/create', 'AddNewMemberController@create')->name('team.create');
|
||||
|
||||
@@ -34,4 +33,6 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
});
|
||||
|
||||
Route::get('/module/list', 'ListCompanyModulesController@list')->name('module.list');
|
||||
|
||||
Route::get('/{company_module_id}/invoice/list', 'ListCompanyModuleInvoicesController@list')->name('invoice.list');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Route::get('/group/paymenttransaction/{transactionsArray?}', 'Transactions\MultipleInvoiceOnePaymentController@getallivoiceid')->name('grouppayment');
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['prefix' => 'wallets', 'namespace' => 'Wallets', 'as' => 'wallet.'], function () {
|
||||
Route::get('/', 'ListWalletController@list')->name('list');
|
||||
Route::post('/create', 'CreateWalletController@create')->name('create');
|
||||
|
||||
Route::post('/topup', 'TopUpWalletController@topUp')->name('topup'); // user
|
||||
Route::post('/credit', 'CreditWalletController@credit')->name('credit'); // admin +
|
||||
|
||||
Route::put('/{transaction_id}/update-status/{status}', 'UpdateStatusWalletController@updateStatus')->where('status', 'approve|reject')->name('approval');
|
||||
|
||||
Route::get('/reports', 'WalletReportController@walletsReport')->name('reports');
|
||||
});
|
||||
+1
-48
@@ -7,26 +7,20 @@ use App\Classes\Jobs\FetchLoadedContainersFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchOrdersFromYDPortalJob;
|
||||
use App\Classes\Jobs\FetchPackingListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListFromVTPortalProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use App\Models\Container;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -39,7 +33,7 @@ use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__ . '/template.php';
|
||||
require __DIR__ . '/template.php';
|
||||
|
||||
Route::domain('hywave.izyim.com')->group(function () {
|
||||
Route::group(['as' => 'last_mile_delivery.'], function () {
|
||||
@@ -324,8 +318,6 @@ Route::get('/export/on-hold-packing-list', 'Exports\ExportPendingArrangementPack
|
||||
Route::get('/export/arrived-parcel', 'Exports\ExportArrivedParcelController@export')->name('packing_list.arrived_parcel.export');
|
||||
Route::get('/export/parcel-summary', 'Exports\ExportArrivedParcelController@summary');
|
||||
Route::get('/export/parcel-postcode', 'Exports\ExportParcelPostcodesController@export');
|
||||
Route::get('/export/{year}/customer-total-order', 'Exports\ExportCustomersToExcelController@totalOrders');
|
||||
Route::get('/export/packing-list-warehouse/guangzhou2-to-johor', 'Exports\ExportArrivedParcelController@guangZhou2ToJohor');
|
||||
|
||||
Route::get('/settings', function () {
|
||||
return view('pages.settings');
|
||||
@@ -660,43 +652,4 @@ Route::get('/billplz/fix', function(){
|
||||
});
|
||||
|
||||
|
||||
Route::get('/invoices/fix', function(){
|
||||
|
||||
$orders = \App\Models\Order::whereIn('company_module_id', [294, 2703])->get();
|
||||
|
||||
foreach ($orders as $order){
|
||||
$invoices = $order->transactions()->where('transactions.type', \App\Classes\ValueObjects\Constants\TransactionType::SHIPPING_INVOICE)->get();
|
||||
foreach ($invoices as $invoice){
|
||||
|
||||
$invoice->documents()->delete();
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = (App()->make(\App\Classes\Modules\Documents\Services\CreatesDocument::class))->execute($invoice, $document_object);
|
||||
|
||||
(App()->make(\App\Classes\Modules\Documents\Services\CreatesFiles::class))->execute($document, $document_object);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Route::get('/invoices/combine/{ids}', function($ids){
|
||||
|
||||
$ids = json_decode($ids);
|
||||
|
||||
$transactions = Transaction::whereIn('id', $ids)->get();
|
||||
|
||||
$pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoices_combined', ['invoice_transactions' => $transactions]);
|
||||
return $pdf->download('combined_invoice_.pdf');
|
||||
})->name('invoice.combined_summary');
|
||||
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
class DashboardCest
|
||||
{
|
||||
public function _before(AcceptanceTester $I)
|
||||
{
|
||||
|
||||
$I->wantTo('Test All Dashboard Data is Loaded');
|
||||
$I->amOnPage('/dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* test if the sidebar was loaded
|
||||
* @param AcceptanceTester $I
|
||||
* @return void
|
||||
*/
|
||||
public function tryToTestIfAllAdminSidebarAreLoaded(AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('/dashboard');
|
||||
$I->see('DASHBOARD');
|
||||
$I->see('CUSTOMERS');
|
||||
$I->see('DELIVERY LIST');
|
||||
$I->see('CONTAINERS');
|
||||
$I->see('PAYMENT AND BILLING');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test if the dashboard content is Loaded
|
||||
* @param AcceptanceTester $I
|
||||
* @return void
|
||||
*/
|
||||
public function tryToTestAllDashboardComponentLoaded(AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('/dashboard');
|
||||
$I->see('Dashboard');
|
||||
$I->see('NEW CUSTOMERS');
|
||||
$I->see('Unclaimed Packing Lists');
|
||||
$I->see('Identification Verification');
|
||||
$I->see('ACTIVATED ORDERS');
|
||||
$I->see('PENDING SHIPMENT');
|
||||
|
||||
//delay a few second
|
||||
$I->wait(5); // 2 seconds delay
|
||||
|
||||
$I->see('Unclaimed Packing Lists');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user