diff --git a/.env.example b/.env.example index f3d4fd56..544ed6cc 100644 --- a/.env.example +++ b/.env.example @@ -53,6 +53,7 @@ JWT_TTL=1440 IS_PRODUCTION=false BILLPLZ_BASE_URL="https://www.billplz-sandbox.com" -BILLPLZ_API_KEY="0fa4c710-761b-4a7a-a501-c2c2d02643d5" -BILLPLZ_X_SIGNATURE_KEY="S-pbNVthVRsvnPfZlgLwqqOg" -BILLPLZ_COLLECTION_ID="hev2wdjy" +BILLPLZ_API_KEY="d25c6170-dc00-45cd-b226-d702b957870c" +BILLPLZ_X_SIGNATURE_KEY="S-HdAU6QDubUrMErxJ-PCpgw" +BILLPLZ_COLLECTION_ID="t0cggbdd" +BILLPLZ_WALLET_COLLECTION_ID="t0cggbdd" diff --git a/.gitignore b/.gitignore index 95d268cf..476bf6a0 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ db/* docker-compose.yml package-lock.json public/* -/public/* \ No newline at end of file +/public/* +/storage/app/public +public +/storage/framework/laravel-excel diff --git a/app/Classes/General/Eloquent/AbstractFetchRecord.php b/app/Classes/General/Eloquent/AbstractFetchRecord.php index 1fbd39da..248deee7 100644 --- a/app/Classes/General/Eloquent/AbstractFetchRecord.php +++ b/app/Classes/General/Eloquent/AbstractFetchRecord.php @@ -6,6 +6,7 @@ namespace App\Classes\General\Eloquent; use App\Classes\Exceptions\ResourceNotFoundException; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +use Psy\Exception\ErrorException; abstract class AbstractFetchRecord extends AbstractGetRecord { diff --git a/app/Classes/General/Eloquent/Filters/Frequency.php b/app/Classes/General/Eloquent/Filters/Frequency.php new file mode 100644 index 00000000..3eb74340 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/Frequency.php @@ -0,0 +1,19 @@ +whereHas('bookings', function ($query){}, '>=', $value); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/Monetary.php b/app/Classes/General/Eloquent/Filters/Monetary.php new file mode 100644 index 00000000..5c91b248 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/Monetary.php @@ -0,0 +1,25 @@ +whereHas('transactions', function ($query) use ($value){ + $query->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + $query->havingRaw('SUM(amount) >= ' . $value); + }); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/OwnerType.php b/app/Classes/General/Eloquent/Filters/OwnerType.php new file mode 100644 index 00000000..6a13fb08 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/OwnerType.php @@ -0,0 +1,20 @@ +where('owner_type', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/PaymentMethodNotIn.php b/app/Classes/General/Eloquent/Filters/PaymentMethodNotIn.php new file mode 100644 index 00000000..239bb8df --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/PaymentMethodNotIn.php @@ -0,0 +1,20 @@ +whereNotIn('payment_method', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/Recency.php b/app/Classes/General/Eloquent/Filters/Recency.php new file mode 100644 index 00000000..75e9ea34 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/Recency.php @@ -0,0 +1,22 @@ +where('transactions.created_at', '>=', $value); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/ServiceCharge.php b/app/Classes/General/Eloquent/Filters/ServiceCharge.php new file mode 100644 index 00000000..de8cdded --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/ServiceCharge.php @@ -0,0 +1,21 @@ +where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/TransactionServiceId.php b/app/Classes/General/Eloquent/Filters/TransactionServiceId.php new file mode 100644 index 00000000..fa0cdba5 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/TransactionServiceId.php @@ -0,0 +1,23 @@ +where('owner_type', Booking::class)->whereHas('booking', function ($query) use($value) { + $query->where('service_id', $value); + }); + } + +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/WithOwner.php b/app/Classes/General/Eloquent/Filters/WithOwner.php new file mode 100644 index 00000000..7d31691e --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithOwner.php @@ -0,0 +1,20 @@ +with('owner'); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/WithTotalPayments.php b/app/Classes/General/Eloquent/Filters/WithTotalPayments.php index 9721f8d7..015221fd 100644 --- a/app/Classes/General/Eloquent/Filters/WithTotalPayments.php +++ b/app/Classes/General/Eloquent/Filters/WithTotalPayments.php @@ -19,8 +19,18 @@ class WithTotalPayments implements Filter */ public static function apply(Builder $builder, $value) { - return $builder->leftJoin('bookings', 'companies.id', '=', 'bookings.company_id')->rightJoin('transactions', function ($join) { - $join->on('bookings.id', '=', 'transactions.owner_id')->where('owner_type', '=', Booking::class)->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - })->addSelect(['companies.*', DB::raw('SUM(transactions.amount) as total_payments'), DB::raw('SUM(transactions.amount / DATEDIFF(companies.created_at, CURRENT_DATE)) as spending_average_per_day'), DB::raw('SUM(transactions.amount) / count(distinct bookings.id) as spending_average_booking')])->groupBy(['companies.id']); + return $builder->leftJoin('bookings', 'companies.id', '=', 'bookings.company_id') + ->rightJoin('transactions', function ($join) { + $join->on('bookings.id', '=', 'transactions.owner_id') + ->where('owner_type', '=', Booking::class) + ->where('transactions.type', TransactionType::PAYMENT) + ->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + })->addSelect([ + 'companies.*', + DB::raw('SUM(transactions.amount) as total_payments'), + DB::raw('SUM(transactions.amount / DATEDIFF(companies.created_at, CURRENT_DATE)) as spending_average_per_day'), + DB::raw('SUM(transactions.amount) / count(distinct bookings.id) as spending_average_booking') + ]) + ->groupBy(['companies.id']); } } \ No newline at end of file diff --git a/app/Classes/General/ExcelHandel.php b/app/Classes/General/ExcelHandel.php new file mode 100644 index 00000000..3060ed8b --- /dev/null +++ b/app/Classes/General/ExcelHandel.php @@ -0,0 +1,87 @@ +makeDirectory($path); + return $folder; + } + + public static function insertExcel($path = '', $base64Set = []) + { + $file_info = []; + $folder_path = ExcelHandel::generateFolder('excels/' . $path); + + foreach ($base64Set as $key => $row) { + + $exceldata = $row; + $filename = (string) Str::uuid(); + + $f = finfo_open(); + $mime_type = finfo_file($f, $exceldata, FILEINFO_MIME_TYPE); + + $extension = 'xls'; + + switch ($mime_type) { + case 'application/vnd.ms-excel': + $extension = 'xls'; + break; + case 'application/zip': + $extension = 'xlsx'; + break; + } + + if (empty($extension)) { + return false; + } + + $exceldata = explode('base64,', $exceldata); + $exceldata = base64_decode($exceldata[1]); + + $filename_with_ext = $filename . '.' . $extension; + + $file = ExcelHandel::generateExcel($path, $exceldata, $filename, $extension); + + $file_info[] = [ + 'path' => $path, + 'filename' => $filename_with_ext, + 'mime_type' => $mime_type, + 'extension' => $extension, + 'file_info' => empty($file) ? [] : $file, + ]; + } + + return $file_info; + } + + public static function generateExcel($path = '', $exceldata = '', $filename = '', $extension = '') + { + $file_info = []; + $file = \Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata); + $file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension); + + return $file_info; + } + + public static function removeExcel($excel_info = []) + { + $excel_info = json_decode(json_encode($excel_info), true); + foreach ($excel_info as $key => $row) { + if (!empty($row['path'])) { + \File::delete([$row['file_info']['original']['file']]); + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Banks/ControllersLogic/UpdateBankLogic.php b/app/Classes/Modules/Banks/ControllersLogic/UpdateBankLogic.php index 85e3449c..9cb8fdd2 100644 --- a/app/Classes/Modules/Banks/ControllersLogic/UpdateBankLogic.php +++ b/app/Classes/Modules/Banks/ControllersLogic/UpdateBankLogic.php @@ -39,7 +39,6 @@ class UpdateBankLogic extends AbstractControllerLogic /** @var FetchesBank */ private $fetchesBank; - /** * UpdateBankLogic constructor. * @param CanUpdateBank $canUpdateBank @@ -66,11 +65,18 @@ class UpdateBankLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - - $bankObject = new BankObject($request->input('company_id'), $request->input('country_id'), - $request->input('reference'), $request->input('bank_name'), $request->input('holder_name'), - $request->input('account_no')); - + $bankObject = new BankObject( + $request->input('company_id'), + $request->input('account_type'), + $request->input('bank_name'), + $request->input('holder_name'), + $request->input('account_no'), + $request->input('bank_branch'), + $request->input('swift'), + $request->input('snap'), + $request->input('country_id'), + $request->input('reference') + ); $bank = $this->fetchesBank->execute(['id' => $request->route('id')]); diff --git a/app/Classes/Modules/Banks/ControllersLogic/UpdateBankStatusLogic.php b/app/Classes/Modules/Banks/ControllersLogic/UpdateBankStatusLogic.php new file mode 100644 index 00000000..09ee2796 --- /dev/null +++ b/app/Classes/Modules/Banks/ControllersLogic/UpdateBankStatusLogic.php @@ -0,0 +1,62 @@ + 'Update Bank Account Status', + 'message' => 'You have successfully updated the Bank Account Status' + ]; + } + + /** @var FetchesBank */ + private $fetchesBank; + + /** @var UpdatesBankStatus */ + private $updatesBankStatus; + + /** + * UpdateBankStatusLogic constructor. + * @param FetchesBank $fetchesBank + * @param UpdatesBankStatus $updatesBankStatus + */ + public function __construct( + FetchesBank $fetchesBank, + UpdatesBankStatus $updatesBankStatus + ) + { + $this->fetchesBank = $fetchesBank; + $this->updatesBankStatus = $updatesBankStatus; + } + + /** + * @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 + { + $bank = $this->fetchesBank->execute(['id' => $request->route('id')]); + + $bank_query = $this->updatesBankStatus->execute($bank, $request->input('status')); + + return $this->resourceResponse(new BankResource($bank_query)); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Banks/Services/UpdatesBank.php b/app/Classes/Modules/Banks/Services/UpdatesBank.php index 6367a6aa..69e8347a 100644 --- a/app/Classes/Modules/Banks/Services/UpdatesBank.php +++ b/app/Classes/Modules/Banks/Services/UpdatesBank.php @@ -23,7 +23,7 @@ class UpdatesBank extends AbstractUpdateRecord $model->bank_branch = $object->getBankBranch(); $model->swift = $object->getSwift(); $model->snap = $object->getSnap(); - $model->default = $object->getDefault(); + $model->reference = $object->getReference(); return $this->handler($model); } diff --git a/app/Classes/Modules/Banks/Services/UpdatesBankStatus.php b/app/Classes/Modules/Banks/Services/UpdatesBankStatus.php new file mode 100644 index 00000000..c080ad56 --- /dev/null +++ b/app/Classes/Modules/Banks/Services/UpdatesBankStatus.php @@ -0,0 +1,22 @@ +status = $status; + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php index 7501bfd1..2230343f 100644 --- a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php @@ -2,10 +2,15 @@ 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\Classes\Modules\Wallets\Services\UpdatesWalletBalance; use App\Http\Resources\TransactionResource; +use App\Models\Booking; use App\Models\User; +use App\Models\Wallet; use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; @@ -32,18 +37,22 @@ class CallbackBillplzLogic /** @var UpdatesTransactionStatus */ private $updatesTransactionStatus; + /** @var UpdatesWalletBalance */ + private $updatesWalletBalance; /** - * CreateBookingLogic constructor. + * CallbackBillplzLogic constructor. * @param GetBillplzBill $getBillplzBill * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus + * @param UpdatesWalletBalance $updatesWalletBalance */ - public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus) + public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWalletBalance $updatesWalletBalance) { $this->getBillplzBill = $getBillplzBill; $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->updatesWalletBalance = $updatesWalletBalance; } @@ -55,7 +64,6 @@ class CallbackBillplzLogic */ public function execute(Request $request) { - $billplzXSignatureObject = new BillplzXSignatureObject($request); if(!$billplzXSignatureObject->isValidSignature()){ @@ -76,12 +84,22 @@ class CallbackBillplzLogic $status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION; } - $this->updatesTransactionStatus->execute($transaction, $status); + if($transaction->status !== ApprovalStatus::COMPLETED){ + + if($transaction->owner instanceof Wallet && $transaction->status !== ApprovalStatus::APPROVED && $status === ApprovalStatus::APPROVED) { + $this->updatesWalletBalance->execute($transaction->owner, $transaction->amount); + } + $this->updatesTransactionStatus->execute($transaction, $status); + + } + $token = Auth::fromUser(User::find(1)); $request->headers->set('Authorization', 'Bearer '.$token); - return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $transaction->booking->marking, 'payment_reference' => $transaction->payment_reference, 'status' => $status, 'amount' => $transaction->amount]); + $marking = $transaction->owner instanceof Booking ? $transaction->booking->marking : $transaction->owner->owner->bookings()->orderBy('id', 'DESC')->first()->marking; + + return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $marking, 'transaction' => $transaction, 'status' => $status]); } } \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index ef3b5f4e..5b331fca 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -15,14 +15,15 @@ class CreatesBillplzBill * @param float $amount * @param string $billNumber * @param null|string $bankCode + * @param null|Boolean $wallet * @return null|object * @throws MalformedRequestException */ - public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null) { + public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) { try{ // config('billplz.maybank') $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ - 'collection_id' => config('billplz.collection_id'), + 'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'), 'name' => $name, 'email' => $email, 'description' => $description, diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php new file mode 100644 index 00000000..73751cfb --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -0,0 +1,114 @@ +generatesPurchaseOrderProducts = $generatesPurchaseOrderProducts; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->createPurchaseOrderTransactionProcessor = $createPurchaseOrderTransactionProcessor; + } + + + /** + * @return array + */ + protected function notification():array { + return [ + 'title' => 'Purchase Order Approval', + 'message' => 'You have successfully updated the Purchase order status' + ]; + } + + /** @var GeneratesPurchaseOrderProducts */ + private $generatesPurchaseOrderProducts; + + /** @var GeneratesTransactionBillNumber */ + private $generatesTransactionBillNumber; + + /** @var CreatePurchaseOrderTransactionProcessor */ + private $createPurchaseOrderTransactionProcessor; + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $bookings = Booking::where(function($query){ + return $query->whereMonth('created_at', 11)->orWhereMonth('created_at', 12); + })->whereDoesntHave('transactions', function($q){ + $q->where('type', TransactionType::PURCHASE_ORDER); + $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); + })->get(); + + foreach ($bookings as $booking) { + $po = Transaction::where('type', TransactionType::PURCHASE_ORDER) + ->where('status', ApprovalStatus::APPROVED)->where('issuer', $booking->company_id) + ->select('*', DB::raw('abs(amount - ' . $booking->fix_amount . ') as nearest_price'))->orderBy('nearest_price')->first(); + + + if (!$po) { + $po = Transaction::where('type', TransactionType::PURCHASE_ORDER) + ->where('status', ApprovalStatus::APPROVED)->select('*', DB::raw('abs(amount - ' . $booking->fix_amount . ') as nearest_price'))->orderBy('nearest_price')->first(); + } + + $products = $this->generatesPurchaseOrderProducts->execute($po, $booking->fix_amount); + + $deference = $booking->fix_amount - $products->sum('total'); + + if($deference > -150 && $deference < 150 && $deference != 0) { + + $products->push([ + 'description' => $deference < 0 ? 'Discount':'Shipping Fee', + 'quantity' => 1, + 'stockCode' => '', + 'total' => $deference, + 'unit_price' => $deference + ]); + } + + $billNumber = $this->generatesTransactionBillNumber->execute('XPO-'); + + $total = $products->sum('total'); + + $object = new TransactionObject($billNumber, TransactionType::PURCHASE_ORDER, $booking->company->id, 1, + 1, PaymentMethodType::CASH, + $total, $total, $booking->fix_currency_id, $booking->fix_currency_id, + 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, $products->toArray()); + + $this->createPurchaseOrderTransactionProcessor->execute($booking, $object); + } + + return $this->response([]); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php index a16be8d2..ecb6a87c 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php @@ -14,11 +14,15 @@ use App\Classes\Modules\Transactions\Services\CreatesTransaction; use App\Classes\Modules\Transactions\Services\UpdatesTransaction; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill; +use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; +use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\ValueObjects\Constants\TransactionType; use App\Http\Resources\TransactionResource; use App\Models\Booking; +use App\Models\Transaction; +use App\Models\Wallet; use Carbon\Carbon; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -48,15 +52,18 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic /** @var CreatesTransaction */ private $createsTransaction; - /** @var UpdatesTransaction */ - private $updatesTransaction; - /** @var CalculatesBookingOutstanding */ private $calculatesBookingOutstanding; /** @var CreatesBillplzBill */ private $createsBillplzBill; + /** @var UpdatesWalletBalance */ + private $updatesWalletBalance; + + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + /** * CreateBookingPaymentLogic constructor. * @param FetchesBookingQuotation $fetchBookingQuotation @@ -65,16 +72,19 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic * @param CreatesTransaction $createsTransaction * @param CalculatesBookingOutstanding $calculatesBookingOutstanding * @param CreatesBillplzBill $createsBillplzBill + * @param UpdatesWalletBalance $updatesWalletBalance + * @param UpdatesTransactionStatus $updatesTransactionStatus */ - public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, UpdatesTransaction $updatesTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill) + public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill, UpdatesWalletBalance $updatesWalletBalance, UpdatesTransactionStatus $updatesTransactionStatus) { $this->fetchBookingQuotation = $fetchBookingQuotation; $this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createsTransaction = $createsTransaction; - $this->updatesTransaction = $updatesTransaction; $this->calculatesBookingOutstanding = $calculatesBookingOutstanding; $this->createsBillplzBill = $createsBillplzBill; + $this->updatesWalletBalance = $updatesWalletBalance; + $this->updatesTransactionStatus = $updatesTransactionStatus; } /** @@ -98,18 +108,47 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); + $paymentReference = null; + + $amount = $configurations->getTotal(); + if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){ $billPlzBill = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, 'This payment is made for transfer ref. '.$booking->marking, $configurations->getTotal(), $billNumber, $request->input('bank_code')); + $paymentReference = $billPlzBill->id; } + if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::WALLET){ + /** @var Wallet $wallet */ + $wallet = $booking->company->wallets()->first(); + + if(round($wallet->amount) < round($amount, 2)){ + throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.'); + } + + $transaction_object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], ''); + $this->createsTransaction->execute($wallet, $transaction_object); + + $paymentReference = $billNumber; + + $this->updatesWalletBalance->execute($wallet, ($amount * -1)); + + } + + $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); + $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), $configurations->getTotal(), $configurations->getForeignTotal(), 1, $configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(), - $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], isset($billPlzBill) ? $billPlzBill->id : NULL); + $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], $paymentReference); + /** @var Transaction $transaction */ $transaction = $this->createsTransaction->execute($booking, $object); + if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::WALLET){ + $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); + } + return $this->resourceResponse(new TransactionResource($transaction)); } diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 411b9163..74e92fa6 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -78,31 +78,27 @@ class CreateBookingRefundLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { - $booking = Booking::find($request->route('id')); - $transaction = $this->fetchesTransaction->execute(['id' => $request->route('payment_id')]); + $booking = $transaction->owner; + $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); - if((int) $transaction->type === TransactionType::BILL){ - $customerBooking = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first(); - } - $refund = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id, $transaction->bill_no); - dd($refund); + $refund = $transaction->transactions()->refunds()->sum('amount'); if($refund + $request->input('amount') > $transaction->original_amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); - $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, (int) $transaction->type === TransactionType::BILL ? $customerBooking : $transaction, $request->input('amount')); + $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount')); $transactionRefundCalculationObject->init(); $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, - $request->input('bank_id'),$transactionRefundCalculationObject->getConversionObject()->getPaymentMethod(), + 1, $transactionRefundCalculationObject->getConversionObject()->getPaymentMethod(), $transactionRefundCalculationObject->getRefundTotalAmount(), $transactionRefundCalculationObject->getAmount(), 1, $transactionRefundCalculationObject->getConversionObject()->getCurrencyId(), $transactionRefundCalculationObject->getTransaction()->currency_rate, $transactionRefundCalculationObject->getRefundTax(), $transactionRefundCalculationObject->getRefundServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no); - $transaction = $this->createsTransaction->execute($booking, $object); + $transaction = $this->createsTransaction->execute($transaction, $object); return $this->resourceResponse(new TransactionResource($transaction)); } diff --git a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php new file mode 100644 index 00000000..d8fdb0df --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php @@ -0,0 +1,78 @@ +input('type').'.zip'; + $attachment = storage_path().'/app/documents/collections/' . $zip_file; + + $zip = new ZipArchive(); + if ($zip->open($attachment, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE)) { + + $bookings = Booking::where('status', ApprovalStatus::COMPLETED) + ->whereDate('created_at', '>=', Carbon::parse($request->input('startDate'))) + ->whereDate('created_at', '<=', Carbon::parse($request->input('endDate')))->whereHas('transactions', function ($query) use ($request){ + return $query->where('type', TransactionType::PAYMENT)->whereHas('transactions', function ($query) use ($request){ + return $query->where('type', TransactionType::BILL)->where('issuer', $request->input('supplier')); + }); + })->get(); + + if (!count($bookings)) throw new MalformedRequestException('No available file to download'); + + foreach ($bookings as $booking) { + $file = $booking->documents()->where('document_type', $request->input('type'))->first()->files()->first(); + $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf'); + } + + $zip->close(); + while (ob_get_level()) { + ob_end_clean(); + } + ob_start(); + header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK'); + header("Content-Type: application/zip"); + header("Content-Transfer-Encoding: Binary"); + header("Content-Length: " . filesize($attachment)); + header('Pragma: no-cache'); + header("Content-Disposition: attachment; filename=\"" . basename($attachment) . "\""); + ob_flush(); + ob_clean(); + + readfile($attachment); + File::delete($attachment); + + exit; + +// header('Content-Type: application/zip'); +// header('Content-Length: ' . filesize($attachment)); +// readfile($attachment); +// unlink($attachment); + + } + } +} diff --git a/app/Classes/Modules/Bookings/ControllersLogic/FetchBookingPaymentQuotationLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/FetchBookingPaymentQuotationLogic.php index 5885d560..eaac0adc 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/FetchBookingPaymentQuotationLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/FetchBookingPaymentQuotationLogic.php @@ -72,7 +72,8 @@ class FetchBookingPaymentQuotationLogic extends AbstractControllerLogic return $this->response(['data' => $this->generatesBookingQuotation->execute( $this->fetchBookingQuotation->execute($booking->company, $conversionObject), - $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company) + $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company), + $conversionObject )]); } 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/Services/CalculatesBookingCurrencyAverageRate.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php index 2a6de8d2..da3fe0b4 100644 --- a/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php +++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingCurrencyAverageRate.php @@ -31,7 +31,7 @@ class CalculatesBookingCurrencyAverageRate } else if ($type == TransactionType::BILL) { - return $booking->transactions()->bills()->complete()->sum('original_amount') / $booking->transactions()->bills()->complete()->sum('amount'); + return $booking->bills->sum('original_amount') / $booking->bills->sum('amount'); } } diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php index 57a5525c..fc355d64 100644 --- a/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php +++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingTransferredAmount.php @@ -12,7 +12,9 @@ class CalculatesBookingTransferredAmount { public function execute(Booking $booking){ - return $booking->transactions()->bills()->complete()->sum('original_amount'); + return $booking->transactions()->payments()->complete()->whereHas('transactions', function($query){ + return $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + })->sum('original_amount'); } } \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php b/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php index 8f40187b..6fe93c97 100644 --- a/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php +++ b/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Bookings\Services; use App\Classes\Modules\Bookings\DataTransferObjects\CalculationObject; +use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject; use App\Http\Resources\BankResource; use App\Models\Bank; use Carbon\Carbon; @@ -12,12 +13,14 @@ use Carbon\CarbonInterval; class GeneratesBookingQuotation { - public function execute(CalculationObject $calculationObject, ?int $paymentAttemptLimit = 0){ + public function execute(CalculationObject $calculationObject, ?int $paymentAttemptLimit = 0, ?CurrencyConversionObject $currencyConversionObject = null){ $date = Carbon::now(); $days = $date->diffInDays($date->copy()->addMinutes($paymentAttemptLimit)); $hours = $date->diffInHours($date->copy()->addMinutes($paymentAttemptLimit)->subDays($days)) ; $minutes = $date->diffInMinutes($date->copy()->addMinutes($paymentAttemptLimit)->subDays($days)->subHours($hours)); + $receive_date = $currencyConversionObject ? Carbon::now()->endOfDay()->addWeekdays($currencyConversionObject->getServiceId() === 3 ? 3 : 1)->timezone('Asia/Singapore')->format('4:00 \P\M, jS M, Y \G\M\T T') : null; + return [ 'bank' => new BankResource(Bank::find($calculationObject->getConfigurations()->getBankId())), 'rate' => $calculationObject->getConfigurations()->getRate(), @@ -30,6 +33,7 @@ class GeneratesBookingQuotation 'sub_total' => $calculationObject->getSubTotal(), 'total' => $calculationObject->getTotal(), 'date' => Carbon::now()->timezone('Asia/Singapore')->format('h:i a, jS M, Y \G\M\T T'), + 'receive_date' => $receive_date, 'payment_attempt_limit' => CarbonInterval::days($days)->hours($hours)->minutes($minutes)->forHumans() ]; } diff --git a/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyBookingQuotationLogic.php b/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyBookingQuotationLogic.php index 37225631..926acaae 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyBookingQuotationLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyBookingQuotationLogic.php @@ -14,6 +14,7 @@ use App\Models\Company; use App\Models\Currency; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Carbon\Carbon; class FetchCompanyBookingQuotationLogic extends AbstractControllerLogic { @@ -71,7 +72,7 @@ class FetchCompanyBookingQuotationLogic extends AbstractControllerLogic if($calculationObject->getConvertibleTotal() < $calculationObject->getConfigurations()->getMinLimit()) throw new RequestValidationException('Your transfer is below the minimum amount allowed of '.$calculationObject->getConfigurations()->getMinLimit().' '.$currency->short_code); //TODO add po limit validation - return $this->response(['data' => $this->generatesBookingQuotation->execute($calculationObject)]); + return $this->response(['data' => $this->generatesBookingQuotation->execute($calculationObject, 0, $conversionObject)]); } diff --git a/app/Classes/Modules/Companies/ControllersLogic/ListCompaniesLogic.php b/app/Classes/Modules/Companies/ControllersLogic/ListCompaniesLogic.php index 80b15c1c..8e19c737 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/ListCompaniesLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/ListCompaniesLogic.php @@ -53,9 +53,12 @@ class ListCompaniesLogic extends AbstractControllerLogic { $this->canListCompanies->passes(); + // dd($request->input('filters')); + // frequency = active bookings + // monetary = total spending/payment $query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters'))); + + // dd($query); return $this->collectionResponse(CompanyResource::collection($query)); - } - } \ No newline at end of file diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDebtorLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDebtorLogic.php new file mode 100644 index 00000000..49938efd --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDebtorLogic.php @@ -0,0 +1,66 @@ + 'Updated Company', + 'message' => 'You have successfully updated the Company' + ]; + } + + /** @var CanUpdateCompany */ + private $canUpdateCompany; + + /** @var UpdatesCompanyDebtor */ + private $updatesCompanyDebtor; + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** + * UpdateCompanyControllersLogic constructor. + * @param CanUpdateCompany $canUpdateCompany + * @param UpdatesCompanyDebtor $updatesCompanyDebtor + * @param FetchesCompany $fetchesCompany + */ + public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompanyDebtor $updatesCompanyDebtor, FetchesCompany $fetchesCompany) + { + $this->canUpdateCompany = $canUpdateCompany; + $this->updatesCompanyDebtor = $updatesCompanyDebtor; + $this->fetchesCompany = $fetchesCompany; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $debtor = $request->input('debtor'); + + $query = $this->fetchesCompany->execute(['id' => $request->route('id')]); + + $query = $this->updatesCompanyDebtor->execute($query, $debtor); + + return $this->resourceResponse(new CompanyResource($query)); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompanyDebtor.php b/app/Classes/Modules/Companies/Services/UpdatesCompanyDebtor.php new file mode 100644 index 00000000..4cb43a9f --- /dev/null +++ b/app/Classes/Modules/Companies/Services/UpdatesCompanyDebtor.php @@ -0,0 +1,23 @@ +debtor = $debtor; + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php b/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php index ed289eac..736853fc 100644 --- a/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php +++ b/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php @@ -28,7 +28,7 @@ class FileObject implements DataTransferObject */ public function getData() { - return $this->getExtension() === 'pdf' ? $this->data : (new imageManager())->make($this->data); + return in_array($this->getExtension(), ['pdf', 'excel']) ? $this->data : (new imageManager())->make($this->data); } /** @@ -66,7 +66,7 @@ class FileObject implements DataTransferObject */ public function getDecodedData(): string { - return $this->getExtension() === 'pdf' ? + return in_array($this->getExtension(), ['pdf', 'excel']) ? base64_decode((explode('base64,', $this->getData()))[1]): $this->getData()->encode('data-url')->encoded; } diff --git a/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php b/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php index a7a5c8b6..8741b823 100644 --- a/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php +++ b/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php @@ -36,7 +36,7 @@ class ConvertsBase64ToFile foreach ($files as $file) { $object = new FileObject($file); - $object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object); + in_array($object->getExtension(), ['pdf', 'excel']) ? $this->generatePDF($object) : $this->generateImage($object); } diff --git a/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php b/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php new file mode 100644 index 00000000..be216473 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php @@ -0,0 +1,97 @@ +whereNull('debtor')->orWhere('debtor', ''); + })->whereNotIn('id', [2207, 2248, 2029])->where('business_type', BusinessType::IMPORTER)->where('status', ApprovalStatus::APPROVED)->whereHas('transactions', function($query){ + return $query->whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP])->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::PENDING_VERIFICATION]); + }); + } + + /** + * @param Company $company + * + * @return array + */ + public function map($company): array + { + return [ + '<>', + '300-0000', + '300-0000', + '300-0000', + $company->name.' (PURCHASE)', + $company->reference, + '', + 'PIA', + 'MYR', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '',//EmailAddress + '', + '', + '', + '' + ]; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php new file mode 100644 index 00000000..0ca1d730 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php @@ -0,0 +1,106 @@ +request = $request; + } + + public function headings(): array + { + return [ + 'DocNo', + 'DocDate', + 'DebtorCode', + 'DebtorName', + 'CurrencyCode', + 'ShipInfo', + 'ItemCode', + 'DetailDescription', + 'Qty', + 'UnitPrice', + 'AccNo' + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $start_date = $this->request->input('start_date', null); + if ($start_date) { + $start_date = Carbon::parse($this->request->input('start_date'))->format('Y-m-d'); + } + + $end_date = $this->request->input('end_date', null); + if ($end_date) { + $end_date = Carbon::parse($this->request->input('end_date'))->format('Y-m-d'); + } + + $query = Transaction::query(); + + $query->where('type', TransactionType::PAYMENT)->where('payment_method', '!=', PaymentMethodType::WALLET); + $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + + if($start_date && $end_date) { + $query->whereBetween('created_at', [ + Carbon::parse($start_date)->format('Y-m-d 0:00:00'), + Carbon::parse($end_date)->format('Y-m-d 23:59:59') + ]); + } + elseif($start_date && !$end_date) { + $query->where('created_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00')); + } + elseif(!$start_date && $end_date) { + $query->where('created_at', '<=', Carbon::parse($end_date)->format('Y-m-d 23:59:59')); + } + + return $query; + } + + /** + * @param Company $transaction + * + * @return array + */ + public function map($transaction): array + { + $booking = $transaction->owner()->first(); + $company = $booking->company()->first(); + + return [ + '<>', + $transaction->updated_at->format('d/m/Y'), + $company->debtor, + '', + 'MYR', + $booking->marking, + '', + 'PLEASE REFER TO THE ATTACHED APPENDIX REF ' . $booking->marking, + 1, + $transaction->amount, + '500-0000' + ]; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Exports/Services/ExportsProducts.php b/app/Classes/Modules/Exports/Services/ExportsProducts.php new file mode 100644 index 00000000..541f1d21 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsProducts.php @@ -0,0 +1,51 @@ +whereHas('transaction', function($query){ + return $query->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->where('status', ApprovalStatus::APPROVED); + })->limit(50); + } + + /** + * @param $product + * @return array + */ + public function map($product): array + { + + return [ + $product->product_code, + $product->product_name, + $product->price, + ]; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Exports/Services/ExportsTransactions.php b/app/Classes/Modules/Exports/Services/ExportsTransactions.php index a49d1f85..f9bbecaf 100644 --- a/app/Classes/Modules/Exports/Services/ExportsTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsTransactions.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Exports\Services; use App\Classes\ValueObjects\Constants\BusinessType; use App\Classes\ValueObjects\Constants\CompanyType; +use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\Company; use App\Models\Transaction; use Maatwebsite\Excel\Concerns\Exportable; @@ -41,6 +42,10 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping 6 => 'REFUND', 7 => 'PURCHASE_ORDER', 8 => 'SUPPLIER_DELIVER', + 9 => 'CREDIT_NOTE', + 10 => 'WITHDRAW', + 11 => 'DEBIT_NOTE', + 12 => 'TRANSFER_FEE' ]; $transactionStatus = [ @@ -55,9 +60,11 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping return [ $transaction->bill_no, - $transaction->booking->marking, - $transaction->booking->company->reference, + $transaction->owner_id, + $transaction->owner_type, $transactionTypes[$transaction->type], + $transaction->issuer, + $transaction->reciver, $transaction->currency_id === 1 ? 'MYR' : 'RMB', $transaction->amount, $transaction->original_currency_id === 1 ? 'MYR' : 'RMB', diff --git a/app/Classes/Modules/Exports/Services/ExportsWalletTransactions.php b/app/Classes/Modules/Exports/Services/ExportsWalletTransactions.php new file mode 100644 index 00000000..af4d2d07 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsWalletTransactions.php @@ -0,0 +1,105 @@ +request = $request; + } + + public function headings(): array + { + return [ + 'DocNo', + 'DocDate', + 'DebtorCode', + 'DebtorName', + 'CurrencyCode', + 'ShipInfo', + 'ItemCode', + 'DetailDescription', + 'Qty', + 'UnitPrice', + 'AccNo' + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $start_date = $this->request->input('start_date', null); + if ($start_date) { + $start_date = Carbon::parse($this->request->input('start_date'))->format('Y-m-d'); + } + + $end_date = $this->request->input('end_date', null); + if ($end_date) { + $end_date = Carbon::parse($this->request->input('end_date'))->format('Y-m-d'); + } + + $query = Transaction::query(); + + $query->where('type', TransactionType::TOP_UP); + $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + + if($start_date && $end_date) { + $query->whereBetween('created_at', [ + Carbon::parse($start_date)->format('Y-m-d 0:00:00'), + Carbon::parse($end_date)->format('Y-m-d 23:59:59') + ]); + } + elseif($start_date && !$end_date) { + $query->where('created_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00')); + } + elseif(!$start_date && $end_date) { + $query->where('created_at', '<=', Carbon::parse($end_date)->format('Y-m-d 23:59:59')); + } + + return $query; + } + + /** + * @param Company $transaction + * + * @return array + */ + public function map($transaction): array + { + $company = $transaction->owner->owner; + + return [ + '<>', + $transaction->updated_at->format('d/m/Y'), + $company->debtor, + '', + 'MYR', + $transaction->bill_no, + 'W1', + 'CREDIT SALES', + 1, + $transaction->amount, + '500-0000' + ]; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Imports/Services/ImportsDebtor.php b/app/Classes/Modules/Imports/Services/ImportsDebtor.php new file mode 100644 index 00000000..5e0bdadc --- /dev/null +++ b/app/Classes/Modules/Imports/Services/ImportsDebtor.php @@ -0,0 +1,51 @@ +whereNull('debtor')->first(); + + if ($company) { + $company->debtor = $debtor; + $company->update(); + } + + } + + } catch (\Exception $exception){ + dd($exception); + } + } + + public function batchSize(): int + { + return 100; + } + + public function rules(): array + { + return [ + + ]; + } +} diff --git a/app/Classes/Modules/SegmentConstants/ControllersLogic/CreateSegmentConstantLogic.php b/app/Classes/Modules/SegmentConstants/ControllersLogic/CreateSegmentConstantLogic.php new file mode 100644 index 00000000..12b26ad6 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/ControllersLogic/CreateSegmentConstantLogic.php @@ -0,0 +1,70 @@ + 'Created Segment Constant', + 'message' => 'You have successfully created a new Segment Constant' + ]; + } + + /** @var CanCreateConstant */ + private $canCreateConstant; + + /** @var CreatesConstant */ + private $createsConstant; + + /** @var FetchesSegment */ + private $fetchesSegment; + + + /** + * CreateSegmentLogic constructor. + * @param CanCreateConstant $canCreateConstant + * @param CreatesConstant $createsConstant + */ + public function __construct(CanCreateConstant $canCreateConstant, CreatesConstant $createsConstant, FetchesSegment $fetchesSegment) + { + $this->canCreateConstant = $canCreateConstant; + $this->createsConstant = $createsConstant; + $this->fetchesSegment = $fetchesSegment; + } + + /** + * @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 + { + $constant_object = new ConstantObject($request->input('name'), $request->input('reference'), $request->input('detail')); + + $segment = $this->fetchesSegment->execute(['id' => $request->input('segment_id')]); + + $this->canCreateConstant->passes($constant_object); + $constant = $this->createsConstant->execute($segment, $constant_object); + + return $this->resourceResponse(new ConstantResource($constant)); + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/ControllersLogic/FetchSegmentConstantLogic.php b/app/Classes/Modules/SegmentConstants/ControllersLogic/FetchSegmentConstantLogic.php new file mode 100644 index 00000000..43c10039 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/ControllersLogic/FetchSegmentConstantLogic.php @@ -0,0 +1,51 @@ + 'Retrieved Segment Constant', + 'message' => 'You have successfully retrieved a segment constant' + ]; + } + + /** @var FetchesConstant */ + private $fetchesConstant; + + /** + * FetchSegmentLogic constructor. + * @param FetchesConstant $fetchesConstant + */ + public function __construct(FetchesConstant $fetchesConstant) + { + $this->fetchesConstant = $fetchesConstant; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $query = $this->fetchesConstant->execute(['id' => $request->route('id')]); + + return $this->resourceResponse(new ConstantResource($query)); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/ControllersLogic/UpdateSegmentConstantLogic.php b/app/Classes/Modules/SegmentConstants/ControllersLogic/UpdateSegmentConstantLogic.php new file mode 100644 index 00000000..49897e95 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/ControllersLogic/UpdateSegmentConstantLogic.php @@ -0,0 +1,88 @@ + 'Updated Segment Constant', + 'message' => 'You have successfully updated the Segment Constant' + ]; + } + + /** @var CanUpdateConstant */ + private $canUpdateConstant; + + /** @var UpdatesConstant */ + private $updatesConstant; + + /** @var FetchesConstant */ + private $fetchesConstant; + + + /** + * UpdateSegmentLogic constructor. + * @param CanUpdateConstant $canUpdateConstant + * @param UpdatesConstant $updatesConstant + * @param FetchesConstant $fetchesConstant + */ + public function __construct( + CanUpdateConstant $canUpdateConstant, + UpdatesConstant $updatesConstant, + FetchesConstant $fetchesConstant + ) + { + $this->canUpdateConstant = $canUpdateConstant; + $this->updatesConstant = $updatesConstant; + $this->fetchesConstant = $fetchesConstant; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + try { + DB::beginTransaction(); + + $constant_query = $this->fetchesConstant->execute(['id' => $request->route('id')]); + + $constant_object = new ConstantObject( + $request->input('name', $constant_query->name), + $request->input('reference', $constant_query->reference), + $request->input('detail', (array) $constant_query->detail)); + $this->canUpdateConstant->passes($constant_object); + $constant_query = $this->updatesConstant->execute($constant_query, $constant_object); + + DB::commit(); + + return $this->resourceResponse(new ConstantResource($constant_query)); + + } catch (\Exception $exception){ + throw new ErrorException($exception->getMessage(), $exception->getCode()); + } + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php index 81eb0c8a..460f5181 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php @@ -85,7 +85,7 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); - $this->createInvoiceTransactionProcessor->execute($transaction->booking); + $this->createInvoiceTransactionProcessor->execute($transaction->owner->booking); return $this->response([]); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePurchaseOrderTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePurchaseOrderTransactionLogic.php index aa4c6f4d..9bab107f 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePurchaseOrderTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePurchaseOrderTransactionLogic.php @@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Bookings\Services\FetchesBooking; use App\Classes\Modules\Companies\Services\FetchesCompany; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; +use App\Classes\Modules\Transactions\Processors\CreatePurchaseOrderTransactionProcessor; use App\Classes\Modules\Transactions\Services\CreatesTransaction; use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail; use App\Classes\Modules\Transactions\Services\DeletesTransactionDetails; @@ -25,26 +26,6 @@ use Illuminate\Http\Request; class CreatePurchaseOrderTransactionLogic extends AbstractControllerLogic { - /** - * CreatePurchaseOrderTransactionLogic constructor. - * @param FetchesBooking $fetchesBooking - * @param UpdatesTransactionStatus $updatesTransactionStatus - * @param CreatesTransaction $createsTransaction - * @param CreatesTransactionDetail $createsTransactionDetail - * @param UpdatesTransaction $updatesTransaction - * @param DeletesTransactionDetails $deletesTransactionDetails - * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber - */ - public function __construct(FetchesBooking $fetchesBooking, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesTransactionDetail $createsTransactionDetail, UpdatesTransaction $updatesTransaction, DeletesTransactionDetails $deletesTransactionDetails, GeneratesTransactionBillNumber $generatesTransactionBillNumber) - { - $this->fetchesBooking = $fetchesBooking; - $this->updatesTransactionStatus = $updatesTransactionStatus; - $this->createsTransaction = $createsTransaction; - $this->createsTransactionDetail = $createsTransactionDetail; - $this->updatesTransaction = $updatesTransaction; - $this->deletesTransactionDetails = $deletesTransactionDetails; - $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; - } /** * @return array @@ -59,37 +40,35 @@ class CreatePurchaseOrderTransactionLogic extends AbstractControllerLogic /** @var FetchesBooking */ private $fetchesBooking; - /** @var UpdatesTransactionStatus */ - private $updatesTransactionStatus; - - /** @var CreatesTransaction */ - private $createsTransaction; - - /** @var CreatesTransactionDetail */ - private $createsTransactionDetail; - - /** @var UpdatesTransaction */ - private $updatesTransaction; - - /** @var DeletesTransactionDetails */ - private $deletesTransactionDetails; - /** @var GeneratesTransactionBillNumber */ private $generatesTransactionBillNumber; + /** @var CreatePurchaseOrderTransactionProcessor */ + private $createPurchaseOrderTransactionProcessor; + + /** + * CreatePurchaseOrderTransactionLogic constructor. + * @param FetchesBooking $fetchesBooking + * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber + * @param CreatePurchaseOrderTransactionProcessor $createPurchaseOrderTransactionProcessor + */ + public function __construct(FetchesBooking $fetchesBooking, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatePurchaseOrderTransactionProcessor $createPurchaseOrderTransactionProcessor) + { + $this->fetchesBooking = $fetchesBooking; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->createPurchaseOrderTransactionProcessor = $createPurchaseOrderTransactionProcessor; + } /** * @param Request $request + * @param string $id * @return JsonResponse * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function logic(Request $request) : JsonResponse + public function logic(Request $request, $id = '') : JsonResponse { /** @var Booking $booking */ - $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); - - /** @var Transaction $transaction */ - $transaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); + $booking = $this->fetchesBooking->execute(['id' => $request->route('id') ?? $id]); $billNumber = $this->generatesTransactionBillNumber->execute('PO-'); @@ -102,15 +81,8 @@ class CreatePurchaseOrderTransactionLogic extends AbstractControllerLogic $total, $total, $booking->fix_currency_id, $booking->fix_currency_id, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, $request->input('products')); - !$transaction ? $transaction = $this->createsTransaction->execute($booking, $object) : $transaction = $this->updatesTransaction->execute($transaction, $object); - $this->updatesTransactionStatus->execute($transaction, (float) number_format($total, 2, '.', '') === (float) number_format((float)$booking->fix_amount, 2, '.', '') ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::PENDING_SUBMISSION); - - $this->deletesTransactionDetails->execute($transaction); - - foreach ($object->getDetails() as $product){ - $this->createsTransactionDetail->execute($transaction, $product); - } + $transaction = $this->createPurchaseOrderTransactionProcessor->execute($booking, $object); return $this->resourceResponse(new TransactionResource($transaction)); diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index f496ab4f..1cf71643 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -3,31 +3,19 @@ namespace App\Classes\Modules\Transactions\ControllersLogic; +use App\Classes\Modules\Transactions\Processors\CreateSupplierTransactionProcessor; +use App\Models\Document; +use Illuminate\Http\Request; +use Illuminate\Http\JsonResponse; +use Meneses\LaravelMpdf\Facades\LaravelMpdf; +use App\Classes\ValueObjects\Constants\DocumentType; +use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\Modules\Documents\Services\CreatesFiles; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Services\FetchesCompany; -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; -use App\Classes\Modules\Transactions\Services\CreatesTransaction; -use App\Classes\Modules\Transactions\Services\FetchesTransaction; -use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; -use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; -use App\Classes\Modules\Documents\Services\CreatesDocument; -use App\Classes\Modules\Documents\Services\CreatesFiles; -use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Classes\ValueObjects\Constants\PaymentMethodType; -use App\Classes\ValueObjects\Constants\TransactionType; -use App\Classes\ValueObjects\Constants\DocumentType; -use App\Models\Document; -use App\Models\Transaction; -use Barryvdh\DomPDF\PDF; -use Carbon\Carbon; -use Illuminate\Http\JsonResponse; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Storage; -use Illuminate\Support\Str; - use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; -use Meneses\LaravelMpdf\Facades\LaravelMpdf; +use App\Classes\Modules\Documents\Services\CreatesDocument; +use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; class CreateSupplierTransactionLogic extends AbstractControllerLogic { @@ -46,14 +34,8 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var FetchesCompany */ private $fetchesCompany; - /** @var FetchesTransaction */ - private $fetchesTransaction; - - /** @var UpdatesTransactionStatus */ - private $updatesTransactionStatus; - - /** @var CreatesTransaction */ - private $createsTransaction; + /** @var CreateSupplierTransactionProcessor */ + private $createSupplierTransactionProcessor; /** @var CreatesDocument */ private $createsDocument; @@ -61,64 +43,35 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var CreatesFiles */ private $createsFile; - /** @var GeneratesTransactionBillNumber */ - private $generatesTransactionBillNumber; - - /** @var PDF */ - private $pdf; - /** * CreateSupplierTransactionLogic constructor. * @param FetchesCompany $fetchesCompany - * @param FetchesTransaction $fetchesTransaction - * @param UpdatesTransactionStatus $updatesTransactionStatus - * @param CreatesTransaction $createsTransaction - * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber - * @param PDF $pdf + * @param CreateSupplierTransactionProcessor $createSupplierTransactionProcessor + * @param CreatesDocument $createsDocument + * @param CreatesFiles $createsFile */ - public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, PDF $pdf) + public function __construct(FetchesCompany $fetchesCompany, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor, CreatesDocument $createsDocument, CreatesFiles $createsFile) { - $this->fetchesCompany = $fetchesCompany; - $this->fetchesTransaction = $fetchesTransaction; - $this->updatesTransactionStatus = $updatesTransactionStatus; - $this->createsTransaction = $createsTransaction; + $this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor; $this->createsDocument = $createsDocument; $this->createsFile = $createsFile; - $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; - $this->pdf = $pdf; } public function logic(Request $request) : JsonResponse { + $supplier = $this->fetchesCompany->execute(['id' => $request->route('id')]); $rate = $request->input('rate'); - $transactions = collect(); + $payments = $request->input('payments'); - foreach($request->input('payments') as $payment){ + $this->createSupplierTransactionProcessor->execute($supplier, $rate, $payments); - /** @var Transaction $payment */ - $payment = $this->fetchesTransaction->execute(['id' => $payment['id']]); - - if($payment->status !== ApprovalStatus::APPROVED) continue; + if(!count($this->createSupplierTransactionProcessor->getBills())) return $this->response([]); - $this->updatesTransactionStatus->execute($payment, ApprovalStatus::COMPLETED); - $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); - $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, - $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, - $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, - $rate, 0, 0, null, ApprovalStatus::PENDING_VERIFICATION); - - $transactions[] = $this->createsTransaction->execute($payment->booking, $object); - } - - if(!count($transactions)) return $this->response([]); - - $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $transactions, 'supplier' => $supplier]); - - $path = Str::studly($supplier->name).'_'.Carbon::now()->format('Y_m_d_h_s_i').'.pdf'; + $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $this->createSupplierTransactionProcessor->getBills(), 'transferFeeTransactions' => $this->createSupplierTransactionProcessor->getTransferTransactions(), 'supplier' => $supplier]); $object = new DocumentObject( DocumentType::CURRENCY_VENDOR_ORDER, diff --git a/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php new file mode 100644 index 00000000..e1875f0a --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php @@ -0,0 +1,62 @@ +fetchesCompany = $fetchesCompany; + $this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor; + } + + + /** + * @param Request $request + * @return string|\Symfony\Component\HttpFoundation\Response + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute(Request $request) + { + + $supplier = $this->fetchesCompany->execute(['id' => $request->route('id')]); + + $rate = $request->input('rate'); + + $payments = array_map(function($value){ + return ['id' => $value]; + }, json_decode($request->input('payments'))); + + DB::beginTransaction(); + + $this->createSupplierTransactionProcessor->execute($supplier, $rate, $payments); + + if(!count($this->createSupplierTransactionProcessor->getBills())) return 'unexpected error'; + + $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $this->createSupplierTransactionProcessor->getBills(), 'transferFeeTransactions' => $this->createSupplierTransactionProcessor->getTransferTransactions(), 'supplier' => $supplier]); + + DB::rollBack(); + + return $pdf->stream('MockUpWhiteForm.pdf'); + } +} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/FetchBankAccountBalanceLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/FetchBankAccountBalanceLogic.php new file mode 100644 index 00000000..5ffa11bf --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/FetchBankAccountBalanceLogic.php @@ -0,0 +1,46 @@ + 'Retrieved Bank Balance Account', + 'message' => 'You have successfully retrieved bank balance account' + ]; + } + + /** @var GeneratesBankBalanceAccount */ + private $generatesBankBalanceAccount; + + /** + * FetchCompanyAccountBalanceLogic constructor. + * @param GeneratesBankBalanceAccount $generatesBankBalanceAccount + */ + public function __construct(GeneratesBankBalanceAccount $generatesBankBalanceAccount) + { + $this->generatesBankBalanceAccount = $generatesBankBalanceAccount; + } + + public function logic(Request $request) : JsonResponse + { + $bank = Bank::find($request->route('id')); + + return $this->response(['data' => $this->generatesBankBalanceAccount->execute($bank)]); + + } + + + +} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php new file mode 100644 index 00000000..b73f5ca3 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php @@ -0,0 +1,46 @@ + 'Retrieved Company Balance Account', + 'message' => 'You have successfully retrieved company balance account' + ]; + } + + /** @var GeneratesCompanyBalanceAccount */ + private $generatesCompanyBalanceAccount; + + /** + * FetchCompanyAccountBalanceLogic constructor. + * @param GeneratesCompanyBalanceAccount $generatesCompanyBalanceAccount + */ + public function __construct(GeneratesCompanyBalanceAccount $generatesCompanyBalanceAccount) + { + $this->generatesCompanyBalanceAccount = $generatesCompanyBalanceAccount; + } + + public function logic(Request $request) : JsonResponse + { + $company = Company::find($request->route('id')); + + return $this->response(['data' => $this->generatesCompanyBalanceAccount->execute($company)]); + + } + + + +} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php index 15cb9bfc..2f4595bf 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php @@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Transactions\Services\ListsTransactions; use App\Http\Resources\BookingResource; use App\Http\Resources\TransactionResource; +use App\Http\Resources\WalletTransactionResource; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListWalletTransactionsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListWalletTransactionsLogic.php new file mode 100644 index 00000000..1ae97d45 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/ListWalletTransactionsLogic.php @@ -0,0 +1,48 @@ +listsTransactions = $listsTransactions; + } + + /** + * @return array + */ + protected function notification():array { + return [ + 'title' => 'Retrieved Wallet Transactions', + 'message' => 'You have successfully retrieved a list of transactions' + ]; + } + + /** @var ListsTransactions */ + private $listsTransactions; + + public function logic(Request $request) : JsonResponse + { + + $query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters'))); + + return $this->collectionResponse(WalletTransactionResource::collection($query)); + + } + + + +} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdatePaymentTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdatePaymentTransactionStatusLogic.php new file mode 100644 index 00000000..11f0a377 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdatePaymentTransactionStatusLogic.php @@ -0,0 +1,76 @@ + 'Updated Transaction', + 'message' => 'You have successfully updated a transaction' + ]; + } + + /** @var FetchesTransaction */ + private $fetchesTransaction; + + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + + /** @var DeletesDocument */ + private $deletesDocument; + + /** + * CreatePaymentVerificationDocumentLogic constructor. + * @param FetchesTransaction $fetchesTransaction + * @param UpdatesTransactionStatus $updatesTransactionStatus + * @param DeletesDocument $deletesDocument + */ + public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument) + { + $this->fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->deletesDocument = $deletesDocument; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); + $status = $request->route('status'); + + $this->updatesTransactionStatus->execute($transaction, $status === 'pending' ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::COMPLETED); + + if ($status == 'pending') { + $document = $transaction->documents()->first(); + if ($document) { + $this->deletesDocument->execute($document); + } + } + + return $this->response([]); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php new file mode 100644 index 00000000..b86e4878 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php @@ -0,0 +1,86 @@ + 'Updated Transaction', + 'message' => 'You have successfully updated a transaction' + ]; + } + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** @var FetchesTransaction */ + private $fetchesTransaction; + + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + + /** @var DeletesDocument */ + private $deletesDocument; + + /** @var CreditWalletProcessor */ + private $creditWalletProcessor; + + /** + * CreatePaymentVerificationDocumentLogic constructor. + * @param FetchesCompany $fetchesCompany + * @param FetchesTransaction $fetchesTransaction + * @param UpdatesTransactionStatus $updatesTransactionStatus + * @param DeletesDocument $deletesDocument + * @param CreditWalletProcessor $creditWalletProcessor + */ + public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument, CreditWalletProcessor $creditWalletProcessor) + { + $this->fetchesCompany = $fetchesCompany; + $this->fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->deletesDocument = $deletesDocument; + $this->creditWalletProcessor = $creditWalletProcessor; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); + + $transaction = $this->updatesTransactionStatus->execute($transaction, $request->input('status')); + + $booking = $transaction->owner->owner; + + $reference = 'Credit Voucher for Overpaid for Ref. '.$booking->marking; + + if ($transaction->status == ApprovalStatus::APPROVED) { + $this->creditWalletProcessor->execute($booking->company, $transaction->type, $transaction->amount, $reference); + } + + + + return $this->response([]); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index e583eaf9..5a29a1a2 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -178,6 +178,7 @@ class CreateInvoiceTransactionProcessor ApprovalStatus::COMPLETED, 'purchase_orders' ); + /** @var Document $document */ $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object); $this->createsFile->execute($document, $document_object); @@ -210,6 +211,9 @@ class CreateInvoiceTransactionProcessor $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::BILL); + $transaction = $booking->transactions()->payments()->where('status', ApprovalStatus::COMPLETED)->first() + ->transactions()->where('type', TransactionType::BILL)->first(); + $transaction_object = new TransactionObject( $billNumber, TransactionType::SUPPLIER_DELIVER, diff --git a/app/Classes/Modules/Transactions/Processors/CreatePurchaseOrderTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreatePurchaseOrderTransactionProcessor.php new file mode 100644 index 00000000..76773c75 --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/CreatePurchaseOrderTransactionProcessor.php @@ -0,0 +1,76 @@ +updatesTransactionStatus = $updatesTransactionStatus; + $this->createsTransaction = $createsTransaction; + $this->createsTransactionDetail = $createsTransactionDetail; + $this->updatesTransaction = $updatesTransaction; + $this->deletesTransactionDetails = $deletesTransactionDetails; + } + + + /** + * @param Booking $booking + * @param TransactionObject $object + * @return Transaction|\Illuminate\Database\Eloquent\Model + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute(Booking $booking, TransactionObject $object){ + /** @var Transaction $transaction */ + $transaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); + + !$transaction ? $transaction = $this->createsTransaction->execute($booking, $object) : $transaction = $this->updatesTransaction->execute($transaction, $object); + + $this->updatesTransactionStatus->execute($transaction, (float) number_format($object->getAmount(), 2, '.', '') === (float) number_format((float)$booking->fix_amount, 2, '.', '') ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::PENDING_SUBMISSION); + + $this->deletesTransactionDetails->execute($transaction); + + foreach ($object->getDetails() as $product){ + $this->createsTransactionDetail->execute($transaction, $product); + } + + return $transaction; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php new file mode 100644 index 00000000..75516fdf --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php @@ -0,0 +1,143 @@ +fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->createsTransaction = $createsTransaction; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; + $this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee; + $this->bills = collect(); + $this->transferFee = collect(); + } + + /** + * @param Company $supplier + * @param String $rate + * @param array $payments + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute(Company $supplier, String $rate, Array $payments) { + + foreach($payments as $payment){ + + /** @var Transaction $payment */ + $payment = $this->fetchesTransaction->execute(['id' => $payment['id']]); + + if($payment->status !== ApprovalStatus::APPROVED) continue; + + $this->updatesTransactionStatus->execute($payment, ApprovalStatus::COMPLETED); + $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); + $constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first(); + + $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant); + + $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, + $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, + $rate, 0, $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); + + /** @var Transaction $billTransaction */ + $billTransaction = $this->createsTransaction->execute($payment, $object); + $this->pushBill($billTransaction); + + $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); + $transferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount, $constant); + $object = new TransactionObject($transferFeeNumber, TransactionType::TRANSFER_FEE, 1, $supplier->id, + $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, + 1, 0, $transferFee, null, ApprovalStatus::PENDING_VERIFICATION); + + $this->pushTransferFee($this->createsTransaction->execute($billTransaction, $object)); + } + + } + + /** + * @return Collection + */ + public function getBills(): Collection + { + return $this->bills; + } + + /** + * @return Collection + */ + public function getTransferTransactions(): Collection + { + return $this->transferFee; + } + + /** + * @param $bill + */ + private function pushBill($bill): void + { + $this->bills->push($bill); + } + + /** + * @param $transferFee + */ + private function pushTransferFee($transferFee): void + { + $this->transferFee->push($transferFee); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php new file mode 100644 index 00000000..e04edee2 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php @@ -0,0 +1,39 @@ +calculatesTransactionTransferFee = $calculatesTransactionTransferFee; + } + + + /** + * @param float $amount + * @param float $rate + * @param SegmentConstant|null $service_charge + * @return float + */ + public function execute(float $amount, float $rate, ?SegmentConstant $service_charge) { + + if(!$service_charge) { + return 0; + } + + $transfer_fee = $this->calculatesTransactionTransferFee->execute($amount, $service_charge); + return $service_charge->detail->amount->type === 'percentage' ? (($amount + $transfer_fee) * ( (float) $service_charge->detail->amount->value /100) * (1/$rate)) : (float) $service_charge->detail->amount->value; + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php new file mode 100644 index 00000000..5a02a394 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php @@ -0,0 +1,24 @@ +detail->transferFee->type === 'percentage' ? $amount * ((float) $service_charge->detail->transferFee->value /100) : (float) $service_charge->detail->transferFee->value; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/GeneratesBankBalanceAccount.php b/app/Classes/Modules/Transactions/Services/GeneratesBankBalanceAccount.php new file mode 100644 index 00000000..39b49276 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/GeneratesBankBalanceAccount.php @@ -0,0 +1,52 @@ +checksIfTransactionBillNumberExists = $checksIfTransactionBillNumberExists; + } + + + /** + * @param Bank $bank + */ + public function execute(Bank $bank) { + $floatTransactions = $bank->recipientTransactions()->where('transactions.type', TransactionType::BILL)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->orderBy('id', 'DESC')->get(); + $transferFeeTransactions = $bank->recipientTransactions()->where('transactions.type', TransactionType::TRANSFER_FEE)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->orderBy('id', 'DESC')->get(); + + $creditNoteTransactions = []; + foreach($transferFeeTransactions as $transferFeeTransaction){ + $creditNoteTransactions[] = $transferFeeTransaction->creditNoteTransaction; + } + $creditNoteTransactions = new Collection($creditNoteTransactions); + + return [ + 'bank' => new BankResource($bank), + 'floatTransactions' => $floatTransactions, + 'transferFeeTransactions' => $transferFeeTransactions, + 'creditNoteTransactions' => $creditNoteTransactions, + 'account_balance' => $floatTransactions->sum('amount') + $transferFeeTransactions->sum('amount') - $creditNoteTransactions->sum('amount'), + ]; + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php b/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php new file mode 100644 index 00000000..cfbe8ee2 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php @@ -0,0 +1,50 @@ +checksIfTransactionBillNumberExists = $checksIfTransactionBillNumberExists; + } + + + /** + * @param Company $company + */ + public function execute(Company $company) { + $transferFeeTransactions = $company->issuerTransactions()->where('transactions.type', TransactionType::TRANSFER_FEE)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->orderBy('id', 'DESC')->get(); + + $creditNoteTransactions = []; + foreach($transferFeeTransactions as $transferFeeTransaction){ + $creditNoteTransactions[] = $transferFeeTransaction->creditNoteTransaction; + } + $creditNoteTransactions = new Collection($creditNoteTransactions); + + return [ + 'company' => new CompanyResource($company), + 'transferFeeTransactions' => $transferFeeTransactions, + 'creditNoteTransactions' => $creditNoteTransactions, + 'account_balance' => $transferFeeTransactions->sum('amount') - $creditNoteTransactions->sum('amount'), + ]; + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/GeneratesPurchaseOrderProducts.php b/app/Classes/Modules/Transactions/Services/GeneratesPurchaseOrderProducts.php new file mode 100644 index 00000000..647fac1e --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/GeneratesPurchaseOrderProducts.php @@ -0,0 +1,73 @@ +products = $products; + } + + + public function execute(Transaction $transaction, float $amount){ + + $products = collect(); + + $amountDifference = $amount - $transaction->amount; + $transactionDetails = $transaction->transactionDetails()->select('*', DB::raw('abs(price - '.abs($amountDifference).') as nearest_price'))->orderBy('nearest_price')->get(); + foreach ($transactionDetails as $product) { + + if($product->price <= 0){ + $amountDifference = $amountDifference + ($product->price * $product->quantity); + continue; + } + + $units = floor(abs($amountDifference) / $product->price); + $quantity = $product->quantity; + + if($amountDifference > 0){ + $quantity = $product->quantity + $units; + $amountDifference = $amountDifference - ($product->price * $units); + } + + if($amountDifference < 0) { + $units = ceil(abs($amountDifference) / $product->price); + $quantity = $product->quantity - $units; + + if($quantity <= 0){ + $amountDifference = $amountDifference + ($product->price * $product->quantity); + continue; + } + + $amountDifference = $amountDifference + ($product->price * $quantity); + } + + $products->push([ + 'description' => $product->product_name, + 'quantity' => (int) $quantity, + 'stockCode' => $product->product_code, + 'total' => $product->price * $quantity, + 'unit_price' => (float) $product->price, + ]); + + } + + return $products; + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php new file mode 100644 index 00000000..8ed8aa08 --- /dev/null +++ b/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php @@ -0,0 +1,101 @@ + '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)); + } +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/DebitWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/DebitWalletLogic.php new file mode 100644 index 00000000..682065c0 --- /dev/null +++ b/app/Classes/Modules/Wallets/ControllersLogic/DebitWalletLogic.php @@ -0,0 +1,117 @@ + '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)); + } +} diff --git a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php index 8497ec32..9bbe6073 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php @@ -2,17 +2,23 @@ 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\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\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\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 App\Models\Wallet; use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -20,53 +26,88 @@ 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 topup company wallet' + 'message' => 'You have successfully created a topup request for company\'s wallet' ]; } - /** @var FetchesWallet */ - private $fetchesWallet; - /** @var CanTopUpWallet */ - private $canTopUpWallet; + /** @var FetchesCompany */ + private $fetchesCompany; + + /** @var GeneratesWalletCode */ + private $generatesWalletCode; + + /** @var CreatesWallet */ + private $createsWallet; + + /** @var GeneratesTransactionBillNumber */ + private $generatesTransactionBillNumber; + + /** @var CreatesBillplzBill */ + private $createsBillplzBill; + + /** @var CreatesTransaction */ + private $createsTransaction; - /** @var CreateWalletTransactionProcessor */ - private $createWalletTransactionProcessor; /** - * CreateWalletLogic constructor. - * @param CreatesWallet $createsWallet + * TopUpWalletLogic constructor. + * @param FetchesCompany $fetchesCompany * @param GeneratesWalletCode $generatesWalletCode - * @param CanCreateCompanyWallet $canCreateCompanyWallet + * @param CreatesWallet $createsWallet + * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber + * @param CreatesBillplzBill $createsBillplzBill + * @param CreatesTransaction $createsTransaction */ - 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; } /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws \App\Classes\Exceptions\MalformedRequestException */ 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')]); - $walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount')); + /** @var Wallet $wallet */ + $wallet = $company->wallets()->first(); - $this->canTopUpWallet->passes($walletOject); + if (!$wallet) { + $object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute()); + /** @var Wallet $wallet */ + $wallet = $this->createsWallet->execute($object, $company); + } - $transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::TOP_UP); + $user = $company->employees()->first(); + $billNumber = $this->generatesTransactionBillNumber->execute('TOPUP-'); - return $this->resourceResponse(new WalletResource($wallet)); + if($amount < 0) { + throw new MalformedRequestException('Top up credit value must be greater than zero.'); + } + + $billPlzBill = $this->createsBillplzBill->execute($user->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)); } } diff --git a/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php b/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php new file mode 100644 index 00000000..d86a4465 --- /dev/null +++ b/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php @@ -0,0 +1,90 @@ +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; + } +} 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/Modules/Wallets/Services/UpdatesWalletBalance.php b/app/Classes/Modules/Wallets/Services/UpdatesWalletBalance.php new file mode 100644 index 00000000..a724cf24 --- /dev/null +++ b/app/Classes/Modules/Wallets/Services/UpdatesWalletBalance.php @@ -0,0 +1,25 @@ +amount = $model->amount + $amount; + return $this->handler($model); + + } +} diff --git a/app/Classes/ValueObjects/Constants/BankAccountType.php b/app/Classes/ValueObjects/Constants/BankAccountType.php index 13a36fde..c1ae288e 100644 --- a/app/Classes/ValueObjects/Constants/BankAccountType.php +++ b/app/Classes/ValueObjects/Constants/BankAccountType.php @@ -8,4 +8,6 @@ final class BankAccountType { public const EXTERNAL = 2; + public const ALIPAY= 3; + } diff --git a/app/Classes/ValueObjects/Constants/BusinessType.php b/app/Classes/ValueObjects/Constants/BusinessType.php index d24b975d..831568e9 100644 --- a/app/Classes/ValueObjects/Constants/BusinessType.php +++ b/app/Classes/ValueObjects/Constants/BusinessType.php @@ -10,4 +10,6 @@ final class BusinessType { public const CURRENCY_VENDOR = 3; + public const TRANSFER_AGENT = 4; + } diff --git a/app/Classes/ValueObjects/Constants/FileType.php b/app/Classes/ValueObjects/Constants/FileType.php index 8564643c..d5404e7a 100644 --- a/app/Classes/ValueObjects/Constants/FileType.php +++ b/app/Classes/ValueObjects/Constants/FileType.php @@ -14,11 +14,15 @@ class FileType public const PDF = 'application/pdf'; + public const EXCEL = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + public const EXTENSION = [ 'image/gif' => 'gif', 'image/png' => 'png', 'image/jpeg' => 'jpeg', 'application/pdf' => 'pdf', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'excel', + 'application/vnd.ms-excel' => 'excel', ]; } \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/SegmentConstants.php b/app/Classes/ValueObjects/Constants/SegmentConstants.php index 80e9cb71..dd6b093a 100644 --- a/app/Classes/ValueObjects/Constants/SegmentConstants.php +++ b/app/Classes/ValueObjects/Constants/SegmentConstants.php @@ -20,4 +20,8 @@ class SegmentConstants public const CUSTOM_SERVICE_TYPE = 'CUSTOM_SERVICE_TYPE'; + public const SERVICE_CHARGE = 'SERVICE_CHARGE'; + + public const TRANSFER_FEE = 'TRANSFER_FEE'; + } \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/TransactionType.php b/app/Classes/ValueObjects/Constants/TransactionType.php index 698abd76..4814ac04 100644 --- a/app/Classes/ValueObjects/Constants/TransactionType.php +++ b/app/Classes/ValueObjects/Constants/TransactionType.php @@ -24,5 +24,9 @@ final class TransactionType { public const CREDIT_NOTE = 9; + public const DEBIT_NOTE = 11; + public const WITHDRAW = 10; + + public const TRANSFER_FEE = 12; } diff --git a/app/Console/Commands/EmailDoToVTCommand.php b/app/Console/Commands/EmailDoToVTCommand.php index 66e4f7b4..00395268 100644 --- a/app/Console/Commands/EmailDoToVTCommand.php +++ b/app/Console/Commands/EmailDoToVTCommand.php @@ -11,8 +11,10 @@ use Carbon\Carbon; use Illuminate\Console\Command; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Storage; +use Psy\Util\Json; use ZipArchive; class EmailDoToVTCommand extends Command @@ -54,12 +56,17 @@ class EmailDoToVTCommand extends Command $zip_file = 'do_'.Carbon::yesterday()->format('Y_m_d').'.zip'; $attachment = storage_path().'/'.$zip_file; + $startDate = Carbon::yesterday(); + $endDate = Carbon::yesterday(); + $zip = new ZipArchive(); if ($zip->open($attachment, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE)) { - $bookings = \App\Models\Booking::where('status', ApprovalStatus::COMPLETED)->whereDate('updated_at', Carbon::yesterday()) + $bookings = \App\Models\Booking::where('status', ApprovalStatus::COMPLETED)->whereDate('updated_at', '>=', $startDate)->whereDate('updated_at', '<=', $endDate) ->whereHas('transactions', function ($query){ - return $query->where('type', TransactionType::BILL)->where('issuer', 2); + return $query->where('type', TransactionType::PAYMENT)->whereHas('transactions', function ($query){ + return $query->where('issuer', 2); + }); })->get(); if(!count($bookings)){ return; } @@ -72,20 +79,20 @@ class EmailDoToVTCommand extends Command $zip->close(); - Mail::raw( "Attention to VT Admin team:\r\n\r\nKindly refer to the attachment for our DAILY DO COMPILATION ".Carbon::yesterday()->format('d-m-Y').".\r\n\r\n**This is an automatically generated email – please do not reply to it. If you have any queries kindly contact our admin team through Wechat.\r\n\r\n\r\nCIEF WORLDWIDE SDN BHD", function($message) use ($attachment){ + Mail::raw( "Attention to VT Admin team:\r\n\r\nKindly refer to the attachment for our DAILY DO COMPILATION ".$startDate->format('d-m-Y')." - ".$endDate->format('d-m-Y').".\r\n\r\n**This is an automatically generated email – please do not reply to it. If you have any queries kindly contact our admin team through Wechat.\r\n\r\n\r\nCIEF WORLDWIDE SDN BHD", function($message) use ($attachment, $startDate, $endDate){ $message->from('exchange@cief-malaysia.com'); $message->to(['vtnation16@gmail.com', 'vtnation@gmail.com', 'atvantic04@gmail.com', 'vtnation2@gmail.com']); $message->cc(['shafiqa_sukeri@cief-malaysia.com', 'frontendcief@gmail.com', 'pm@cief-malaysia.com', 'hasan@cief-malaysia.com', 'shipping_admin@cief-malaysia.com', 'hasanakbar27@gmail.com', 'pmwong2019@gmail.com', 'uldvstar@gmail.com']); - $message->subject('CIEF DO COMPILATION '.Carbon::yesterday()->format('d-m-Y')); + $message->subject('CIEF DO COMPILATION '.$startDate->format('d-m-Y').' - '.$endDate->format('d-m-Y')); $message->attach($attachment); }); File::delete($attachment); - - echo 'success'; + Log::info('success'); } + } } diff --git a/app/Http/Controllers/Banks/UpdateBankStatusController.php b/app/Http/Controllers/Banks/UpdateBankStatusController.php new file mode 100644 index 00000000..e5faffa5 --- /dev/null +++ b/app/Http/Controllers/Banks/UpdateBankStatusController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Bookings/AutoPurchaseOrderFillController.php b/app/Http/Controllers/Bookings/AutoPurchaseOrderFillController.php new file mode 100644 index 00000000..c92900bd --- /dev/null +++ b/app/Http/Controllers/Bookings/AutoPurchaseOrderFillController.php @@ -0,0 +1,25 @@ +login(User::find(1)); + return $logic->execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php b/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php new file mode 100644 index 00000000..d2a7d85c --- /dev/null +++ b/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php @@ -0,0 +1,21 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Companies/UpdateCompanyDebtorController.php b/app/Http/Controllers/Companies/UpdateCompanyDebtorController.php new file mode 100644 index 00000000..af62c4f9 --- /dev/null +++ b/app/Http/Controllers/Companies/UpdateCompanyDebtorController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index cdd1c49a..39ea3dc5 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -5,6 +5,10 @@ namespace App\Http\Controllers\Exports; use App\Classes\Modules\Exports\Services\ExportsCustomers; use App\Classes\Modules\Exports\Services\ExportsTransactions; +use App\Classes\Modules\Exports\Services\ExportsNullDebtors; +use App\Classes\Modules\Exports\Services\ExportsPaymentTransactions; + +use App\Classes\Modules\Exports\Services\ExportsWalletTransactions; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -13,15 +17,41 @@ use Maatwebsite\Excel\Excel; class ExportCustomersToExcelController { - public function export(ExportsCustomers $exportsCustomers, Request $request){ + /** + * ExportCustomersToExcelController constructor. + * @param Request $request + */ + public function __construct(Request $request) + { $token = Auth::fromUser(User::find(1)); $request->headers->set('Authorization', 'Bearer '.$token); + } + + public function export(ExportsCustomers $exportsCustomers, Request $request){ return $exportsCustomers->download('customers.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } public function transactions(ExportsTransactions $exportsTransactions, Request $request){ - $token = Auth::fromUser(User::find(1)); - $request->headers->set('Authorization', 'Bearer '.$token); return $exportsTransactions->download('transactions.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } + + public function nullDebtor(ExportsNullDebtors $exportsNullDebtors, Request $request){ + $response = $exportsNullDebtors->download('nullDebtor.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } + + public function paymentTransactions(Request $request){ + $exportsTransactions = new ExportsPaymentTransactions($request); + $response = $exportsTransactions->download('payment-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } + + public function walletTransactions(Request $request){ + $exportsTransactions = new ExportsWalletTransactions($request); + $response = $exportsTransactions->download('wallet-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } } \ No newline at end of file diff --git a/app/Http/Controllers/Imports/ImportUpdateDebtorController.php b/app/Http/Controllers/Imports/ImportUpdateDebtorController.php new file mode 100644 index 00000000..72f998d4 --- /dev/null +++ b/app/Http/Controllers/Imports/ImportUpdateDebtorController.php @@ -0,0 +1,27 @@ +input('files'), '', ApprovalStatus::APPROVED, 'imports'); + Excel::import(new ImportsDebtor(), json_decode($object->getFiles()[0])->file_info->original->file); + return []; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/SegmentConstants/CreateSegmentConstantController.php b/app/Http/Controllers/SegmentConstants/CreateSegmentConstantController.php new file mode 100644 index 00000000..7520e1d1 --- /dev/null +++ b/app/Http/Controllers/SegmentConstants/CreateSegmentConstantController.php @@ -0,0 +1,19 @@ +execute($request); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/SegmentConstants/FetchSegmentConstantController.php b/app/Http/Controllers/SegmentConstants/FetchSegmentConstantController.php new file mode 100644 index 00000000..67532d3f --- /dev/null +++ b/app/Http/Controllers/SegmentConstants/FetchSegmentConstantController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/SegmentConstants/UpdateSegmentConstantController.php b/app/Http/Controllers/SegmentConstants/UpdateSegmentConstantController.php new file mode 100644 index 00000000..c34914dc --- /dev/null +++ b/app/Http/Controllers/SegmentConstants/UpdateSegmentConstantController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php b/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php new file mode 100644 index 00000000..e94c9484 --- /dev/null +++ b/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php @@ -0,0 +1,15 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Transactions/FetchBankAccountBalanceController.php b/app/Http/Controllers/Transactions/FetchBankAccountBalanceController.php new file mode 100644 index 00000000..0d8c89b4 --- /dev/null +++ b/app/Http/Controllers/Transactions/FetchBankAccountBalanceController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php b/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php new file mode 100644 index 00000000..d36b0605 --- /dev/null +++ b/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Transactions/ListWalletTransactionsController.php b/app/Http/Controllers/Transactions/ListWalletTransactionsController.php new file mode 100644 index 00000000..e83d7b58 --- /dev/null +++ b/app/Http/Controllers/Transactions/ListWalletTransactionsController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Transactions/UpdatePaymentTransactionStatusController.php b/app/Http/Controllers/Transactions/UpdatePaymentTransactionStatusController.php new file mode 100644 index 00000000..047bc1dc --- /dev/null +++ b/app/Http/Controllers/Transactions/UpdatePaymentTransactionStatusController.php @@ -0,0 +1,14 @@ +execute($request); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Transactions/UpdateRefundTransactionStatusController.php b/app/Http/Controllers/Transactions/UpdateRefundTransactionStatusController.php new file mode 100644 index 00000000..919fadd1 --- /dev/null +++ b/app/Http/Controllers/Transactions/UpdateRefundTransactionStatusController.php @@ -0,0 +1,14 @@ +execute($request); + } +} \ No newline at end of file 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/BookingResource.php b/app/Http/Resources/BookingResource.php index 80199df9..0eeb9670 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -46,6 +46,7 @@ class BookingResource extends JsonResource ], 'status' => $this->status, 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), + 'created_at_with_time' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'), $this->mergeWhen($this->relationLoaded('transactions'), [ 'purchase_order' => new TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()), 'payment_attempts' => TransactionResource::collection( @@ -57,11 +58,7 @@ class BookingResource extends JsonResource 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '<', Carbon::now())->get()), 'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){ $query->where(function($query){ - $query->where(function($query){ - $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED]); - })->orWhere(function($query){ - $query->where('type', TransactionType::BILL)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - }); + $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]); })->orWhere(function($query){ $query->where(function($query){ $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]); diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index 54ab047d..fceab5bc 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -15,6 +15,7 @@ use App\Models\SegmentConstant; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Log; class CompanyResource extends JsonResource { @@ -28,6 +29,10 @@ class CompanyResource extends JsonResource { $lastPayment = $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->first(); $totalPayments = $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount'); + + $segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $this->id)->first(); + $serviceCharge = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $this->id)->first(); + return [ 'id' => $this->id, 'name' => $this->name, @@ -56,14 +61,13 @@ class CompanyResource extends JsonResource ], 'segments' => SegmentResource::collection($this->segments), 'services' => (new FetchesCompanyServices())->getServices($this->servicesConfigurations()), - 'currencies' => $this->when($this->business_type === BusinessType::CURRENCY_VENDOR, function(){ - $segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $this->id)->first(); - return $segment ? CurrencyResource::collection(Currency::whereIn('id', $segment->detail->currencies)->get()) : []; - }), - 'created_at' => $this->created_at->format('d-m-Y') - + 'wallet' => new WalletResource($this->wallets()->first()), + 'created_at' => $this->created_at->format('d-m-Y'), + $this->mergeWhen($this->business_type === BusinessType::CURRENCY_VENDOR, [ + 'currencies' => $segment ? CurrencyResource::collection(Currency::whereIn('id', $segment->detail->currencies)->get()) : [], + 'service_charge' => $serviceCharge + ]) ]; - } } diff --git a/app/Http/Resources/DocumentResource.php b/app/Http/Resources/DocumentResource.php index 2595ed55..59933a67 100644 --- a/app/Http/Resources/DocumentResource.php +++ b/app/Http/Resources/DocumentResource.php @@ -2,6 +2,7 @@ namespace App\Http\Resources; +use App\Models\Booking; use App\Models\Company; use App\Models\Document; use Carbon\Carbon; @@ -23,7 +24,7 @@ class DocumentResource extends JsonResource 'reference' => $this->reference, 'status' => (int) $this->status, 'document_type' => $this->document_type, - 'owner' => new CompanyResource($this->whenLoaded('owner')), + 'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingResource($this->owner) : new CompanyResource($this->owner)) : null, 'files' => FileResource::collection($this->files), 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A') ]; diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 633985cf..30ba223c 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -3,6 +3,7 @@ namespace App\Http\Resources; use App\Classes\ValueObjects\Constants\TransactionType; +use App\Models\Booking; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; @@ -16,14 +17,18 @@ class TransactionResource extends JsonResource */ public function toArray($request) { + + $booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; + $days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); + return [ 'id' => $this->id, - 'booking' => new BookingResource($this->booking), + 'booking' => new BookingResource($booking), 'type' => (int) $this->type, 'bill_no' => $this->bill_no, 'payment_reference' => $this->payment_reference, 'payment_method' => (float) $this->payment_method, - 'recipient_bank_account' => new BankResource($this->when((int) $this->type === TransactionType::BILL, $this->booking->bank)), + 'recipient_bank_account' => new BankResource($booking->bank), 'issuer_name' => $this->issuerCompany->name, 'amount' => (double) $this->amount, 'original_amount' => (double) $this->original_amount, @@ -35,9 +40,14 @@ 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())), + 'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())), + 'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())), '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' => $days->gt(Carbon::now()) ? '+' : '-', + 'duration' => $days->diff(Carbon::now())->format('%d'), + ] ]; } } diff --git a/app/Http/Resources/WalletResource.php b/app/Http/Resources/WalletResource.php index 37ff5dbd..143af1c4 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,9 @@ 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' => WalletTransactionResource::collection($this->transactions()->whereIn('status', [2, 3])->orderBy('id', 'DESC')->get()), + 'top_up_records' => WalletTransactionResource::collection($this->transactions()->whereNotIn('status', [0])->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get()) ]; } } diff --git a/app/Http/Resources/WalletTransactionResource.php b/app/Http/Resources/WalletTransactionResource.php index 1d0037fe..cfc8ab10 100644 --- a/app/Http/Resources/WalletTransactionResource.php +++ b/app/Http/Resources/WalletTransactionResource.php @@ -2,6 +2,10 @@ namespace App\Http\Resources; +use App\Classes\General\Eloquent\Filters\TransactionServiceId; +use App\Classes\ValueObjects\Constants\TransactionType; +use App\Models\Transaction; +use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; class WalletTransactionResource extends JsonResource @@ -14,16 +18,39 @@ class WalletTransactionResource extends JsonResource */ public function toArray($request) { + $description = ''; + switch((int) $this->type){ + case 5: + $description = (double) $this->amount.' Credit Top up'; + break; + case 9: + $description = 'Credit Voucher for '.$this->payment_reference; + break; + case 1: + $marking = Transaction::where('payment_reference', $this->bill_no)->first()->owner->marking; + $description = 'Payment For booking refs.'.''.$marking.''; + break; + case 11: + $description = 'Debit Voucher for '.$this->payment_reference; + break; + + } + return [ - 'id' => $this->id, - 'wallet_id' => (int) $this->wallet_id, - 'bill_no' => (int) $this->bill_no, - 'trans_type'=>(int) $this->trans_type, + 'type' => (int) $this->type, + 'marking' => $this->owner->owner->reference, + 'bill_no' => $this->bill_no, + 'reference' => $this->payment_reference, + 'payment_method' => (float) $this->payment_method, + 'issuer_name' => $this->issuerCompany->name, 'amount' => (double) $this->amount, - '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 + 'service_charge' => (double) $this->service_charge, + 'tax' => (double) $this->tax, + 'status' => (int) $this->status, + 'description' => $description, + 'details' => TransactionDetailResource::collection($this->transactionDetails), + 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), + 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A') ]; } } diff --git a/app/Models/Bank.php b/app/Models/Bank.php index 9381b94a..3b0bb915 100644 --- a/app/Models/Bank.php +++ b/app/Models/Bank.php @@ -2,11 +2,12 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; - use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\BelongsTo; + /** * Class Bank * @package App\Models @@ -41,4 +42,12 @@ class Bank extends AbstractModel { return $this->BelongsTo(Company::class, 'company_id', 'id'); } + + /** + * @return HasMany + */ + public function recipientTransactions(): HasMany + { + return $this->HasMany(Transaction::class, 'recipient_bank_account_id'); + } } diff --git a/app/Models/Booking.php b/app/Models/Booking.php index ea01b302..69b8a745 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -9,6 +9,8 @@ use App\Scopes\CustomerBookingsScope; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\SoftDeletes; +use Staudenmeir\EloquentHasManyDeep\HasManyDeep; +use Staudenmeir\EloquentHasManyDeep\HasRelationships; /** * Class Booking @@ -24,6 +26,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; */ class Booking extends AbstractModel implements Documentable, Transactionable { + use HasRelationships; use SoftDeletes; protected $table = 'bookings'; @@ -94,10 +97,20 @@ class Booking extends AbstractModel implements Documentable, Transactionable return $this->MorphMany(Transaction::class, 'owner'); } + /** + * @return hasManyDeep + */ + public function bills(): hasManyDeep + { + return $this->hasManyDeep(Transaction::class, [Transaction::class.' as alias'], [['owner_type', 'owner_id'], ['owner_type', 'owner_id']], [null, null]); + } + protected static function booted() { - if (auth()->user()->type === RoleTypes::USER) { - static::addGlobalScope(new CustomerBookingsScope); + if (auth()->user()) { + if (auth()->user()->type === RoleTypes::USER) { + static::addGlobalScope(new CustomerBookingsScope); + } } } diff --git a/app/Models/Company.php b/app/Models/Company.php index 7b8e4387..def72720 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -101,6 +101,14 @@ class Company extends AbstractModel implements Documentable { return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'owner_id'], ['id', 'id']); } + + /** + * @return HasMany + */ + public function issuerTransactions(): HasMany + { + return $this->HasMany(Transaction::class, 'issuer'); + } /** * @return MorphMany diff --git a/app/Models/SegmentConstant.php b/app/Models/SegmentConstant.php index 08c8b2af..b7fda276 100644 --- a/app/Models/SegmentConstant.php +++ b/app/Models/SegmentConstant.php @@ -20,6 +20,10 @@ class SegmentConstant extends AbstractModel protected $table = 'segment_constants'; protected $dates = ['deleted_at']; + + // protected $casts = [ + // 'detail' => 'array', + // ]; public function getDetailAttribute($value) { diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index a3e16c79..429449a6 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Classes\General\Interfaces\Documentable; +use App\Classes\General\Interfaces\Transactionable; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use Carbon\Carbon; @@ -14,10 +15,12 @@ use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasOneThrough; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphTo; +use Staudenmeir\EloquentHasManyDeep\HasTableAlias; -class Transaction extends AbstractModel implements Documentable +class Transaction extends AbstractModel implements Documentable, Transactionable { + use HasTableAlias; use SoftDeletes; protected $table = 'transactions'; @@ -30,27 +33,27 @@ class Transaction extends AbstractModel implements Documentable /** * @return MorphMany */ + public function transactions(): MorphMany + { + return $this->MorphMany(Transaction::class, 'owner'); + } + + /** + * @return \Illuminate\Database\Eloquent\Relations\MorphOne + */ + public function creditNoteTransaction() + { + return $this->MorphOne(Transaction::class, 'owner')->where('type', TransactionType::CREDIT_NOTE); + } + + /** + * @return BelongsTo + */ public function booking(): BelongsTo { return $this->BelongsTo(Booking::class, 'owner_id', 'id'); } - /** - * @return MorphMany - */ - public function wallets(): morphMany - { - return $this->morphMany(Wallet::class, 'owner'); - } - - /** - * @return BelongsTo - */ - public function wallet(): BelongsTo - { - return $this->BelongsTo(Wallet::class, 'owner_id', 'id'); - } - /** * @return BelongsTo */ diff --git a/app/Models/Wallet.php b/app/Models/Wallet.php index 52d8f718..8c3114fd 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; @@ -20,10 +21,6 @@ class Wallet extends AbstractModel { return $this->morphTo(); } - public function company(): BelongsTo - { - return $this->BelongsTo(Company::class, 'owner_id', 'id'); - } /** * @return morphMany diff --git a/config/billplz.php b/config/billplz.php index fb8ed920..904cea31 100644 --- a/config/billplz.php +++ b/config/billplz.php @@ -5,6 +5,7 @@ return [ 'api_key' => env('BILLPLZ_API_KEY', '0fa4c710-761b-4a7a-a501-c2c2d02643d5'), 'x_signature_key' => env('BILLPLZ_X_SIGNATURE_KEY', 'S-pbNVthVRsvnPfZlgLwqqOg'), 'collection_id' => env('BILLPLZ_COLLECTION_ID', 'hev2wdjy'), + 'wallet_collection_id' => env('BILLPLZ_WALLET_COLLECTION_ID', 'hev2wdjy'), 'redirect_url' => env('BILLPLZ_REDIRECT_URL', 'localhost'), 'callback_url' => env('BILLPLZ_CALLBACK_URL', 'localhost'), 'maybank' => 'MB2U0227', diff --git a/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php b/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php new file mode 100644 index 00000000..2798b9e7 --- /dev/null +++ b/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php @@ -0,0 +1,32 @@ +string('debtor')->nullable()->after('reference'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('companies', function (Blueprint $table) { + + }); + } +} diff --git a/database/seeds/UpdateTransactionBillOwnerSeeder.php b/database/seeds/UpdateTransactionBillOwnerSeeder.php new file mode 100644 index 00000000..1ced925d --- /dev/null +++ b/database/seeds/UpdateTransactionBillOwnerSeeder.php @@ -0,0 +1,41 @@ +transactions()->bills()->get(); + foreach ($transactions as $row) { + $key = 0; + $bills = $booking->transactions()->bills()->where('original_amount', '=', $row->original_amount)->get(); + if(count($bills) > 1){ $key = $bills->search(function($bill)use($row){ return $bill->id === $row->id; }); } + $paymentTransaction = $booking->transactions()->payments()->complete()->where('original_amount', '=', $row->original_amount)->skip($key)->first(); + + $row->owner_type = Transaction::class; + $row->owner_id = $paymentTransaction->id; + $row->updated_at = $row->updated_at; + $row->update(); + } + } + + DB::commit(); + } +} diff --git a/resources/assets/images/10107.jpg b/resources/assets/images/10107.jpg new file mode 100644 index 00000000..cffb1f8f Binary files /dev/null and b/resources/assets/images/10107.jpg differ diff --git a/resources/assets/images/first_topup_badge.png b/resources/assets/images/first_topup_badge.png new file mode 100644 index 00000000..dce1b545 Binary files /dev/null and b/resources/assets/images/first_topup_badge.png differ diff --git a/resources/assets/images/fpx-logo-vector-01.png b/resources/assets/images/fpx-logo-vector-01.png new file mode 100644 index 00000000..e46fd21d Binary files /dev/null and b/resources/assets/images/fpx-logo-vector-01.png differ diff --git a/resources/assets/images/hot.png b/resources/assets/images/hot.png new file mode 100644 index 00000000..46520b44 Binary files /dev/null and b/resources/assets/images/hot.png differ diff --git a/resources/assets/images/new-icon.png b/resources/assets/images/new-icon.png new file mode 100644 index 00000000..4131f31e Binary files /dev/null and b/resources/assets/images/new-icon.png differ diff --git a/resources/assets/images/wallet_announcement.png b/resources/assets/images/wallet_announcement.png new file mode 100644 index 00000000..bb03ce79 Binary files /dev/null and b/resources/assets/images/wallet_announcement.png differ diff --git a/resources/assets/images/wallet_announcement_2.png b/resources/assets/images/wallet_announcement_2.png new file mode 100644 index 00000000..79c6a32f Binary files /dev/null and b/resources/assets/images/wallet_announcement_2.png differ diff --git a/resources/assets/images/—Pngtree—2019 chinese new year lantern_951828.jpg b/resources/assets/images/—Pngtree—2019 chinese new year lantern_951828.jpg new file mode 100644 index 00000000..dd7ceda3 Binary files /dev/null and b/resources/assets/images/—Pngtree—2019 chinese new year lantern_951828.jpg differ diff --git a/resources/assets/sass/_responsive.scss b/resources/assets/sass/_responsive.scss index 622c734a..fa7bb2f7 100644 --- a/resources/assets/sass/_responsive.scss +++ b/resources/assets/sass/_responsive.scss @@ -1184,4 +1184,8 @@ border: 1px solid #d9d9d9; border-top: none; pointer-events: none; +} + +.top-0 { + top: 0; } \ No newline at end of file diff --git a/resources/assets/sass/modules/_typography.scss b/resources/assets/sass/modules/_typography.scss index 6e9934dc..605b8e7c 100644 --- a/resources/assets/sass/modules/_typography.scss +++ b/resources/assets/sass/modules/_typography.scss @@ -439,6 +439,10 @@ hr{ background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.8) 75%); background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.8) 75%); } +.gradient-white { + background: -webkit-linear-gradient(top, rgba(255,255,255, 0.5) 0%, rgba(255,255,255, 0.9) 75%); + background: linear-gradient(to bottom, rgba(255,255,255, 0.5) 0%, rgba(255,255,255, 0.9) 75%); +} /* Other Colors ------------------------------------ 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/accounts/sections/OnboardingSectionComponent.vue b/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue index 8b9e6171..5f2fb8e9 100644 --- a/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue +++ b/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue @@ -10,14 +10,14 @@
-
+
-
+
diff --git a/resources/assets/vue/components/address/elements/AddressListComponent.vue b/resources/assets/vue/components/address/elements/AddressListComponent.vue index c54efd95..d4efbc3d 100644 --- a/resources/assets/vue/components/address/elements/AddressListComponent.vue +++ b/resources/assets/vue/components/address/elements/AddressListComponent.vue @@ -1,22 +1,9 @@