Compare commits

..

1 Commits

Author SHA1 Message Date
Cleison Freitas 27c3cd4275 FetchInvoice API to multiple payments 2022-12-27 12:34:29 -03:00
68 changed files with 245 additions and 2554 deletions
@@ -1,20 +0,0 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class Receiver implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('receiver', '=', $value);
}
}
@@ -94,11 +94,6 @@ 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')
$requestBody = [
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
'collection_id' => config('billplz.collection_id'),
'name' => $name,
'email' => $email,
@@ -34,13 +34,7 @@ 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();
@@ -1,66 +0,0 @@
<?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));
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\FetchPayments;
use App\Classes\Modules\Transactions\Services\ListsTransactions;
use App\Http\Resources\InvoiceResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class FetchInvoiceLogic extends AbstractControllerLogic
{
/**
* ListTransactionsLogic constructor.
* @param FetchPayments $fetchPayments
*/
public function __construct(FetchPayments $fetchPayments)
{
$this->fetchPayments = $fetchPayments;
}
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Transactions',
'message' => 'You have successfully retrieved a list of transactions'
];
}
/** @var FetchPayments */
private $fetchPayments;
public function logic(Request $request) : JsonResponse
{
$query = $this->fetchPayments->execute($this->fetchPayments->deserializeFilters($request->input('filters')));
return $this->collectionResponse(InvoiceResource::collection($query));
}
}
?>
@@ -1,204 +0,0 @@
<?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]);
}
}
@@ -15,7 +15,7 @@ class CreatesTransaction extends AbstractUpdateRelationshipRecord
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute( $packing_list, TransactionObject $object) {
public function execute(PackingList $packing_list, TransactionObject $object) {
$model = new Transaction();
$model->bill_no = $object->getBillNo();
$model->type = $object->getTransactionType();
@@ -1,21 +1,22 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
namespace App\Classes\Modules\Transactions\Services;
use App\Models\Transaction;
use Illuminate\Database\Eloquent\Builder;
use App\Classes\General\Eloquent\AbstractListRecord;
use App\Models\Wallet;
class ListsWallet extends AbstractListRecord
class FetchPayments extends AbstractListRecord
{
/** @var Booking */
/** @var Transaction */
private $repository;
/**
* ListsBookings constructor.
* @param Booking $repository
* @param Transaction $repository
*/
public function __construct(Wallet $repository)
public function __construct(Transaction $repository)
{
$this->repository = $repository;
}
@@ -1,76 +0,0 @@
<?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));
}
}
@@ -1,132 +0,0 @@
<?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());
}
}
}
@@ -1,101 +0,0 @@
<?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));
}
}
@@ -1,117 +0,0 @@
<?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));
}
}
@@ -1,60 +0,0 @@
<?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));
}
}
@@ -1,113 +0,0 @@
<?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));
}
}
@@ -1,69 +0,0 @@
<?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));
}
}
@@ -1,72 +0,0 @@
<?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));
}
}
@@ -1,65 +0,0 @@
<?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;
}
}
@@ -1,94 +0,0 @@
<?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;
}
}
@@ -1,90 +0,0 @@
<?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;
}
}
@@ -1,28 +0,0 @@
<?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();
}
}
@@ -1,22 +0,0 @@
<?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();
}
}
@@ -1,26 +0,0 @@
<?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);
}
}
@@ -1,30 +0,0 @@
<?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);
}
}
@@ -1,34 +0,0 @@
<?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();
}
}
@@ -1,32 +0,0 @@
<?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();
}
}
@@ -1,27 +0,0 @@
<?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();
}
}
@@ -1,27 +0,0 @@
<?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);
}
}
@@ -1,25 +0,0 @@
<?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);
}
}
@@ -1,55 +0,0 @@
<?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;
}
}
@@ -1,51 +0,0 @@
<?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;
}
}
@@ -1,51 +0,0 @@
<?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;
}
}
@@ -1,51 +0,0 @@
<?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;
}
}
@@ -1,51 +0,0 @@
<?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;
}
}
@@ -1,40 +0,0 @@
<?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 [];
}
}
@@ -1,30 +0,0 @@
<?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 [];
}
}
@@ -1,30 +0,0 @@
<?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 [];
}
}
@@ -1,40 +0,0 @@
<?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 [];
}
}
@@ -1,30 +0,0 @@
<?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,20 +0,0 @@
<?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);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Orders;
use App\Classes\Modules\Orders\ControllersLogic\FetchOrderLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class FetchMultipleOrderController
{
/**
* @param Request $request
* @param FetchOrderLogic $logic
* @return JsonResponse
*/
public function fetch(Request $request, FetchOrderLogic $logic): JsonResponse
{
return $logic->execute($request);
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\Transactions;
use App\Classes\Modules\Transactions\ControllersLogic\FetchInvoiceLogic;
use App\Classes\Modules\Transactions\ControllersLogic\ListTransactionsLogic;
use App\Http\Controllers\Controller;
use App\Http\Resources\InvoiceResource;
use App\Models\Order;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class FetchInvoiceController extends Controller
{
public function list(Request $request)
{
try{
return InvoiceResource::collection(Order::Paginate(10,['*'],'page',2));
}catch(\Exception $ex) {
return response()->json(['error' => [$ex->getMessage()]],404);
}
}
/**
* @param Request $request
* @param FetchInvoiceLogic $logic
* @return JsonResponse
*/
public function fetch(Request $request, FetchInvoiceLogic $logic) : JsonResponse {
return $logic->execute($request);
}
}
@@ -1,38 +0,0 @@
<?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);
}
}
@@ -1,15 +0,0 @@
<?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);
}
}
@@ -1,15 +0,0 @@
<?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);
}
}
@@ -1,15 +0,0 @@
<?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);
}
}
@@ -1,15 +0,0 @@
<?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);
}
}
@@ -1,14 +0,0 @@
<?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);
}
}
@@ -1,15 +0,0 @@
<?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);
}
}
@@ -1,14 +0,0 @@
<?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);
}
}
@@ -1,29 +0,0 @@
<?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();
}
}
@@ -1,15 +0,0 @@
<?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);
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class InvoiceResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'invoice_id' => $this->reference,
'carrier_tracking_number' => '1zbr06tw403742920',
'this_package_was_delivered' => '1zbr06tw403742920',
'due_date' => '11.04.2021',
'date_paid' => '21.01.2021',
'outstanding' => 92.01
];
}
}
-5
View File
@@ -102,9 +102,4 @@ 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');
}
}
-34
View File
@@ -1,34 +0,0 @@
<?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');
}
}
-32
View File
@@ -1,32 +0,0 @@
<?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');
}
}
@@ -1,19 +0,0 @@
<?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'
];
}
@@ -1,40 +0,0 @@
<?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');
}
}
@@ -1,153 +0,0 @@
<template>
<div class="row">
<div class="col">
<div class="row">
<div class="col-12 col-sm-12 col-md-9">
<div class="row m-b-15 m-l-5 m-r-10">
<div class="col b-a b-grey rounded bg-master-light">
<div class="row">
<div class="col padding-20">
<div class="row align-items-center justify-conten-center" @click="chooseAllInvoice()">
<div class="col-auto pointer">
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selectAllInvoice, 'fa-check-square': selectAllInvoice, 'text-primary':selectAllInvoice}" ></i>
</div>
<div class="col">
<h5 class="no-margin font-heading">Invoice No</h5>
</div>
<div class="col">
<h5 class="no-margin">Invoice Date</h5>
</div>
<div class="col">
<h5 class="no-margin">Status</h5>
</div>
<div class="col">
<h5 class="no-margin">Amount</h5>
</div>
<div class="col-auto">
<div class="btn bg-grey no-border muted invisible">
<i class="fa fa-file-pdf-o"></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" v-for="invoice in invoices">
<div class="col">
<payments-billing-components :data="invoice" :selectedInvoice="selectedInvoice" v-on:input="updateList($event)"></payments-billing-components>
</div>
</div>
</div>
<div class="col-12 col-sm-12 col-md-3">
<div class="row align-items-center">
<div class="col b-a b-grey rounded padding-25">
<div class="row">
<div class="col">
<h6 class="semi-bold muted">Payment Summary</h6>
</div>
</div>
<div class="row align-items-center justify-content-center">
<div class="col-auto">
<div class="padding-5">
<i class="fa fa-angle-up"></i>
</div>
</div>
<div class="col p-l-0">
<h6 class="semi-bold text-primary">{{selectedInvoice.length}} Invoice Selected</h6>
</div>
</div>
<div class="row">
<div class="col">
<div class="row" v-for="invoice in selectedInvoice">
<div class="col">
<h6 class="no-margin">lorem ipsum</h6>
</div>
<div class="col-auto">
<h6 class="no-margin">52x62x635 CM</h6>
</div>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col">
<h6 class="normal">Total Payments</h6>
</div>
<div class="col-auto">
<h6 class="text-primary bold">RM 3300.00</h6>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="btn btn-xl btn-success pointer m-t-10 w-100" @click='makePayment'>Make Payments</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
company_module_id: {
type: Number,
required: true,
},
},
data(){
return {
section: 'customerPaymentBillingSectionComponent',
isLoading: true,
invoices: null,
selectedInvoice: [],
selectAllInvoice: false,
}
},
computed: {
pendingQueue () {
return this.$store.getters.isInCompleteQueue(this.section);
}
},
watch: {
pendingQueue(inComplete){
if(inComplete){
this.fetchInvoice();
}
}
},
created(){
this.$store.dispatch('updateListQueue', {'name': this.section});
},
methods: {
fetchInvoice(){
this.isLoading = true;
this.submit(route('api.company.invoice.list', this.company_module_id), 'get', this.section, false, false)
},
successHandler(response){
this.$store.dispatch('completeList', {'name': this.section, 'data': []});
this.isLoading = false;
this.invoices = response.payload.data;
},
makePayment(){
var selectedId = this.selectedInvoice.map(s=>s.id);
console.log(selectedId);
},
updateList(packageList){
this.selectedInvoice.includes(packageList) ? this.selectedInvoice.splice(this.selectedInvoice.indexOf(packageList), 1) : this.selectedInvoice.push(packageList);
this.selectedInvoice.length === this.invoices.length ? this.selectAllInvoice = true : this.selectAllInvoice = false;
},
chooseAllInvoice(){
this.selectAllInvoice = !this.selectAllInvoice;
this.selectedInvoice = [];
if (this.selectAllInvoice) {
this.selectedInvoice = this.invoices;
}
}
}
}
</script>
@@ -4,36 +4,110 @@
<div class="row">
<div class="col padding-20">
<div class="row align-items-center">
<div class="col-auto pointer align-items-center" @click="activate()">
<div class="col-auto pointer align-items-center" @click="selected = !selected">
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
</div>
<div class="col">
<h5 class="no-margin">{{ item.bill_no }}</h5>
<h5 class="no-margin">{{item.country.id}}05052021</h5>
</div>
<div class="col">
<h5 class="no-margin">{{ item.created_at }}</h5>
<h5 class="no-margin">Invoice Date Invoice Date</h5>
</div>
<div class="col">
<h5 class="no-margin">Status</h5>
</div>
<div class="col">
<h5 class="no-margin">MYR {{ item.amount.toFixed(2) }}</h5>
<h5 class="no-margin">Amount</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 bg-grey no-border muted">
<i class="fa fa-file-pdf-o"></i>
</div>
</template>
</document-file-viewer-component>
<div class="btn bg-grey no-border" @click="expanded = !expanded">
<i class="fa" :class="{'fa-angle-down': !expanded, 'fa-angle-up': expanded}" ></i>
</div>
</div>
</div>
</div>
</div>
<div class="row b-t b-grey p-t-10" v-show="expanded">
<div class="col p-b-10">
<div class="row">
<div class="col p-l-20 p-r-20 p-t-10 p-b-10">
<div class="row align-items-center">
<div class="col-auto invisible">
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="m-b-0">Carrier Tracking Number</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">#1zbr06tw403742920</h5>
</div>
</div>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="m-b-0">Due Date</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">11.04.2021</h5>
</div>
</div>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">Outstanding</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">RM0.00</h5>
</div>
</div>
</div>
</div>
<div v-else>
<div class="btn bg-grey no-border muted invisible">
<i class="fa fa-file-pdf-o"></i>
</div>
</div>
<div class="row">
<div class="col p-l-20 p-r-20 p-t-10 p-b-10">
<div class="row align-items-center">
<div class="col-auto invisible">
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="m-b-0 normal-text">This package was delivered by</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">#1zbr06tw403742920</h5>
</div>
</div>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="m-b-0">Date Paid</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">21.01.2021</h5>
</div>
</div>
</div>
<div class="col">
<div class="btn btn-outline-complete btn-lg">
Invoice Detail
</div>
</div>
</div>
</div>
@@ -46,33 +120,10 @@
<script>
import componentHandler from '../../../general/mixins/componentHandler';
export default {
props: {
selectedInvoice: {
type: Array,
required: false,
}
},
data(){
return {
expanded: false,
selectedValue: false,
}
},
methods: {
activate(){
this.select = !this.select;
this.$emit('input', this.data);
}
},
computed: {
selected() {
var response = false;
this.selectedInvoice.forEach((value, index) => {
if (value.id == this.item.id) {
response = true;
}
});
return response;
selected: false,
}
},
mixins: [componentHandler]
@@ -1,4 +0,0 @@
@extends('layouts.base_portal')
@section('inner_content')
<customer-payment-billing-section-component :company_module_id={{$company_module_id}}></customer-payment-billing-section-component>
@endsection
File diff suppressed because one or more lines are too long
+2 -6
View File
@@ -24,12 +24,12 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
require __DIR__ . '/delivery.php';
Route::group(['middleware' => 'valid.token'], function () {
Route::group([/*'middleware' => 'valid.token'*/], function () {
Route::get('/storage/{fileName}/fetch', 'Documents\RenderDocumentController@fileStorageServe')->where(['fileName' => '.*'])->name('storage.document.file');
Route::post('online_payment/callback', 'Billplz\CallbackBillplzController@callback')->name('online_payment.callback');
Route::post('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import')->name('debtor.import');
require __DIR__ . '/company.php';
@@ -62,11 +62,7 @@ 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
View File
@@ -33,6 +33,4 @@ 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');
});
-9
View File
@@ -1,9 +0,0 @@
<?php
use Illuminate\Support\Facades\Route;
Route::get('/group/paymenttransaction/{transactionsArray?}', 'Transactions\MultipleInvoiceOnePaymentController@getallivoiceid')->name('grouppayment');
+2
View File
@@ -1,5 +1,6 @@
<?php
use App\Http\Controllers\Transactions\FetchInvoiceController;
use Illuminate\Support\Facades\Route;
Route::group(['prefix' => 'order', 'as' => 'order.', 'namespace' => 'Orders'], function () {
@@ -18,4 +19,5 @@ Route::group(['prefix' => 'order', 'as' => 'order.', 'namespace' => 'Orders'], f
Route::put('/assign-remark/{id}', 'AssignOrderRemarkController@create')->name('assign.remark');
Route::get('/{id}/shipping-cost', 'ShippingCostController@calculate')->name('shipping.cost');
Route::get('/payments_billings' , [FetchInvoiceController::class,'fetch'])->name('shipping.invoice');
});
-15
View File
@@ -1,15 +0,0 @@
<?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');
});
+3 -9
View File
@@ -33,7 +33,7 @@ use Illuminate\Support\Facades\Route;
|
*/
require __DIR__ . '/template.php';
require __DIR__ . '/template.php';
Route::domain('hywave.izyim.com')->group(function () {
Route::group(['as' => 'last_mile_delivery.'], function () {
@@ -160,12 +160,6 @@ Route::get('/customer/{marking}/details', function ($marking) {
return view('pages.customers.profile_details', ['id' => $id]);
})->name('customer.profile.details');
Route::get('/customer/{marking}/payment-and-billing', function ($marking) {
$connection = CompanyConnection::where('invitee_reference', $marking)->first();
$company_module_id = $connection->invitee->id;
return view('pages.customers.paymentsBilling', ['company_module_id' => $company_module_id]);
})->name('customer.payment-and-billing');
Route::get('/orders/refresh', function(\Illuminate\Http\Request $request){
$packingLists = \App\Models\PackingList::where('type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->has('containers')->get();
dd($packingLists);
@@ -204,9 +198,9 @@ Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download
Route::get('/report/customclearance/{orderid}', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance');
Route::group(['prefix' => 'template', 'as' => 'template.'], function () {
Route::get('/payment-and-billing', function () {
Route::get('/payments-and-billing', function () {
return view('pages.templates.paymentsBilling');
})->name('payment-and-billing');
})->name('payments-and-billing');
Route::get('/shipping-queue', function () {
return view('pages.templates.shippingQueue');