mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 56bba0eaaf | |||
| af8444e0d9 | |||
| b2a7d1f73d | |||
| 9d2ff3fafa | |||
| 487d07e28c | |||
| 4176e09ea3 | |||
| c44bf46a42 | |||
| e687dd2b9a | |||
| 59951c4efd | |||
| c00a4712a0 | |||
| 1bb07e9402 | |||
| 683bdec1f7 | |||
| ee53a9438a | |||
| 2e2087f16e | |||
| 998b0b4da5 | |||
| dcf5c2e455 | |||
| 156b1dee07 | |||
| 544d7907c3 | |||
| 5b77f7baa6 | |||
| b33016aac4 | |||
| 2788e349ae | |||
| 5b190d5334 | |||
| 8f32769656 | |||
| 2d175f4acc | |||
| 782aed06e4 |
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreatedAfterOrEqual implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
$table = $builder->getModel()->getTable();
|
||||
$startDate = Carbon::createFromFormat('d-m-Y', $value)->startOfDay();
|
||||
return $builder->where("{$table}.created_at", '>=', $startDate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreatedBeforeOrEqual implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
$table = $builder->getModel()->getTable();
|
||||
$endDate = Carbon::createFromFormat('d-m-Y', $value)->endOfDay();
|
||||
return $builder->where("{$table}.created_at", '<=', $endDate);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,8 @@ class OwnerId implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('owner_id', $value);
|
||||
$table = $builder->getModel()->getTable();
|
||||
return $builder->where("{$table}.owner_id", $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
$table = $builder->getModel()->getTable();
|
||||
return $builder->where("{$table}.owner_type", $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,8 @@ class StatusIn implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereIn('status', $value);
|
||||
$table = $builder->getModel()->getTable();
|
||||
return $builder->whereIn("{$table}.status", $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithOrderReferenceLike implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->join('transactions as t2', 't2.payment_reference', '=', 'transactions.bill_no')
|
||||
->join('transactions as t3', 't3.id', '=', 't2.owner_id')
|
||||
->join('packing_lists', 'packing_lists.id', '=', 't3.owner_id')
|
||||
->join('orders', function ($join) use ($value) {
|
||||
$join->on('orders.id', '=', 'packing_lists.owner_id')
|
||||
->where('orders.reference', 'LIKE', '%'.$value.'%');
|
||||
})
|
||||
->addSelect(['transactions.*', 't2.id as paymentTransactionId', 't3.id as invoiceTransactionId', 'packing_lists.id as packingListId', 'orders.reference as orderReference']);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
@@ -46,6 +47,9 @@ class CallbackBillplzLogic
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/** @var CallbackBillplzProcessor */
|
||||
private $callbackBillplzProcessor;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
@@ -54,8 +58,9 @@ class CallbackBillplzLogic
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
* @param CallbackBillplzProcessor $callbackBillplzProcessor
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, CallbackBillplzProcessor $callbackBillplzProcessor)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
@@ -64,6 +69,7 @@ class CallbackBillplzLogic
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,41 +112,7 @@ class CallbackBillplzLogic
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
// check if is wallet top up
|
||||
if($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
|
||||
// group payment
|
||||
if ($transaction->type == TransactionType::GROUP_PAYMENT && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$group = Group::where('reference', $billplzXSignatureObject->getBillPlzId())->first();
|
||||
|
||||
foreach($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
|
||||
}
|
||||
|
||||
$group->status = $status;
|
||||
$group->save();
|
||||
}
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
if (!$transaction->owner instanceof Wallet) {
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->callbackBillplzProcessor->execute($transaction, $status);
|
||||
|
||||
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Group;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
|
||||
class CallbackBillplzProcessor
|
||||
{
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CreateUserProcessor constructor.
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
*/
|
||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($transaction, $status)
|
||||
{
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
// check if is wallet top up
|
||||
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
||||
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
|
||||
$group = Group::where('reference', $transaction->payment_reference)->first();
|
||||
|
||||
// check if is group payment
|
||||
if ($group) {
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
|
||||
}
|
||||
|
||||
$group->status = $status;
|
||||
$group->save();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$transaction->owner instanceof Wallet) {
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if (($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if (app()->environment('production')) {
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Company;
|
||||
use App\Models\Wallet;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
private $runningBalance = 0;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Date',
|
||||
'Description',
|
||||
'Incoming',
|
||||
'Outgoing',
|
||||
'Balance',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$wallet = Wallet::find($this->request->route('wallet_id'));
|
||||
$transactions = $wallet->transactions()->whereIn('transactions.status', [2, 3])->orderBy('id');
|
||||
|
||||
return $transactions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($transaction): array
|
||||
{
|
||||
$decimals = $this->request->route('is_precise') == 'true' ? 5 : 2;
|
||||
|
||||
$description = '';
|
||||
switch ((int) $transaction->type) {
|
||||
case TransactionType::TOP_UP:
|
||||
$description = (float) $transaction->amount . ' Credit Top up';
|
||||
break;
|
||||
case TransactionType::GROUP_PAYMENT:
|
||||
$description = (float) $transaction->amount . ' Credit Top up';
|
||||
break;
|
||||
case TransactionType::CREDIT_NOTE:
|
||||
$description = 'Credit Voucher for ' . $transaction->payment_reference;
|
||||
break;
|
||||
case TransactionType::PAYMENT:
|
||||
$booking = Transaction::where('payment_reference', $transaction->bill_no)->first()->owner;
|
||||
|
||||
if (!$booking) {
|
||||
$description = 'Payment for unknown booking, please contact tech support.';
|
||||
break;
|
||||
}
|
||||
|
||||
$marking = $booking->marking;
|
||||
$description = 'Payment For booking refs' . $marking;
|
||||
break;
|
||||
case TransactionType::DEBIT_NOTE:
|
||||
$description = 'Debit Voucher for ' . $transaction->payment_reference;
|
||||
break;
|
||||
}
|
||||
|
||||
$incoming = $outgoing = '';
|
||||
|
||||
if (in_array($transaction->type, [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE, TransactionType::GROUP_PAYMENT])) {
|
||||
$incoming = number_format($transaction->amount, $decimals, '.', ',');
|
||||
$this->runningBalance += $transaction->amount;
|
||||
}
|
||||
|
||||
if (in_array($transaction->type, [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE])) {
|
||||
$outgoing = number_format($transaction->amount, $decimals, '.', ',');
|
||||
$this->runningBalance -= $transaction->amount;
|
||||
}
|
||||
|
||||
return [
|
||||
Carbon::parse($transaction->created_at)->format('d-m-Y h:i:s A'),
|
||||
$description,
|
||||
$incoming,
|
||||
$outgoing,
|
||||
number_format($this->runningBalance, $decimals, '.', ',')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\PackingList;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateDoFromVTPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
@@ -36,6 +38,8 @@ class UpdateDoFromVTPortalProcessor
|
||||
*/
|
||||
public function execute(PackingList $packing_list) {
|
||||
|
||||
Log::info('Trying to Call UpdateDoFromVTPortalProcessor');
|
||||
|
||||
if(!app()->environment(['production'])){
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ class UpdateDoFromYDPortalProcessor
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function execute(PackingList $packingList) {
|
||||
Log::info('Trying to Call UpdateDoFromYDPortalProcessor');
|
||||
|
||||
if(!app()->environment(['production'])){
|
||||
return;
|
||||
}
|
||||
|
||||
+10
-31
@@ -4,18 +4,15 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
use App\Classes\Modules\Documents\Services\RejectsDocument;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -29,15 +26,15 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
||||
* @param RejectsDocument $rejectsDocument
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, CallbackBillplzProcessor $callbackBillplzProcessor)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
$this->rejectsDocument = $rejectsDocument;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,11 +59,8 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
||||
/** @var RejectsDocument */
|
||||
private $rejectsDocument;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
/** @var CallbackBillplzProcessor */
|
||||
private $callbackBillplzProcessor;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
@@ -82,29 +76,14 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('transaction_id')]);
|
||||
|
||||
$status === 'approve' ? $this->approvesDocument->execute($transaction->documents()->first()) : $this->rejectsDocument->execute($transaction->documents()->first());
|
||||
$status === 'approve' ? $this->approvesDocument->execute($transaction->documents()->where('status', ApprovalStatus::PENDING_VERIFICATION)->first()) : $this->rejectsDocument->execute($transaction->documents()->where('status', ApprovalStatus::PENDING_VERIFICATION)->first());
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
if($transaction->status === ApprovalStatus::APPROVED){
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
|
||||
if(($invoice->amount - $transaction->amount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
|
||||
if ($status === 'approve') {
|
||||
$this->callbackBillplzProcessor->execute($transaction, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
$companyModuleId = $invoice->receiver;
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $companyModuleId]);
|
||||
|
||||
$topUpTransaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $request->input('bank_code'), true, $payment_method);
|
||||
$topUpTransaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $request->input('bank_code'), $payment_method, $billNumber, true);
|
||||
}
|
||||
|
||||
$group->issuer = $issuer;
|
||||
|
||||
@@ -50,6 +50,11 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
||||
{
|
||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
// $groupTransaction->transaction->delete();
|
||||
$groupTransaction->delete();
|
||||
}
|
||||
|
||||
$this->deletesGroup->execute($group);
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeletePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Delete Payment Transaction',
|
||||
'message' => 'You have successfully deleted the payment transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
|
||||
/**
|
||||
* SuspendTransactionLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$transaction->delete();
|
||||
|
||||
$invoice = $transaction->owner;
|
||||
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::APPROVED);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Http\Resources\WalletTransactionResource ;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListWalletTransactionsLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* ListTransactionsLogic constructor.
|
||||
* @param ListsTransactions $listsTransactions
|
||||
*/
|
||||
public function __construct(ListsTransactions $listsTransactions)
|
||||
{
|
||||
$this->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')));
|
||||
|
||||
if (str_contains($request->input('filters'), "owner_id") && $query->count() > 0) {
|
||||
$wallet_total_incoming = Transaction::where('owner_type', $query->first()->owner_type)
|
||||
->where('owner_id', $query->first()->owner_id)
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->whereIn('type', [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE, TransactionType::GROUP_PAYMENT])
|
||||
->sum('amount');
|
||||
|
||||
$wallet_total_outgoing = Transaction::where('owner_type', $query->first()->owner_type)
|
||||
->where('owner_id', $query->first()->owner_id)
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->whereIn('type', [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE])
|
||||
->sum('amount');
|
||||
|
||||
$currentWalletBalance = $wallet_total_incoming - $wallet_total_outgoing;
|
||||
$incoming = Transaction::where('owner_type', $query->first()->owner_type)
|
||||
->where('owner_id', $query->first()->owner_id)
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->whereIn('type', [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE, TransactionType::GROUP_PAYMENT])
|
||||
->where('id', '>', $query->first()->id)
|
||||
->sum('amount');
|
||||
$outgoing = Transaction::where('owner_type', $query->first()->owner_type)
|
||||
->where('owner_id', $query->first()->owner_id)
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->whereIn('type', [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE])
|
||||
->where('id', '>', $query->first()->id)
|
||||
->sum('amount');
|
||||
$runningBalanceInReverse = $currentWalletBalance - $incoming + $outgoing;
|
||||
$request['running_balance'] = $runningBalanceInReverse;
|
||||
}
|
||||
|
||||
return $this->collectionResponse(WalletTransactionResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class CreateWalletTopUpTransactionProcessor
|
||||
/**
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $companyModule, $amount, $bank_code, ?bool $groupTransaction = false)
|
||||
public function execute(CompanyModule $companyModule, $amount, $bank_code, ?int $payment_method = PaymentMethodType::PAYMENT_GATEWAY, ?string $payment_reference = null, ?bool $groupTransaction = false)
|
||||
{
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $companyModule->wallets()->first();
|
||||
@@ -82,7 +82,9 @@ class CreateWalletTopUpTransactionProcessor
|
||||
$billPlzBill = $this->createsBillplzBill->execute($companyModule->name, $user->email, 'This payment is credit topup for company ref. ' . $companyModule->reference, $amount, $billNumber, $bank_code, true);
|
||||
|
||||
// IF $groupTransaction, transaction type is GROUP_PAYMENT
|
||||
$transaction_object = new TransactionObject($billNumber, $groupTransaction? TransactionType::GROUP_PAYMENT: TransactionType::TOP_UP, 1, $companyModule->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id);
|
||||
// $transaction_object = new TransactionObject($billNumber, $groupTransaction? TransactionType::GROUP_PAYMENT: TransactionType::TOP_UP, 1, $companyModule->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id);
|
||||
// no more group payment
|
||||
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $companyModule->id, 1, $payment_method, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $payment_method === PaymentMethodType::PAYMENT_GATEWAY ? $billPlzBill->id : $payment_reference);
|
||||
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace App\Classes\Modules\Wallets\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
@@ -16,10 +18,24 @@ class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, $amount) {
|
||||
public function execute(Wallet $model, $amount)
|
||||
{
|
||||
$topups = 0;
|
||||
$credit = 0;
|
||||
$payments = 0;
|
||||
$debit = 0;
|
||||
|
||||
$model->amount = $model->amount + $amount;
|
||||
foreach ($model->transactions as $transaction) {
|
||||
if (!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) $topups += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::GROUP_PAYMENT) $topups += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
$auditBalance = ($topups + $credit) - ($payments + $debit);
|
||||
|
||||
$model->amount = $auditBalance;
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
@@ -53,12 +54,15 @@ class FixBillplzFailedCallbackPayment extends Command
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var CallbackBillplzProcessor */
|
||||
private $callbackBillplzProcessor;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, CallbackBillplzProcessor $callbackBillplzProcessor)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
@@ -66,6 +70,7 @@ class FixBillplzFailedCallbackPayment extends Command
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +87,7 @@ class FixBillplzFailedCallbackPayment extends Command
|
||||
|
||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
||||
|
||||
$transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
$transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP, TransactionType::GROUP_PAYMENT])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
|
||||
if ($totalTransactions) {
|
||||
@@ -96,84 +101,15 @@ class FixBillplzFailedCallbackPayment extends Command
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
$totalAmount += $transaction->amount;
|
||||
$invoiceStatus = null;
|
||||
if($data['paid']) {
|
||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
switch($transaction->owner->status) {
|
||||
case 3:
|
||||
$invoiceStatus = 'Payment Completed';
|
||||
break;
|
||||
case 5:
|
||||
$invoiceStatus = 'Dispute in progress';
|
||||
break;
|
||||
case 6:
|
||||
$invoiceStatus = 'Cancelled Invoice';
|
||||
break;
|
||||
default:
|
||||
$invoiceStatus = 'Pending Payment';
|
||||
if($data['state'] === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
$order = $transaction->owner->owner->owner;
|
||||
|
||||
if (in_array($invoiceStatus , ['Pending Payment', 'Payment Completed'])) {
|
||||
// code here
|
||||
|
||||
// $billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId());
|
||||
|
||||
// if(!$billPlz) throw new ResourceNotFoundException('Billplz bill not found.');
|
||||
|
||||
// $transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
|
||||
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
if($data['state'] === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
// if($data->state === 'due') {
|
||||
// $status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||
// }
|
||||
|
||||
// $token = Auth::fromUser(User::find(1));
|
||||
// $request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
$this->info('Updated invoice ' . $counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
||||
} else {
|
||||
$this->info('Failed to update invoice due to unsufficeint payment ' . $counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if(!$order instanceof Order) {
|
||||
$this->info("Error transaction id:" . $transaction->id . 'Type: ' . get_class($order));
|
||||
} else {
|
||||
$this->info($counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// $totalAmount += $transaction->amount;
|
||||
// $this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
||||
$this->info(Carbon::now() . ' : Fixing ' . $transaction->payment_reference);
|
||||
$this->callbackBillplzProcessor->execute($transaction, $status);
|
||||
}
|
||||
}else{
|
||||
$this->info("billplz error</br>");
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ShowFailediBllplzCallback extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'show-failed-billplz-callback';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Show all failled callback from billplz';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$start = new Carbon();
|
||||
|
||||
$transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP, TransactionType::GROUP_PAYMENT])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
|
||||
if ($totalTransactions) {
|
||||
$this->info(Carbon::now() . ' : ' . $this->description);
|
||||
}
|
||||
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
dump($transaction->payment_reference);
|
||||
dump($transaction->id);
|
||||
}
|
||||
}else{
|
||||
$this->info("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
if ($totalTransactions) {
|
||||
$this->info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Exports;
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsCustomersWalletTransactionHistory;
|
||||
use App\Models\User;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
class ExportCustomersWalletTransactionToExcelController
|
||||
{
|
||||
|
||||
/**
|
||||
* ExportCustomersWalletTransactionToExcelController constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer ' . $token);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$exportsTransactions = new ExportsCustomersWalletTransactionHistory($request);
|
||||
$wallet = Wallet::find($request->route('wallet_id'));
|
||||
$company_marking = $wallet->owner->connections->first()->invitee_reference;
|
||||
|
||||
$filename = $company_marking . '-wallet-' . ($request->route('is_precise') == 'true' ? 'precise-' : '') . 'transaction-history.xls';
|
||||
$response = $exportsTransactions->download($filename, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\DeletePaymentTransactionLogic;
|
||||
|
||||
|
||||
class DeletePaymentTransactionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeletePaymentTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeletePaymentTransactionLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\ListWalletTransactionsLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class ListWalletTransactionsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListWalletTransactionsLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListWalletTransactionsLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -19,6 +20,7 @@ class GroupResource extends JsonResource
|
||||
{
|
||||
|
||||
// dd($this->groupTransactions);
|
||||
$payment_transaction = Transaction::where('payment_reference', $this->reference)->first();
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
@@ -37,6 +39,12 @@ class GroupResource extends JsonResource
|
||||
'payment_method_name' => ucwords(PaymentMethodType::PAYMENT_METHODS_ID[$this->payment_method]),
|
||||
'invoices' => GroupTransactionResource::collection($this->groupTransactions),
|
||||
'reference' => $this->reference,
|
||||
'payment_transaction' => $payment_transaction ? [
|
||||
'id' => $payment_transaction->id,
|
||||
'status' => $payment_transaction->status,
|
||||
'status_name' => ApprovalStatus::APPROVAL_STATUS_ID[$payment_transaction->status],
|
||||
'documents' => $this->status === ApprovalStatus::APPROVED ? DocumentResource::collection($payment_transaction->documents->where('status', ApprovalStatus::APPROVED)) : DocumentResource::collection($payment_transaction->documents->where('status', ApprovalStatus::PENDING_VERIFICATION)),
|
||||
] : []
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace App\Http\Resources;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Group;
|
||||
use App\Models\Order;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -20,11 +22,28 @@ class TransactionResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$order = null;
|
||||
$groupTransactions = null;
|
||||
|
||||
if ($this->owner instanceof Transaction) {
|
||||
$order = new OrderResource($this->owner->owner->owner);
|
||||
} else if (!($this->owner instanceof Transaction) && !($this->owner instanceof Wallet)) {
|
||||
$order = new OrderResource($this->owner->owner);
|
||||
} else {
|
||||
$group = Group::where('reference', $this->payment_reference)->first();
|
||||
if ($group) {
|
||||
$groupTransactions = GroupTransactionResource::collection($group->groupTransactions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'owner_type' => $this->owner_type,
|
||||
'order' => ($this->owner instanceof Transaction) ? new OrderResource($this->owner->owner->owner) : new OrderResource($this->owner->owner),
|
||||
'documents' => DocumentResource::collection($this->documents),
|
||||
'order' => $order,
|
||||
'group_transactions' => $groupTransactions,
|
||||
'group_reference' => $groupTransactions ? $group->reference : null,
|
||||
'documents' => $groupTransactions ? DocumentResource::collection($this->documents->where('status', ApprovalStatus::PENDING_VERIFICATION)) : DocumentResource::collection($this->documents),
|
||||
'type' => (int) $this->type,
|
||||
'bill_no' => $this->bill_no,
|
||||
'amount' => (double) $this->amount,
|
||||
|
||||
@@ -23,7 +23,7 @@ class WalletResource extends JsonResource
|
||||
'amount' => (double) $this->amount,
|
||||
'company_id' => (int) $this->owner->id,
|
||||
'transactions' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->get()), []),
|
||||
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('type', [TransactionType::TOP_UP])->orderBy('id', 'DESC')->get()), []),
|
||||
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('type', [TransactionType::TOP_UP, TransactionType::GROUP_PAYMENT])->orderBy('id', 'DESC')->get()), []),
|
||||
'company_module_marking' => $this->owner->connections->first()->invitee_reference,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -20,12 +20,15 @@ class WalletTransactionResource extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
$description = '';
|
||||
$current_running_balance = $request['running_balance'];
|
||||
switch((int) $this->type){
|
||||
case TransactionType::TOP_UP:
|
||||
$description = (double) $this->amount.' Credit Top up';
|
||||
$request['running_balance'] = bcsub($request['running_balance'], $this->amount, 5);
|
||||
break;
|
||||
case TransactionType::CREDIT_NOTE:
|
||||
$description = 'Credit Voucher for '.$this->payment_reference;
|
||||
$request['running_balance'] = bcsub($request['running_balance'], $this->amount, 5);
|
||||
break;
|
||||
case TransactionType::PAYMENT:
|
||||
$order = Transaction::where('payment_reference', $this->bill_no)->first()->owner->owner->owner;
|
||||
@@ -35,13 +38,16 @@ class WalletTransactionResource extends JsonResource
|
||||
break;
|
||||
}
|
||||
|
||||
$request['running_balance'] = bcadd($request['running_balance'], $this->amount, 5);
|
||||
$marking = $order->reference;
|
||||
$description = 'Payment For order refs.'.'<a href="'.route('order.details', $marking).'">'.$marking.'</a>';
|
||||
break;
|
||||
case 11:
|
||||
$request['running_balance'] = bcadd($request['running_balance'], $this->amount, 5);
|
||||
$description = 'Debit Voucher for '.$this->payment_reference;
|
||||
break;
|
||||
case 15:
|
||||
$request['running_balance'] = bcsub($request['running_balance'], $this->amount, 5);
|
||||
$description = (double) $this->amount.' Credit Top up';
|
||||
break;
|
||||
|
||||
@@ -56,6 +62,7 @@ class WalletTransactionResource extends JsonResource
|
||||
'payment_method' => (float) $this->payment_method,
|
||||
// 'issuer_name' => $this->issuerCompany->name,
|
||||
'amount' => (double) $this->amount,
|
||||
'running_balance' => (double) $current_running_balance,
|
||||
'service_charge' => (double) $this->service_charge,
|
||||
'tax' => (double) $this->tax,
|
||||
'status' => (int) $this->status,
|
||||
|
||||
@@ -4,10 +4,12 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class GroupTransaction extends Model
|
||||
{
|
||||
protected $table = 'group_transactions';
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
@@ -105,7 +105,7 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
*/
|
||||
public function scopePayments(Builder $query)
|
||||
{
|
||||
return $query->where('type', TransactionType::PAYMENT);
|
||||
return $query->whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+26
-7
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="row m-b-15 m-l-5 m-r-10">
|
||||
<div class="row m-b-15 m-l-5 m-r-10 parentContainer">
|
||||
<div class="col bg-white rounded b-a" :class="{'b-white': !selected, 'b-primary': selected, 'bg-primary-lighter': selected, 'b-danger': item.status != 2, 'b-success': item.status == 2}">
|
||||
<div class="row">
|
||||
<div class="row parentContainer">
|
||||
<div class="col padding-20">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
@@ -43,16 +43,38 @@
|
||||
</general-confirmation-form-component>
|
||||
</modal-component>
|
||||
<!-- payment method 1 -->
|
||||
<!-- <div class="col-auto pointer btn btn-success requestModal pointer" v-if="item.payment_method == 1 && item.status != 2" data-type="paymentProofModal" @click="selectedID(item.id)">
|
||||
<div class="col-auto pointer btn btn-success requestModal pointer" v-if="item.payment_method == 1 && [0, 4].includes(item.payment_transaction.status)" data-type="paymentProofModal" @click="selectedID(item.id)">
|
||||
<div class="no-border h-100">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="30" height="30" viewBox="0 0 172 172" style=" fill:#000000;"><defs><linearGradient x1="86" y1="70.76994" x2="86" y2="116.46013" gradientUnits="userSpaceOnUse" id="color-1_52139_gr1"><stop offset="0" stop-color="#ffffff"></stop><stop offset="1" stop-color="#ffffff"></stop></linearGradient><linearGradient x1="61.8125" y1="34.48869" x2="61.8125" y2="144.97181" gradientUnits="userSpaceOnUse" id="color-2_52139_gr2"><stop offset="0" stop-color="#ffffff"></stop><stop offset="1" stop-color="#ffffff"></stop></linearGradient><linearGradient x1="130.34375" y1="34.48869" x2="130.34375" y2="144.97181" gradientUnits="userSpaceOnUse" id="color-3_52139_gr3"><stop offset="0" stop-color="#ffffff"></stop><stop offset="1" stop-color="#ffffff"></stop></linearGradient><linearGradient x1="86" y1="32.25" x2="86" y2="148.71013" gradientUnits="userSpaceOnUse" id="color-4_52139_gr4"><stop offset="0" stop-color="#ffffff"></stop><stop offset="1" stop-color="#ffffff"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M102.45825,99.43213h-5.70825c-1.4835,0 -2.6875,1.16637 -2.6875,2.65256v8.10013c0,1.48081 -1.19862,2.68481 -2.67944,2.68481h-10.76612c-1.48081,0 -2.67944,-1.204 -2.67944,-2.68481v-8.10013c0,-1.48619 -1.204,-2.65256 -2.6875,-2.65256h-5.70825c-1.93769,0 -3.04225,-2.39188 -1.88125,-4.05275l14.577,-20.855c1.8275,-2.61494 5.69481,-2.61763 7.52231,-0.00538l14.577,20.86306c1.16369,1.66088 0.05644,4.05006 -1.87856,4.05006z" fill="url(#color-1_52139_gr1)"></path><path d="M51.0625,67.1875h5.375c0,-8.0625 7.23206,-16.12231 16.125,-16.12231v-5.375c-11.85456,0 -21.5,10.74731 -21.5,21.49731z" fill="url(#color-2_52139_gr2)"></path><path d="M139.75,80.625c0,-10.75 -8.44144,-18.80981 -18.8125,-18.80981v5.375c7.40944,0 13.4375,5.37231 13.4375,13.43481z" fill="url(#color-3_52139_gr3)"></path><path d="M148.09738,92.27263c1.59369,-3.68188 2.40263,-7.59219 2.40263,-11.64494c0,-16.29969 -13.26281,-29.5625 -29.5625,-29.5625c-6.5145,0 -12.68769,2.08819 -17.78588,5.96088c-4.30269,-13.03438 -16.52006,-22.08587 -30.58912,-22.08587c-17.78319,0 -32.25,14.46681 -32.25,32.25c0,4.14681 0.16662,8.05981 1.42437,10.74731h-1.42437c-13.33806,0 -24.1875,10.84944 -24.1875,24.1875c0,11.56431 8.16194,21.24737 19.0275,23.62044c1.02394,6.39894 6.53869,11.31706 13.2225,11.31706h56.4375h16.125h5.375c6.54944,0 12.00238,-4.71388 13.18488,-10.92469c9.2235,-1.20131 16.37762,-9.08913 16.37762,-18.63513c0,-6.09256 -2.924,-11.72019 -7.77762,-15.23006zM126.3125,131.6875h-5.375h-16.125h-56.4375c-3.49912,0 -6.45538,-2.6875 -7.568,-5.375h93.0735c-1.11263,2.6875 -4.06888,5.375 -7.568,5.375zM137.0625,120.9375h-96.75c-10.37106,0 -18.8125,-8.44144 -18.8125,-18.8125c0,-10.37106 8.44144,-18.8125 18.8125,-18.8125h9.51375l-1.68506,-3.78131c-2.23063,-5.01488 -2.45369,-7.48737 -2.45369,-12.341c0,-14.81888 12.05613,-26.875 26.875,-26.875c13.01825,0 24.13106,9.29875 26.42619,22.11275l0.92719,5.17075l3.64962,-3.77325c4.60638,-4.76225 10.77687,-7.38525 17.372,-7.38525c13.33806,0 24.1875,10.84944 24.1875,24.1875c0,3.6765 -0.81431,7.21056 -2.37575,10.41944l-1.763,3.32713l2.37037,1.26044c4.40481,2.34081 7.14338,6.88806 7.14338,11.868c0,7.40944 -6.02806,13.43481 -13.4375,13.43481z" fill="url(#color-4_52139_gr4)"></path></g></g></svg>
|
||||
</div>
|
||||
</div>
|
||||
<modal-component type="paymentProofModal">
|
||||
<payment-verification-form-component v-if="selected_id === item.id" :section="section" :data="{...item, id: item.payment_transaction.id}"></payment-verification-form-component>
|
||||
</modal-component>
|
||||
<div class="col-auto" v-if="item.payment_method == 1 && [1, 2].includes(item.payment_transaction.status)">
|
||||
<div class="fs-10 all-caps">Payment Proof</div>
|
||||
<div v-if="item.payment_transaction.documents.length">
|
||||
<div v-for="file in item.payment_transaction.documents[0].files" v-bind:key="file.id" class="col-auto no-padding">
|
||||
<document-file-viewer-component :file="file">
|
||||
<template slot="button">
|
||||
<div class="icon-thumbnail fs-11 text-white icon-25 bg-primary btn-rounded float-left m-r-5">
|
||||
<i class="fa fa-file-pdf-o"></i>
|
||||
</div>
|
||||
</template>
|
||||
</document-file-viewer-component>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="btn bg-grey no-border muted invisible">
|
||||
<i class="fa fa-file-pdf-o"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto pointer btn btn-success invisible" v-else>
|
||||
<div class=" no-border h-100">
|
||||
<i class="fa fa-repeat fs-20 text-white"></i>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="btn bg-grey no-border" @click="expanded = !expanded">
|
||||
<i class="fa" :class="{'fa-angle-down': !expanded, 'fa-angle-up': expanded}" ></i>
|
||||
@@ -66,9 +88,6 @@
|
||||
<payments-billing-components :section="section" v-for="invoice in data.invoices" v-bind:key="invoice.id" :data="invoice" :selectedInvoice="selectedInvoice" v-on:input="updateList($event)"></payments-billing-components>
|
||||
</div>
|
||||
</div>
|
||||
<modal-component type="paymentProofModal">
|
||||
<payment-verification-form-component v-if="selected_id === item.id" :section="section" :data="item"></payment-verification-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+20
-1
@@ -3,7 +3,7 @@
|
||||
<div class="col">
|
||||
<div class="row" v-if="!item.transaction_bill">
|
||||
<div class="col">
|
||||
<div class="row bg-white ">
|
||||
<div class="row bg-white parentContainer">
|
||||
<div class="col p-t-10 p-b-10 p-r-0 pointer" @click="clickExpand()" :class="[{'bg-master-lighter': item.status === 1 && item.type !== 6}, {'bg-white': item.status !== 1 && item.status !== 4}, {'bg-warning-lighter': item.type === 6}]">
|
||||
<div class="row m-b-5">
|
||||
<div class="col-auto">
|
||||
@@ -43,6 +43,25 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto" v-if="$store.getters.isSuperAdmin">
|
||||
<div class="row align-items-center h-100 bg-danger pointer requestModal" data-type="deleteInvoiceFunction">
|
||||
<div class="col">
|
||||
<i class="fa fa-times text-white"></i>
|
||||
</div>
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="deleteInvoiceFunction">
|
||||
<general-confirmation-form-component
|
||||
contentText="Are you sure you want to delete this Payment?"
|
||||
modalType="delete"
|
||||
buttonText="Delete"
|
||||
class="text-center"
|
||||
:apiRoute="route('api.transaction.payment.delete', item.id)"
|
||||
apiMethod="delete"
|
||||
:section="section"
|
||||
>
|
||||
</general-confirmation-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center m-b-25" v-if="item.status === 0 && item.payment_method === 1">
|
||||
<div class="col-auto p-r-0">
|
||||
|
||||
+70
-10
@@ -2,25 +2,39 @@
|
||||
<div class="row m-b-10 parentContainer">
|
||||
<div class="col">
|
||||
<loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
|
||||
<div class="row p-b-5 b-b b-grey" v-show="!isLoading">
|
||||
<div class="row p-1 b-b b-grey" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col-auto">
|
||||
<div class="col-auto p-l-0">
|
||||
<div class="font-heading fs-10 muted all-caps">Date</div>
|
||||
<div class="font-heading fs-10">
|
||||
{{ item.updated_at }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-10 muted all-caps">Order</div>
|
||||
<div class="font-heading fs-10"><a :href="route('order.show' , item.order.reference)" target="_blank">{{item.order.reference}}</a></div>
|
||||
<div v-if="item.order">
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-10 muted all-caps">Order</div>
|
||||
<div class="font-heading fs-10"><a :href="route('order.show' , item.order.reference)" target="_blank">{{item.order.reference}}</a></div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-10 muted all-caps">Customer</div>
|
||||
<div class="font-heading fs-10">
|
||||
<a :href="route('customer.profile', item.order.company_module.marking)">{{item.order.company_module.marking}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-10 muted all-caps">Customer</div>
|
||||
<div class="font-heading fs-10">
|
||||
<a :href="route('customer.profile', item.order.company_module.marking)">{{item.order.company_module.marking}}</a>
|
||||
<div v-if="item.group_transactions">
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-10 muted all-caps">Group Payment</div>
|
||||
<div class="font-heading fs-10">{{item.group_reference}}</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="font-heading fs-10 muted all-caps">Customer</div>
|
||||
<div class="font-heading fs-10">
|
||||
<a :href="route('customer.profile', item.group_transactions[0].order.company_module.marking)">{{item.group_transactions[0].order.company_module.marking}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col text-right">
|
||||
@@ -31,7 +45,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<div class="col p-l-0">
|
||||
<div class="font-heading fs-10 muted all-caps">Payment Proof</div>
|
||||
<div class="row no-margin" v-if="item.payment_method !==5 && item.payment_method !==4">
|
||||
<div v-for="file in item.documents[0].files" v-bind:key="file.id" class="col-auto no-padding">
|
||||
@@ -132,6 +146,47 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-10 m-b-10" v-if="item.group_transactions">
|
||||
<div class="col text-center p-l-0">
|
||||
<div id="expend-method" class="padding-10 bg-master-lightest pointer" @click="expanded = !expanded">
|
||||
<i class="fa m-r-10" :class="[{'fa-angle-up': expanded}, {'fa-angle-down': !expanded}]"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-t b-grey p-t-10" v-show="expanded" v-if="item.group_transactions">
|
||||
<div class="col">
|
||||
<div class="row p-b-10 b-b b-grey" v-for="(invoice, index) in item.group_transactions">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
<p class="no-margin fs-10 all-caps">{{ index + 1 }}.</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps bold">Invoice No</p>
|
||||
<div class="fs-10">{{ invoice.bill_no }}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps bold">Order</p>
|
||||
<div class="fs-10"><a :href="route('order.show', invoice.order.reference)">{{invoice.order.reference}}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
<p class="no-margin fs-10 all-caps bold"></p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps bold">Invoice Date</p>
|
||||
<div class="fs-10">{{ invoice.created_at }}</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps bold">Amount</p>
|
||||
<div class="font-heading fs-14 text-success bold">{{ invoice.amount.toFixed(2) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -147,6 +202,11 @@
|
||||
props: {
|
||||
no_action: Boolean
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
expanded: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
approvePayment(status){
|
||||
this.isLoading = true;
|
||||
|
||||
+57
-54
File diff suppressed because one or more lines are too long
+81
-18
@@ -9,6 +9,43 @@
|
||||
<h6>Transaction History</h6>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-10 m-b-10">
|
||||
<div class="col">
|
||||
<div class="d-flex align-items-center h-100">
|
||||
<span class="btn btn-md fs-11 bg-primary text-white fs-12 m-r-5" :class="[{'bg-primary-darker': showingPreciseAmount}]" @click="showingPreciseAmount=!showingPreciseAmount">{{ showingPreciseAmount ? 'Showing Precise Wallet Transaction' : 'Show Precise Wallet Transaction'}}</span>
|
||||
<a v-if="wallet" :href="route('wallet.details-export', wallet.id, showingPreciseAmount)" target="_blank" class="btn btn-md btn-primary fs-11"><i class="fa fa-download m-r-5"></i>{{ showingPreciseAmount ? 'Download Precise Transaction' : 'Download Transaction'}}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<validation-wrapper-component selectable :validator="$v.showingTransactionCount">
|
||||
<label>Showing Rows</label>
|
||||
<select-component :options="[5, 10, 20, 30, 50]" v-model="showingTransactionCount"></select-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5" @keyup.enter="submitSearch">
|
||||
<div class="col p-r-0">
|
||||
<validation-wrapper-component :validator="$v.reference_no">
|
||||
<label class="all-caps">Order Reference</label>
|
||||
<input type="text" class="form-control" v-model="reference_no">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col p-r-0">
|
||||
<validation-wrapper-component :validator="$v.startDate">
|
||||
<label class="all-caps">Start Date</label>
|
||||
<date-picker-component v-model.lazy="startDate"></date-picker-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col p-r-0">
|
||||
<validation-wrapper-component :validator="$v.endDate">
|
||||
<label class="all-caps">End Date</label>
|
||||
<date-picker-component v-model.lazy="endDate"></date-picker-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col col-md-auto d-flex justify-content-center align-items-center">
|
||||
<button type="button" class="btn btn-lg btn-primary fs-11 w-100" @click="submitSearch()">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="wallet.transactions">
|
||||
<div class="col">
|
||||
<div class="row padding-10">
|
||||
@@ -19,13 +56,11 @@
|
||||
<div class="col-2 fs-10 text-right">Balance</div>
|
||||
</div>
|
||||
|
||||
<div class="row bg-white padding-10 m-b-10 rounded align-items-center" v-for="(item, index) in wallet.transactions" v-bind:key="item.id" :data="item">
|
||||
<div class="col-3 fs-12">{{item.created_at}}</div>
|
||||
<div class="col fs-12"><span v-html="item.description"></span> <a target=”_blank” v-if="[9,11].includes(item.type) " :href="route('transaction.credit_note.download', item.id)"><i class="fa fa-download fs-11 m-l-5 text-secondary hover-primary"></i></a></div>
|
||||
<div class="col-2 text-success text-center">{{[5, 9, 15].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
|
||||
<div class="col-2 text-danger text-center">{{[2, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
|
||||
<div class="col-2 text-right">{{remainingBalance(index)}}</div>
|
||||
</div>
|
||||
<list-component :key="key" section="walletTransactionSection" :endpoint="route('api.transaction.wallet.list')" :options="options">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<customer-wallet-transaction-component :data="data" :showingPreciseAmount="showingPreciseAmount" ></customer-wallet-transaction-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -103,10 +138,22 @@ export default {
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
key: 1,
|
||||
section: 'customerTransactionSection',
|
||||
isLoading: true,
|
||||
wallet: null,
|
||||
attention: false
|
||||
showingPreciseAmount: false,
|
||||
showingTransactionCount: 10,
|
||||
attention: false,
|
||||
reference_no: null,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
options: {
|
||||
status_in: [2, 3],
|
||||
owner_type: 'App\\Models\\Wallet',
|
||||
owner_id: 0,
|
||||
per_page: this.showingTransactionCount
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -119,8 +166,17 @@ export default {
|
||||
if(inComplete){
|
||||
this.fetchWallet();
|
||||
}
|
||||
},
|
||||
showingTransactionCount() {
|
||||
this.key ++;
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
showingTransactionCount: { },
|
||||
reference_no: { },
|
||||
startDate: { },
|
||||
endDate: { },
|
||||
},
|
||||
created(){
|
||||
this.$store.dispatch('updateListQueue', {'name': this.section});
|
||||
},
|
||||
@@ -130,22 +186,29 @@ export default {
|
||||
var filters = {with_transactions: true};
|
||||
this.submit(route('api.wallet.company_module.show', this.id) + '?filters=' + JSON.stringify(filters), 'get', this.section, false, false);
|
||||
},
|
||||
remainingBalance(index) {
|
||||
let tempBalance = 0;
|
||||
submitSearch() {
|
||||
console.log("searcvhing");
|
||||
delete this.options.with_order_reference_like;
|
||||
delete this.options.created_after_or_equal;
|
||||
delete this.options.created_before_or_equal;
|
||||
|
||||
if(this.wallet){
|
||||
let transactions = this.wallet.transactions.slice().reverse();
|
||||
transactions.slice(0, transactions.length - index).map(function(transaction) {
|
||||
[2, 11].includes(transaction.type) ? tempBalance -= (transaction.amount) : tempBalance += (transaction.amount);
|
||||
return tempBalance
|
||||
}, 0);
|
||||
if (this.reference_no) {
|
||||
this.options.with_order_reference_like = this.reference_no
|
||||
}
|
||||
|
||||
return (Math.round((tempBalance + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
if (this.startDate) {
|
||||
this.options.created_after_or_equal = this.startDate
|
||||
}
|
||||
if (this.endDate) {
|
||||
this.options.created_before_or_equal = this.endDate
|
||||
}
|
||||
|
||||
this.key ++;
|
||||
},
|
||||
successHandler(response){
|
||||
this.isLoading = false;
|
||||
this.wallet = response.payload.data;
|
||||
this.options.owner_id = this.wallet.id
|
||||
this.key ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<div class="row bg-white padding-10 m-b-10 rounded align-datas-center">
|
||||
<div class="col-3 fs-12">{{data.created_at}}</div>
|
||||
<div class="col fs-12"><span v-html="data.description"></span> <a target=”_blank” v-if="[9,11].includes(data.type) " :href="route('transaction.credit_note.download', data.id)"><i class="fa fa-download fs-11 m-l-5 text-secondary hover-primary"></i></a></div>
|
||||
<div class="col-2 text-success text-center">{{[5, 9, 15].includes(parseFloat(data.type)) ? formatValue(data.amount) : ''}}</div>
|
||||
<div class="col-2 text-danger text-center">{{[2, 11].includes(parseFloat(data.type)) ? '- ' + formatValue(data.amount, ) : ''}}</div>
|
||||
<div class="col-2 text-right">{{formatValue(data.running_balance)}}</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
data: {
|
||||
required: true,
|
||||
type: Object
|
||||
},
|
||||
showingPreciseAmount: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatValue(value) {
|
||||
if (this.showingPreciseAmount) {
|
||||
return (Math.round((parseFloat(value) + Number.EPSILON) * 100000) / 100000).toLocaleString('en-US', { minimumFractionDigits: 5, maximumFractionDigits: 5 });
|
||||
}
|
||||
|
||||
return (Math.round((parseFloat(value) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler],
|
||||
}
|
||||
</script>
|
||||
@@ -61,7 +61,7 @@
|
||||
</div> --}}
|
||||
</div>
|
||||
<div class="row no-margin">
|
||||
<div class="col bg-white padding-25">
|
||||
<div class="col bg-white p-t-10">
|
||||
<div class="row tabsContainer tabContent" tab-name="payments">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
|
||||
@@ -7,8 +7,11 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' =>
|
||||
Route::get('/list', 'ListTransactionsController@list')->name('list');
|
||||
Route::delete('/suspend/{id}', 'SuspendTransactionController@suspend')->name('suspend');
|
||||
Route::delete('/delete/{id}', 'DeleteTransactionController@delete')->name('delete');
|
||||
Route::delete('/delete-payment/{id}', 'DeletePaymentTransactionController@delete')->name('payment.delete');
|
||||
Route::put('{id}/status/update/{status}', 'UpdateTransactionStatusController@update')->where('status', 'approve|expire|reject')->name('update');
|
||||
|
||||
Route::get('wallet/list', 'ListWalletTransactionsController@list')->name('wallet.list');
|
||||
|
||||
Route::group(['prefix' => 'payment', 'as' => 'payment.'], function () {
|
||||
Route::post('/create', 'CreatePaymentTransactionController@create')->name('create');
|
||||
Route::post('/upload-verification-document/{transaction_id}', 'UploadPaymentVerificationDocumentController@upload')->name('verification.create');
|
||||
|
||||
+5
-19
@@ -436,7 +436,8 @@ Route::get('/warehouse/{id}/show', function ($id) {
|
||||
Route::get('/export/customer-latest-order-date/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export');
|
||||
Route::get('/export/packing-list/{id}', 'Exports\ExportContainerPackingListController@export')->name('container.packaging_list.export');
|
||||
Route::get('/export/pending-arrangement-delivery-list', 'Exports\ExportPendingArrangementPackingListV2Controller@export')->name('packaging_list.pending_arrangement.export');
|
||||
Route::get('/export/on-hold-packing-list', 'Exports\ExportPendingArrangementPackingListV2Controller@onHold')->name('packaging_list.on_hold.export');
|
||||
// Route::get('/export/on-hold-packing-list', 'Exports\ExportPendingArrangementPackingListV2Controller@onHold')->name('packaging_list.on_hold.export');
|
||||
Route::get('/export/on-hold-packing-list', 'Exports\ExportPendingArrangementPackingListController@onHold')->name('packaging_list.on_hold.export');
|
||||
Route::get('/export/arrived-parcel', 'Exports\ExportArrivedParcelController@export')->name('packing_list.arrived_parcel.export');
|
||||
Route::get('/export/parcel-summary', 'Exports\ExportArrivedParcelController@summary');
|
||||
Route::get('/export/parcel-postcode', 'Exports\ExportParcelPostcodesController@export');
|
||||
@@ -1067,6 +1068,8 @@ Route::get('/wallet/{marking}/details', function ($marking) {
|
||||
return view('pages.wallet.index', ['id' => $id, 'marking' => $marking]);
|
||||
})->name('wallet.details');
|
||||
|
||||
Route::get('/wallet/{wallet_id}/{is_precise}/export', 'Exports\ExportCustomersWalletTransactionToExcelController@export')->name('wallet.details-export');
|
||||
|
||||
Route::get('/wallet/audit', function (Request $request) {
|
||||
$wallets = \App\Models\Wallet::all();
|
||||
|
||||
@@ -1208,23 +1211,6 @@ Route::get('/404', function () {
|
||||
|
||||
Route::get('transaction/{id}/credit_note/download', 'Transactions\GenerateCreditNotePdfController@download')->name('transaction.credit_note.download');
|
||||
|
||||
Route::get('/check-successful-payment-or-topup', function () {
|
||||
$sum = 0 ;
|
||||
$transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP, TransactionType::GROUP_PAYMENT])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
foreach ($transactions as $transaction){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$sum += $transaction->amount;
|
||||
dump($transaction->payment_reference . 'Amount : ' . $transaction->amount);
|
||||
}else{
|
||||
dump("billplz error</br>");
|
||||
}
|
||||
}
|
||||
|
||||
dump("Sum is : " . $sum);
|
||||
});
|
||||
|
||||
Route::get('/wallets/active', function(){
|
||||
$wallets = Wallet::all();
|
||||
|
||||
@@ -1232,7 +1218,7 @@ Route::get('/wallets/active', function(){
|
||||
foreach ($wallets as $wallet){
|
||||
$companyMarking = $wallet->owner->getMarking();
|
||||
echo '<tr>';
|
||||
echo '<td><a href="'.route('wallet.details', $companyMarking).'" target="_blank">'.$companyMarking.'</a></td>';
|
||||
echo '<td><a href="'.route('wallet.details', $companyMarking).'" target="_blank">'.$companyMarking.'</a>'."(".$wallet->id.")".'</td>';
|
||||
echo '<td>'.$wallet->amount.'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user