diff --git a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php index 485e9cf3..e7aa57f8 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php @@ -53,24 +53,18 @@ class DeleteUserLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { - try { - DB::beginTransaction(); + $user = $this->fetchesUser->execute(['id' => $request->route('id')]); + $this->canDeleteUser->passes(); + $this->deletesUser->execute($user); - $user = $this->fetchesUser->execute(['id' => $request->route('id')]); - $this->canDeleteUser->passes(); - $this->deletesUser->execute($user); - - DB::commit(); - return $this->resourceResponse(new UserResource($user)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + return $this->resourceResponse(new UserResource($user)); } } \ No newline at end of file diff --git a/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php b/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php index 8c164317..48e3bb62 100644 --- a/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php +++ b/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php @@ -22,7 +22,7 @@ class AddressObject implements DataTransferObject /** @var int */ private $districtId; - /** @var int */ + /** @var string */ private $postCode; /** @@ -32,9 +32,9 @@ class AddressObject implements DataTransferObject * @param int $countryId * @param int $stateId * @param int $districtId - * @param int $postCode + * @param string $postCode */ - public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode) + public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, string $postCode) { $this->streetOne = $streetOne; $this->streetTwo = $streetTwo; @@ -85,9 +85,9 @@ class AddressObject implements DataTransferObject } /** - * @return int + * @return string */ - public function getPostCode(): int + public function getPostCode(): string { return $this->postCode; } diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php index 7501bfd1..8c763460 100644 --- a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php @@ -2,6 +2,8 @@ namespace App\Classes\Modules\Billplzs\ControllersLogic; +use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject; +use App\Classes\Modules\Wallets\Services\UpdatesWallet; use App\Classes\Exceptions\ResourceNotFoundException; use App\Http\Resources\TransactionResource; @@ -32,6 +34,8 @@ class CallbackBillplzLogic /** @var UpdatesTransactionStatus */ private $updatesTransactionStatus; + /** @var UpdatesWallet */ + private $updatesWallet; /** * CreateBookingLogic constructor. @@ -39,11 +43,12 @@ class CallbackBillplzLogic * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus */ - public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus) + public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWallet $updatesWallet) { $this->getBillplzBill = $getBillplzBill; $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->updatesWallet = $updatesWallet; } @@ -55,7 +60,6 @@ class CallbackBillplzLogic */ public function execute(Request $request) { - $billplzXSignatureObject = new BillplzXSignatureObject($request); if(!$billplzXSignatureObject->isValidSignature()){ @@ -70,13 +74,26 @@ class CallbackBillplzLogic if($billPlz->state === 'paid') { $status = ApprovalStatus::APPROVED; + if ( + $transaction->owner_type == 'App\Models\Wallet' && + $transaction->status == ApprovalStatus::PENDING_VERIFICATION + ) { + $wallet = $transaction->owner; + $updateWalletAmount = $wallet->amount + $transaction->amount; + $walletOject = new WalletObject($wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount); + $wallet = $this->updatesWallet->execute($wallet, $walletOject); + } + } if($billPlz->state === 'due') { $status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION; } - $this->updatesTransactionStatus->execute($transaction, $status); + if($transaction->status !== ApprovalStatus::COMPLETED){ + $this->updatesTransactionStatus->execute($transaction, $status); + } + $token = Auth::fromUser(User::find(1)); $request->headers->set('Authorization', 'Bearer '.$token); diff --git a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php index d1cdbada..71ea7ba1 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php @@ -78,6 +78,7 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic * @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 diff --git a/app/Classes/Modules/Bookings/Standards/Rules/CanDeleteBooking.php b/app/Classes/Modules/Bookings/Standards/Rules/CanDeleteBooking.php index dfd307bc..d1fcfe15 100644 --- a/app/Classes/Modules/Bookings/Standards/Rules/CanDeleteBooking.php +++ b/app/Classes/Modules/Bookings/Standards/Rules/CanDeleteBooking.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Bookings\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject; +use Illuminate\Support\Facades\Auth; class CanDeleteBooking extends AbstractRule { @@ -14,7 +15,7 @@ class CanDeleteBooking extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('delete booking')) { + if (!Auth::user()->can('delete booking')) { return false; } diff --git a/app/Classes/Modules/Bookings/Standards/Rules/CanUpdateBooking.php b/app/Classes/Modules/Bookings/Standards/Rules/CanUpdateBooking.php index bf5c022c..7158a825 100644 --- a/app/Classes/Modules/Bookings/Standards/Rules/CanUpdateBooking.php +++ b/app/Classes/Modules/Bookings/Standards/Rules/CanUpdateBooking.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Bookings\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Bookings\Standards\Validators\BookingValidation; +use Illuminate\Support\Facades\Auth; class CanUpdateBooking extends AbstractRule { @@ -29,7 +30,7 @@ class CanUpdateBooking extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('edit booking')) { + if (!Auth::user()->can('edit booking')) { return false; } diff --git a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanCreateRate.php b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanCreateRate.php index 842a548b..cf63f89c 100644 --- a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanCreateRate.php +++ b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanCreateRate.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Currencies\Standards\Rules\Rates; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Currencies\Standards\Validators\Rates\RateValidation; use App\Classes\Modules\Currencies\DataTransferObjects\RateObject; +use Illuminate\Support\Facades\Auth; class CanCreateRate extends AbstractRule { @@ -27,7 +28,7 @@ class CanCreateRate extends AbstractRule protected function authorized(): bool { // TODO Set Authorization rules - if (!\Auth::user()->can('add currency_rate')) { + if (!Auth::user()->can('add currency_rate')) { return false; } diff --git a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanDeleteRate.php b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanDeleteRate.php index 4ebefb9e..37fff506 100644 --- a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanDeleteRate.php +++ b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanDeleteRate.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Currencies\Standards\Rules\Rates; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Currencies\DataTransferObjects\RateObject; +use Illuminate\Support\Facades\Auth; class CanDeleteRate extends AbstractRule { @@ -14,7 +15,7 @@ class CanDeleteRate extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('delete currency_rate')) { + if (!Auth::user()->can('delete currency_rate')) { return false; } diff --git a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanListRates.php b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanListRates.php index 496ba1e5..bd49c263 100644 --- a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanListRates.php +++ b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanListRates.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Currencies\Standards\Rules\Rates; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyObject; +use Illuminate\Support\Facades\Auth; class CanListRates extends AbstractRule { @@ -14,7 +15,7 @@ class CanListRates extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('view currency_rate')) { + if (!Auth::user()->can('view currency_rate')) { return false; } diff --git a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanUpdateRate.php b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanUpdateRate.php index 59564725..8a153c54 100644 --- a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanUpdateRate.php +++ b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanUpdateRate.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Currencies\Standards\Rules\Rates; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Currencies\Standards\Validators\Rates\RateValidation; use App\Classes\Modules\Currencies\DataTransferObjects\RateObject; +use Illuminate\Support\Facades\Auth; class CanUpdateRate extends AbstractRule { @@ -29,7 +30,7 @@ class CanUpdateRate extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('view currency_rate')) { + if (!Auth::user()->can('view currency_rate')) { return false; } diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php index 50f7e81d..f7b05a10 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Segments\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject; use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation; +use Illuminate\Support\Facades\Auth; class CanCreateSegment extends AbstractRule { @@ -27,7 +28,7 @@ class CanCreateSegment extends AbstractRule protected function authorized(): bool { // TODO Set Authorization rules - if (!\Auth::user()->can('add segment')) { + if (!Auth::user()->can('add segment')) { return false; } diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php index 197b0a5f..9faf4da6 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Segments\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject; +use Illuminate\Support\Facades\Auth; class CanDeleteSegment extends AbstractRule { @@ -14,7 +15,7 @@ class CanDeleteSegment extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('delete segment')) { + if (!Auth::user()->can('delete segment')) { return false; } diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php index 58a8c0ca..8287dfd6 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Segments\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject; use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation; +use Illuminate\Support\Facades\Auth; class CanUpdateSegment extends AbstractRule { @@ -30,7 +31,7 @@ class CanUpdateSegment extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('edit segment')) { + if (!Auth::user()->can('edit segment')) { return false; } diff --git a/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php new file mode 100644 index 00000000..7e93ccb5 --- /dev/null +++ b/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php @@ -0,0 +1,128 @@ + '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; + + /** + * CreateWalletLogic constructor. + * @param FetchesCompany $fetchesCompany + * @param GeneratesWalletCode $generatesWalletCode + * @param CreatesWallet $createsWallet + * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber + * @param CreatesTransaction $createsTransaction + * @param UpdatesWallet $updatesWallet + */ + public function __construct( + FetchesCompany $fetchesCompany, + GeneratesWalletCode $generatesWalletCode, + CreatesWallet $createsWallet, + GeneratesTransactionBillNumber $generatesTransactionBillNumber, + CreatesTransaction $createsTransaction, + UpdatesWallet $updatesWallet + ) + { + $this->fetchesCompany = $fetchesCompany; + $this->generatesWalletCode = $generatesWalletCode; + $this->createsWallet = $createsWallet; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->createsTransaction = $createsTransaction; + $this->updatesWallet = $updatesWallet; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $amount = floatval(str_replace(',', '', $request->input('amount'))); + $company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]); + 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('CREDIT-NOTE-'); + + $transaction_object = new TransactionObject( + $billNumber, + TransactionType::CREDIT_NOTE, + 1, + $wallet->company->id, + 1, + PaymentMethodType::WALLET, + $amount, + $amount, + 1, + 1, + 1, + 0, + 0, + null, + ApprovalStatus::PENDING_SUBMISSION, + [] + ); + + $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)); + } +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/DebitWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/DebitWalletLogic.php new file mode 100644 index 00000000..3085184f --- /dev/null +++ b/app/Classes/Modules/Wallets/ControllersLogic/DebitWalletLogic.php @@ -0,0 +1,114 @@ + '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 ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $amount = floatval(str_replace(',', '', $request->input('amount'))); + $company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]); + 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::WALLET, + $amount, + $amount, + 1, + 1, + 1, + 0, + 0, + null, + ApprovalStatus::PENDING_SUBMISSION, + [] + ); + + $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)); + } +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php index 8497ec32..776e4c0b 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php @@ -3,16 +3,19 @@ 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\Modules\Transactions\DataTransferObjects\TransactionObject; +use App\Classes\Modules\Companies\Services\FetchesCompany; +use App\Classes\Modules\Wallets\Services\CreatesWallet; +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\Modules\Wallets\Standards\Rules\CanTopUpWallet; +use App\Classes\ValueObjects\Constants\PaymentMethodType; +use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Http\Resources\WalletResource; -use App\Classes\Modules\Transactions\Processors\CreateWalletTransactionProcessor; - +use App\Http\Resources\WalletTransactionResource; use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -30,26 +33,50 @@ class TopUpWalletLogic extends AbstractControllerLogic ]; } - /** @var FetchesWallet */ - private $fetchesWallet; - /** @var CanTopUpWallet */ - private $canTopUpWallet; + /** @var FetchesCompany */ + private $fetchesCompany; - /** @var CreateWalletTransactionProcessor */ - private $createWalletTransactionProcessor; + /** @var GeneratesWalletCode */ + private $generatesWalletCode; + + /** @var CreatesWallet */ + private $createsWallet; + + /** @var GeneratesTransactionBillNumber */ + private $generatesTransactionBillNumber; + + /** @var CreatesWalletTransaction */ + private $createsWalletTransaction; + + /** @var CreatesBillplzBill */ + private $createsBillplzBill; + + /** @var CreatesTransaction */ + private $createsTransaction; /** * CreateWalletLogic constructor. - * @param CreatesWallet $createsWallet + * @param FetchesCompany $fetchesCompany * @param GeneratesWalletCode $generatesWalletCode - * @param CanCreateCompanyWallet $canCreateCompanyWallet + * @param CreatesWallet $createsWallet + * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber */ - public function __construct(CanTopUpWallet $canTopUpWallet, FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor) + public function __construct( + FetchesCompany $fetchesCompany, + GeneratesWalletCode $generatesWalletCode, + CreatesWallet $createsWallet, + GeneratesTransactionBillNumber $generatesTransactionBillNumber, + CreatesBillplzBill $createsBillplzBill, + CreatesTransaction $createsTransaction + ) { - $this->canTopUpWallet = $canTopUpWallet; - $this->fetchesWallet = $fetchesWallet; - $this->createWalletTransactionProcessor = $createWalletTransactionProcessor; + $this->fetchesCompany = $fetchesCompany; + $this->generatesWalletCode = $generatesWalletCode; + $this->createsWallet = $createsWallet; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->createsBillplzBill = $createsBillplzBill; + $this->createsTransaction = $createsTransaction; } /** @@ -59,14 +86,49 @@ class TopUpWalletLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - $wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]); + $amount = floatval(str_replace(',', '', $request->input('amount'))); + $company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]); + if (!$company->wallets()->first()) { + $object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute()); + $wallet = $this->createsWallet->execute($object, $company); + } + + $wallet = $company->wallets()->first(); - $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount')); + $user = $company->employees()->first(); + $billNumber = $this->generatesTransactionBillNumber->execute('TOPUP-'); + + $billPlzBill = $this->createsBillplzBill->execute( + $user->name, + $user->email, + 'This payment is made for wallet topup. ' . $company->reference, + $amount, + $billNumber, + $request->input('bank_code') + ); - $this->canTopUpWallet->passes($walletOject); + $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->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::TOP_UP); + $transaction = $this->createsTransaction->execute($company->wallets()->first(), $transaction_object); - return $this->resourceResponse(new WalletResource($wallet)); + return $this->resourceResponse(new WalletTransactionResource($transaction)); } } diff --git a/app/Classes/Modules/Wallets/Services/CreatesWallet.php b/app/Classes/Modules/Wallets/Services/CreatesWallet.php index c114b9de..2a927e6d 100644 --- a/app/Classes/Modules/Wallets/Services/CreatesWallet.php +++ b/app/Classes/Modules/Wallets/Services/CreatesWallet.php @@ -21,8 +21,6 @@ class CreatesWallet extends AbstractUpdateRelationshipRecord $model->code = $object->getCode(); $model->currency_id = $object->getCurrency(); - return $this->handler($company->wallets(), $model); - } } diff --git a/app/Classes/ValueObjects/Constants/TransactionType.php b/app/Classes/ValueObjects/Constants/TransactionType.php index 698abd76..040f63fa 100644 --- a/app/Classes/ValueObjects/Constants/TransactionType.php +++ b/app/Classes/ValueObjects/Constants/TransactionType.php @@ -24,5 +24,7 @@ final class TransactionType { public const CREDIT_NOTE = 9; + public const DEBIT_NOTE = 11; + public const WITHDRAW = 10; } diff --git a/app/Http/Controllers/Wallets/CreditWalletController.php b/app/Http/Controllers/Wallets/CreditWalletController.php new file mode 100644 index 00000000..b3143588 --- /dev/null +++ b/app/Http/Controllers/Wallets/CreditWalletController.php @@ -0,0 +1,15 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Wallets/DebitWalletController.php b/app/Http/Controllers/Wallets/DebitWalletController.php new file mode 100644 index 00000000..7feafb39 --- /dev/null +++ b/app/Http/Controllers/Wallets/DebitWalletController.php @@ -0,0 +1,15 @@ +execute($request); + } +} diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index 54ab047d..5488df0e 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -60,10 +60,8 @@ class CompanyResource extends JsonResource $segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $this->id)->first(); return $segment ? CurrencyResource::collection(Currency::whereIn('id', $segment->detail->currencies)->get()) : []; }), + 'wallet' => WalletResource::collection($this->wallets), 'created_at' => $this->created_at->format('d-m-Y') - - ]; - } } diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 633985cf..6de5d391 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -35,9 +35,19 @@ class TransactionResource extends JsonResource 'status' => (int) $this->status, 'details' => TransactionDetailResource::collection($this->transactionDetails), 'documents' => new DocumentResource($this->documents()->first()), - 'customer_booking' => new TransactionResource($this->when((int) $this->type === TransactionType::BILL, $this->booking->transactions()->payments()->complete()->where('original_amount', '=', $this->original_amount)->where('id', '<', $this->id)->orderByDesc('id')->first())), + 'customer_booking' => new TransactionResource($this->when((int) $this->type === TransactionType::BILL, function(){ + $key = 0; + $bills = $this->booking->transactions()->bills()->where('original_amount', '=', $this->original_amount)->get(); + if(count($bills) > 1){ $key = $bills->search(function($bill){ return $bill->id === $this->id; }); } + return $this->booking->transactions()->payments()->complete()->where('original_amount', '=', $this->original_amount)->skip($key)->first(); + + })), 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'), - 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A') + 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), + 'interval' => [ + 'value' => (Carbon::parse($this->created_at)->addDays(3)->gt(Carbon::now()) ) ? '+' : '-' , + 'duration' => Carbon::parse($this->created_at)->addDays(3)->diff(Carbon::now())->format('%d'), + ], ]; } } diff --git a/app/Http/Resources/WalletResource.php b/app/Http/Resources/WalletResource.php index 37ff5dbd..39c634eb 100644 --- a/app/Http/Resources/WalletResource.php +++ b/app/Http/Resources/WalletResource.php @@ -2,6 +2,7 @@ namespace App\Http\Resources; +use App\Classes\ValueObjects\Constants\TransactionType; use Illuminate\Http\Resources\Json\JsonResource; class WalletResource extends JsonResource @@ -19,7 +20,17 @@ class WalletResource extends JsonResource 'code' => $this->code, 'currency_id' => $this->currency_id, 'amount' => (double) $this->amount, - 'company_id' => (int) $this->company_id + 'company_id' => (int) $this->owner->id, + 'transactions' => $this->transactions()->orderBy('id', 'DESC')->get(), + 'topup_transactions' => $this->transactions()->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get(), + + // 'transaction' => $this->whenLoaded('transactions', function() { + // return [ + // 'topup' => $this->transactions + // ]; + // }), + // 'transaction' // all + // 'top_transaction' // only topup ]; } } diff --git a/app/Http/Resources/WalletTransactionResource.php b/app/Http/Resources/WalletTransactionResource.php index 1d0037fe..af634f3b 100644 --- a/app/Http/Resources/WalletTransactionResource.php +++ b/app/Http/Resources/WalletTransactionResource.php @@ -23,7 +23,8 @@ class WalletTransactionResource extends JsonResource 'currency_id' => (int) $this->currency_id, 'original_amount' => (double) $this->original_amount, 'original_currency_id' => (int) $this->original_currency_id, - 'currency_rate' => (double) $this->currency_rate + 'currency_rate' => (double) $this->currency_rate, + 'reference' => $this->payment_reference ]; } } diff --git a/app/Models/User.php b/app/Models/User.php index d41cbb7f..6fd8b6b0 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\SoftDeletes; use Spatie\Permission\Traits\HasRoles; use Tymon\JWTAuth\Contracts\JWTSubject; @@ -23,7 +24,7 @@ class User extends AbstractModel implements AuthorizableContract, CanResetPasswordContract { - use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail; + use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes; /** diff --git a/app/Models/Wallet.php b/app/Models/Wallet.php index 52d8f718..29c3ddc9 100644 --- a/app/Models/Wallet.php +++ b/app/Models/Wallet.php @@ -2,13 +2,14 @@ namespace App\Models; +use App\Classes\General\Interfaces\Transactionable; 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 +class Wallet extends AbstractModel implements Transactionable { use SoftDeletes; diff --git a/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue b/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue deleted file mode 100644 index af8a43b7..00000000 --- a/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue +++ /dev/null @@ -1,196 +0,0 @@ - - \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue index 9acdab65..24dcaea0 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue @@ -68,6 +68,14 @@ {{item.original_currency.short_code}} {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} +
+
Service
+
+ {{item.booking.service.name}} +
+
+ +
+
+
Service
+
+ {{item.booking.service.name}} +
+
@@ -60,12 +66,20 @@ {{item.original_currency.short_code}}
-
+
Amount
{{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
timer
+
+ {{item.interval.value}} + {{item.interval.duration}} + days +
+
diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index acec8d4b..0c2ce14f 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -215,6 +215,21 @@ +
+
+
+
+ +
+

Wallet

+
+
+
+ +
@@ -228,11 +243,9 @@
-
-
-
+
Cancel
- - +
@@ -482,13 +494,12 @@ }, methods: { updatePaymentType(payment){ - this.paymentMethod = { name: payment.name, id: payment.id, status: false, } - + this.error = ''; }, selectOnlinePaymentBank(bankCode){ this.onlinePayment = { @@ -503,6 +514,13 @@ amount: this.amount }; + if (this.parameters.payment_method == 'wallet') { + if (!this.data.company.wallet.length || this.data.company.wallet[0].amount < this.parameters.amount) { + this.error = 'Insufficient wallet balance. Please Top up your wallet.'; + return; + } + } + this.submit(route('api.booking.payment.quotation', this.item.id), 'post', this.section, false, false) this.calculation = null; }, diff --git a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue index effcce53..d1e96c83 100644 --- a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue @@ -369,6 +369,7 @@
+
diff --git a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue index 81e17c37..23e3116f 100644 --- a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue @@ -8,30 +8,30 @@
-
-
+
+
-
- {{selectedSupplier.name}} +
+ {{selectedService.name}}
-
+
- +
-
+
-
-
+
+
-
{{supplier.name}}
+
{{service.name}}
@@ -41,7 +41,7 @@
-
+
@@ -75,11 +75,46 @@
+
+
+
+
+
+ {{selectedSupplier.name}} +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
{{supplier.name}}
+
+
+
+
+
+
+
+
+
+
- + @@ -124,6 +159,14 @@ currencyDropdownLaunch: { status: false }, + serviceDropdownLaunch: { + status: false + }, + selectedService: { + id: 1, + name: '', + status: false + }, payments: [] } }, @@ -135,6 +178,7 @@ this.suppliers = response.payload.data; this.updateSupplier(this.suppliers[0]); this.updateCurrency(this.suppliers[0].currencies[0]); + this.updateService(this.suppliers[0].services[0]); }, updateSupplier(supplier){ this.selectedSupplier = supplier; @@ -151,6 +195,10 @@ this.payments = []; }, + updateService(service){ + this.selectedService = service; + this.serviceDropdownLaunch.status = false; + }, updateOrder(payment){ this.payments.includes(payment) ? this.payments.splice(this.payments.indexOf(payment), 1) : this.payments.push(payment); } diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index 85502c97..50ecbacd 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -138,10 +138,10 @@
-
+
-
- +
+
diff --git a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue index 35b1d0a9..73099881 100644 --- a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue @@ -3,7 +3,7 @@
-
+
@@ -571,7 +571,7 @@
- +
diff --git a/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue b/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue new file mode 100644 index 00000000..2b5dda86 --- /dev/null +++ b/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue @@ -0,0 +1,141 @@ + + diff --git a/resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue b/resources/assets/vue/components/wallets/elements/WalletComponent.vue similarity index 80% rename from resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue rename to resources/assets/vue/components/wallets/elements/WalletComponent.vue index dd100288..6b553521 100644 --- a/resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue +++ b/resources/assets/vue/components/wallets/elements/WalletComponent.vue @@ -6,7 +6,7 @@
-
MYR 0.00
+
MYR {{ data.wallet.length > 0 ? (Math.round((data.wallet[0].amount + Number.EPSILON) * 100) / 100).toFixed(2) : '0.00'}}
@@ -14,23 +14,23 @@ Top Up
-
+
-
+
- Top Up + Top Up
-
- +
+ Redraw
@@ -42,32 +42,10 @@
- -
-
-
-
- - - - -
-
-
-
MYR
500
-
MYR
1000
-
MYR
3000
-
-
-
MYR
5000
-
MYR
10000
-
MYR
50000
-
-
-
-
Confirm
+
+
@@ -76,29 +54,20 @@ \ No newline at end of file diff --git a/resources/assets/vue/components/wallets/elements/WalletTopUpHistoryComponent.vue b/resources/assets/vue/components/wallets/elements/WalletTopUpHistoryComponent.vue new file mode 100644 index 00000000..ff392682 --- /dev/null +++ b/resources/assets/vue/components/wallets/elements/WalletTopUpHistoryComponent.vue @@ -0,0 +1,75 @@ + + + diff --git a/resources/assets/vue/components/wallets/elements/WalletsComponent.vue b/resources/assets/vue/components/wallets/elements/WalletsComponent.vue new file mode 100644 index 00000000..8f0daa9c --- /dev/null +++ b/resources/assets/vue/components/wallets/elements/WalletsComponent.vue @@ -0,0 +1,178 @@ + + + diff --git a/resources/assets/vue/components/wallets/forms/WalletTopUpFormComponent.vue b/resources/assets/vue/components/wallets/forms/WalletTopUpFormComponent.vue new file mode 100644 index 00000000..383b3c43 --- /dev/null +++ b/resources/assets/vue/components/wallets/forms/WalletTopUpFormComponent.vue @@ -0,0 +1,82 @@ + + + \ No newline at end of file diff --git a/resources/views/pages/wallet/transactions.blade.php b/resources/views/pages/wallet/transactions.blade.php index 8fcb3a8a..ce31dec6 100644 --- a/resources/views/pages/wallet/transactions.blade.php +++ b/resources/views/pages/wallet/transactions.blade.php @@ -1,121 +1,5 @@
-
-
-
-
Transaction History
-
-
- -
-
Date
-
Description
-
Incoming
-
Outgoing
-
Balance
-
- -
-
25/11/2015
-
Payment to bill #121221121
-
-
2,123
-
12,123
-
- -
-
115/11/2015
-
Top Up
-
1,234
-
-
14,246
-
-
-
- -
-
-
-
-
Top Up Records
-
-
- - -
-
-
-
-
-
-
-
-
-
Payment Method Success
-
-
-

$123,123

-
-
-
-
- 12-03-2021 -
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
Payment Method Failed
-
-
-

$123,123

-
-
-
-
- 12-03-2021 -
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
Payment Method Processing
-
-
-

$123,123

-
-
-
-
- 12-03-2021 -
-
-
-
-
-
-
-
+
+
\ No newline at end of file diff --git a/resources/views/pages/wallet/wallets.blade.php b/resources/views/pages/wallet/wallets.blade.php new file mode 100644 index 00000000..1a876a4f --- /dev/null +++ b/resources/views/pages/wallet/wallets.blade.php @@ -0,0 +1,54 @@ + +@extends('layouts.base_portal') +@section('inner_content') +
+
+ +
+
+
+
+
Transaction History
+
+
+ +
+
Date
+
Description
+
Incoming
+
Outgoing
+
Balance
+
+ +
+
25/11/2015
+
Payment to bill #121221121
+
+
- 2,123
+
12,123
+
+ +
+
115/11/2015
+
Top Up
+
1,234
+
+
14,246
+
+
+
+
+
+
+
+
Top Up Records
+
+
+ +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/partials/header.blade.php b/resources/views/partials/header.blade.php index c8535af9..edd7c858 100644 --- a/resources/views/partials/header.blade.php +++ b/resources/views/partials/header.blade.php @@ -48,6 +48,11 @@
customers
+ @@ -64,14 +69,6 @@
-
-
-
-
MYR 0.00
-
- -
-
diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 727a1fe4..40d5ff80 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -1,6 +1,6 @@
-
+
diff --git a/routes/wallet.php b/routes/wallet.php index 7ad2a479..80290c52 100644 --- a/routes/wallet.php +++ b/routes/wallet.php @@ -5,8 +5,10 @@ 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'); - Route::post('/withdraw', 'WithdrawWalletController@withdraw')->name('withdraw'); - Route::put('/{transaction_id}/update-status/{status}', 'UpdateStatusWalletController@updateStatus')->where('status', 'approve|reject')->name('approval'); + Route::post('/topup', 'TopUpWalletController@topUp')->name('topup'); // user + Route::post('/debit', 'DebitWalletController@debit')->name('debit'); //admin - + Route::post('/credit', 'CreditWalletController@credit')->name('credit'); // admin + + + Route::put('/{transaction_id}/update-status/{status}', 'UpdateStatusWalletController@updateStatus')->where('status', 'approve|reject')->name('approval'); }); diff --git a/routes/web.php b/routes/web.php index b521f08b..77026a89 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,8 +1,11 @@ name('booking.merge'); Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); -Route::get('/wallet-transactions', function () { - return view('pages.wallet.index'); -})->name('wallet.transactions'); + +Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); +Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); + +Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) { + return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']); +})->name('products.random'); + + +//Route::get('/duplicated_bills', function (Request $request) { +// Auth()->login(User::find(1)); +// $bookings = Booking::whereIn('id', [10391, 10275, 10109, 10108, 10070, 10066, 10063, 9801, 9166, 8895, 8790, 8544, 8264, 6957, 5409, 4717])->with('transactions')->pluck('marking'); +// dd($bookings); +// +//})->name('x2.data'); +Route::get('/wallet/{id}/details', function ($id) { + return view('pages.wallet.index', ['id' => $id]); +})->name('wallet.details'); + +Route::get('/wallets', function () { + return view('pages.wallet.wallets'); +})->name('wallet.wallets'); Route::get('/test', function(){ @@ -121,4 +143,4 @@ Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsP return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']); })->name('products.random'); -Route::get('/auto-purchase-order-fill', 'Bookings\AutoPurchaseOrderFillController@auto')->name('assign'); \ No newline at end of file +Route::get('/auto-purchase-order-fill', 'Bookings\AutoPurchaseOrderFillController@auto')->name('assign');