mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-27 00:13:59 +00:00
fix bugs
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class IsMappedWithMultiple implements Filter
|
||||
@@ -14,7 +15,10 @@ class IsMappedWithMultiple implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $value ? $builder->has('owners', '>', 1) : $builder->has('owners', '=',1);
|
||||
$query = $builder->withCount(['owners' => function ($query){
|
||||
$query->where('status', ApprovalStatus::PENDING_VERIFICATION);
|
||||
}]);
|
||||
return $value ? $query->having('owners_count', '>', 1) : $query->having('owners_count', '=', 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class StatementTransactionOwnerStatusIn implements Filter
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('owners', function ($query) use ($value) {
|
||||
return $query->whereIn('status', $value);
|
||||
return $query->whereIn('statement_transaction_owners.status', $value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+230
-54
@@ -14,6 +14,7 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Accounting\Services\FetchesBankStatementDetails;
|
||||
use App\Classes\Modules\Accounting\Services\ListsBankStatementDetails;
|
||||
use App\Models\StatementTransactionOwner;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ApproveDuplicateBankStatementDetailsStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -29,79 +30,254 @@ class ApproveDuplicateBankStatementDetailsStatusLogic extends AbstractController
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsBankStatementDetails */
|
||||
private $listsBankStatementDetails;
|
||||
|
||||
/** @var FetchesBankStatementDetails */
|
||||
private $fetchesBankStatementDetails;
|
||||
|
||||
/** @var UpdatesBankStatementTransactionOwnerStatus */
|
||||
private $updatesBankStatementTransactionOwnerStatus;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/**
|
||||
* UpdateAnnouncementLogic constructor.
|
||||
* @param ListsBankStatementDetails $listsBankStatementDetails
|
||||
* @param FetchesBankStatementDetails $fetchesBankStatementDetails
|
||||
* @param UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(
|
||||
listsBankStatementDetails $listsBankStatementDetails,
|
||||
FetchesBankStatementDetails $fetchesBankStatementDetails,
|
||||
UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
) {
|
||||
$this->listsBankStatementDetails = $listsBankStatementDetails;
|
||||
$this->fetchesBankStatementDetails = $fetchesBankStatementDetails;
|
||||
public function __construct(UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus)
|
||||
{
|
||||
$this->updatesBankStatementTransactionOwnerStatus = $updatesBankStatementTransactionOwnerStatus;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Perform logic for approving or rejecting a statement transaction owner and handle matching records.
|
||||
// *
|
||||
// * @param Request $request The request object containing route parameters and data.
|
||||
// * @return JsonResponse The JSON response indicating the result of the logic.
|
||||
// */
|
||||
// public function logic(Request $request): JsonResponse
|
||||
// {
|
||||
// // Determine the status based on the 'status' route parameter
|
||||
// $status = $request->route('status') == 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED;
|
||||
//
|
||||
// // Find the statement transaction owner based on the 'id' route parameter
|
||||
// $owner = StatementTransactionOwner::find($request->route('id'));
|
||||
//
|
||||
// // Execute an update action to change the status of the owner
|
||||
// $this->updatesBankStatementTransactionOwnerStatus->execute($owner, $status);
|
||||
//
|
||||
// // If the status is 'approved', reject all other owners with the same system, owner type, and owner ID
|
||||
// if ($status === ApprovalStatus::APPROVED) {
|
||||
// StatementTransactionOwner::where('system', $owner->system)
|
||||
// ->where('owner_type', $owner->owner_type)
|
||||
// ->where('owner_id', $owner->owner_id)
|
||||
// ->where('id', '!=', $owner->id)
|
||||
// ->update(['status' => ApprovalStatus::REJECTED]);
|
||||
// }
|
||||
//
|
||||
// // Find all siblings (owners with the same statement transaction ID)
|
||||
// $siblings = StatementTransactionOwner::where('statement_transaction_id', $owner->statement_transaction_id)
|
||||
// ->where('id', '!=', $owner->id)
|
||||
// ->get();
|
||||
//
|
||||
// // Process each sibling
|
||||
// foreach ($siblings as $sibling) {
|
||||
//
|
||||
// // If the status is 'approved', reject the sibling and save the changes
|
||||
// if ($status === ApprovalStatus::APPROVED) {
|
||||
// $sibling->status = ApprovalStatus::REJECTED;
|
||||
// $sibling->save();
|
||||
// }
|
||||
//
|
||||
// // Find all twins (owners with the same system, owner type, and owner ID)
|
||||
// $twins = StatementTransactionOwner::where('system', $sibling->system)
|
||||
// ->where('owner_type', $sibling->owner_type)
|
||||
// ->where('owner_id', $sibling->owner_id)
|
||||
// ->where('id', '!=', $sibling->id)
|
||||
// ->get();
|
||||
//
|
||||
// // Process each twin
|
||||
// foreach ($twins as $twin) {
|
||||
// // Find all owners with the same statement transaction ID as the twin
|
||||
// $owners = StatementTransactionOwner::where('statement_transaction_id', $twin->statement_transaction_id)
|
||||
// ->where('id', '!=', $twin->id)
|
||||
// ->get();
|
||||
//
|
||||
// // If there is only one owner (the twin itself), execute an update action to change its status to 'approved'
|
||||
// if (count($owners) === 1) {
|
||||
// $this->updatesBankStatementTransactionOwnerStatus->execute($twin, ApprovalStatus::APPROVED);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Find all remaining matching owners for the related transaction
|
||||
// $remainingMatches = StatementTransactionOwner::where('system', $owner->system)
|
||||
// ->where('owner_type', $owner->owner_type)
|
||||
// ->where('owner_id', $owner->owner_id)
|
||||
// ->where('status', ApprovalStatus::PENDING_VERIFICATION) // Consider only pending owners
|
||||
// ->get();
|
||||
//
|
||||
// // Process each remaining match
|
||||
// foreach ($remainingMatches as $match) {
|
||||
// // Find all owners with the same statement transaction ID as the match
|
||||
// $owners = StatementTransactionOwner::where('statement_transaction_id', $match->statement_transaction_id)
|
||||
// ->where('id', '!=', $match->id)
|
||||
// ->get();
|
||||
//
|
||||
// // If there is only one owner (the match itself), execute an update action to change its status to 'approved'
|
||||
// if (count($owners) === 1) {
|
||||
// $this->updatesBankStatementTransactionOwnerStatus->execute($match, ApprovalStatus::APPROVED);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Return an empty response
|
||||
// return $this->response([]);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* Perform logic for approving or rejecting a statement transaction owner and handle matching records.
|
||||
*
|
||||
* @param Request $request The request object containing route parameters and data.
|
||||
* @return JsonResponse The JSON response indicating the result of the logic.
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$bankSatementDetails = $this->fetchesBankStatementDetails->execute(['id' => $request->route('id')]);
|
||||
// Determine the approval status
|
||||
$status = $this->getApprovalStatus($request);
|
||||
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($bankSatementDetails, ApprovalStatus::APPROVED);
|
||||
// Find the statement transaction owner
|
||||
$owner = $this->getOwner($request);
|
||||
|
||||
// todo-new: approve payments status, need to check the owner(if system is shipping, need to api with shipping portal)
|
||||
// if ($bankSatementDetails->transaction->type === StatementTransactionOwnerType::SALES) {
|
||||
// if ($bankSatementDetails->owner->status === ApprovalStatus::PENDING_VERIFICATION) {
|
||||
// $this->updatesTransactionStatus->execute($bankSatementDetails->owner, ApprovalStatus::APPROVED);
|
||||
// }
|
||||
// }
|
||||
// Update owner status
|
||||
$this->updateOwnerStatus($owner, $status);
|
||||
|
||||
$rejectedBankSatementDetails = $this->listsBankStatementDetails->execute(['id_not' => $request->route('id'), 'owner_id' => $bankSatementDetails->owner_id]);
|
||||
|
||||
if (count($rejectedBankSatementDetails) == 1) {
|
||||
$otherBankStatement = $rejectedBankSatementDetails->first();
|
||||
|
||||
$otherSetBankStatement = StatementTransactionOwner::where('system', $otherBankStatement->system)->where('owner_type', $otherBankStatement->owner_type)->where('owner_id', $otherBankStatement->owner_id)->get();
|
||||
foreach ($otherSetBankStatement as $otherStatement) {
|
||||
// todo: check is this id verification needed?
|
||||
if ($otherStatement->id == $request->route('id')) {
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($otherStatement, ApprovalStatus::REJECTED);
|
||||
} else {
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($otherStatement, ApprovalStatus::APPROVED);
|
||||
}
|
||||
}
|
||||
// If the status is 'approved', handle the approval process
|
||||
if ($status === ApprovalStatus::APPROVED) {
|
||||
$this->handleApprovedStatus($owner);
|
||||
}
|
||||
|
||||
foreach ($rejectedBankSatementDetails as $statement) {
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($statement, ApprovalStatus::REJECTED);
|
||||
}
|
||||
|
||||
dd($bankSatementDetails);
|
||||
// Check and approve remaining matches if any
|
||||
$this->checkAndApproveRemainingMatches($owner);
|
||||
|
||||
// Return an empty response
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
private function getApprovalStatus(Request $request): int
|
||||
{
|
||||
return $request->route('status') == 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED;
|
||||
}
|
||||
|
||||
private function getOwner(Request $request): StatementTransactionOwner
|
||||
{
|
||||
return StatementTransactionOwner::find($request->route('id'));
|
||||
}
|
||||
|
||||
private function updateOwnerStatus(StatementTransactionOwner $owner, int $status): void
|
||||
{
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($owner, $status);
|
||||
}
|
||||
|
||||
private function handleApprovedStatus(StatementTransactionOwner $owner): void
|
||||
{
|
||||
// Reject all other owners with the same system, owner type, and owner ID
|
||||
$this->rejectOtherOwners($owner);
|
||||
|
||||
// Find all siblings and process them
|
||||
$siblings = $this->getSiblings($owner);
|
||||
$this->processSiblings($siblings);
|
||||
}
|
||||
|
||||
private function rejectOtherOwners(StatementTransactionOwner $owner): void
|
||||
{
|
||||
StatementTransactionOwner::where('system', $owner->system)
|
||||
->where('owner_type', $owner->owner_type)
|
||||
->where('owner_id', $owner->owner_id)
|
||||
->where('id', '!=', $owner->id)
|
||||
->update(['status' => ApprovalStatus::REJECTED]);
|
||||
}
|
||||
|
||||
private function getSiblings(StatementTransactionOwner $owner): Collection
|
||||
{
|
||||
return StatementTransactionOwner::where('statement_transaction_id', $owner->statement_transaction_id)
|
||||
->where('id', '!=', $owner->id)
|
||||
->get();
|
||||
}
|
||||
|
||||
private function processSiblings(Collection $siblings): void
|
||||
{
|
||||
foreach ($siblings as $sibling) {
|
||||
$this->processSibling($sibling);
|
||||
}
|
||||
}
|
||||
|
||||
private function processSibling(StatementTransactionOwner $sibling): void
|
||||
{
|
||||
// Reject the sibling and save the changes
|
||||
$sibling->status = ApprovalStatus::REJECTED;
|
||||
$sibling->save();
|
||||
|
||||
// Find all twins and process them
|
||||
$twins = $this->getTwins($sibling);
|
||||
$this->processTwins($twins);
|
||||
}
|
||||
|
||||
private function getTwins(StatementTransactionOwner $sibling): Collection
|
||||
{
|
||||
return StatementTransactionOwner::where('system', $sibling->system)
|
||||
->where('owner_type', $sibling->owner_type)
|
||||
->where('owner_id', $sibling->owner_id)
|
||||
->where('id', '!=', $sibling->id)
|
||||
->get();
|
||||
}
|
||||
|
||||
private function processTwins(Collection $twins): void
|
||||
{
|
||||
foreach ($twins as $twin) {
|
||||
$this->processTwin($twin);
|
||||
}
|
||||
}
|
||||
|
||||
private function processTwin(StatementTransactionOwner $twin): void
|
||||
{
|
||||
// Find all owners with the same statement transaction ID as the twin
|
||||
$owners = $this->getOwners($twin);
|
||||
|
||||
// If there is only one owner (the twin itself), approve it
|
||||
if ($owners->count() === 1) {
|
||||
$this->updateOwnerStatus($twin, ApprovalStatus::APPROVED);
|
||||
}
|
||||
}
|
||||
|
||||
private function getOwners(StatementTransactionOwner $transactionOwner): Collection
|
||||
{
|
||||
return StatementTransactionOwner::where('statement_transaction_id', $transactionOwner->statement_transaction_id)
|
||||
->where('id', '!=', $transactionOwner->id)
|
||||
->get();
|
||||
}
|
||||
|
||||
private function checkAndApproveRemainingMatches(StatementTransactionOwner $owner): void
|
||||
{
|
||||
// Find all remaining matching owners for the related transaction
|
||||
$remainingMatches = $this->getRemainingMatches($owner);
|
||||
|
||||
// Process each remaining match
|
||||
foreach ($remainingMatches as $match) {
|
||||
$this->processRemainingMatch($match);
|
||||
}
|
||||
}
|
||||
|
||||
private function getRemainingMatches(StatementTransactionOwner $owner): Collection
|
||||
{
|
||||
return StatementTransactionOwner::where('system', $owner->system)
|
||||
->where('owner_type', $owner->owner_type)
|
||||
->where('owner_id', $owner->owner_id)
|
||||
->where('status', ApprovalStatus::PENDING_VERIFICATION)
|
||||
->get();
|
||||
}
|
||||
|
||||
private function processRemainingMatch(StatementTransactionOwner $match): void
|
||||
{
|
||||
// Find all owners with the same statement transaction ID as the match
|
||||
$owners = $this->getOwners($match);
|
||||
|
||||
// If there is only one owner (the match itself), approve it
|
||||
if ($owners->count() === 1) {
|
||||
$this->updateOwnerStatus($match, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-21
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Classes\Modules\Accounting\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounting\Services\ListsBankStatementTransactions;
|
||||
use App\Http\Resources\BankStatementTransactionResource;
|
||||
@@ -15,6 +16,7 @@ use App\Classes\ValueObjects\Constants\StatementTransactionOwnerType;
|
||||
class GroupApproveStatementTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -36,16 +38,12 @@ class GroupApproveStatementTransactionLogic extends AbstractControllerLogic
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/**
|
||||
* UpdateAnnouncementLogic constructor.
|
||||
* @param ListsBankStatementTransactions $listsBankStatementTransactions
|
||||
* @param UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(
|
||||
ListsBankStatementTransactions $listsBankStatementTransactions,
|
||||
UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
) {
|
||||
public function __construct(ListsBankStatementTransactions $listsBankStatementTransactions, UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||
{
|
||||
$this->listsBankStatementTransactions = $listsBankStatementTransactions;
|
||||
$this->updatesBankStatementTransactionOwnerStatus = $updatesBankStatementTransactionOwnerStatus;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
@@ -54,30 +52,35 @@ class GroupApproveStatementTransactionLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$statementTrasactions = $this->listsBankStatementTransactions->execute($this->listsBankStatementTransactions->deserializeFilters(
|
||||
json_decode("{min_amount: 0, is_mapped: true, is_mapped_with_multiple: false, statement_transaction_owner_type_in: [1, 2], statement_transaction_owner_status_in: [1], per_page: 100, order_by: {column: 'posting_date', DESC: true}}", true)
|
||||
));
|
||||
|
||||
foreach ($statementTrasactions as $statementTrasaction) {
|
||||
$statementTrasactionOwner = $statementTrasaction->owners;
|
||||
$filters = [
|
||||
"min_amount" => 0,
|
||||
"is_mapped" => true,
|
||||
"is_mapped_with_multiple" => false,
|
||||
"statement_transaction_owner_type_in" => [1, 2],
|
||||
"statement_transaction_owner_status_in" => [1]
|
||||
];
|
||||
$statementTransactions = $this->listsBankStatementTransactions->execute($filters);
|
||||
|
||||
if (count($statementTrasactionOwner)) {
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($statementTrasactionOwner->first(), ApprovalStatus::APPROVED);
|
||||
foreach ($statementTransactions as $statementTransaction) {
|
||||
$owners = $statementTransaction->owners;
|
||||
|
||||
if ($statementTrasactionOwner->owner->type !== StatementTransactionOwnerType::SALES) continue;
|
||||
if (count($owners)) {
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($owners->first(), ApprovalStatus::APPROVED);
|
||||
|
||||
if ($statementTrasactionOwner->owner->status === ApprovalStatus::PENDING_VERIFICATION ) {
|
||||
$this->updatesTransactionStatus->execute($statementTrasactionOwner->owner, ApprovalStatus::APPROVED);
|
||||
}
|
||||
// automatically approve payment if pending verification
|
||||
|
||||
// if ($statementTrasactionOwner->owner->type !== StatementTransactionOwnerType::SALES) continue;
|
||||
// if ($statementTrasactionOwner->owner->status === ApprovalStatus::PENDING_VERIFICATION ) {
|
||||
// $this->updatesTransactionStatus->execute($statementTrasactionOwner->owner, ApprovalStatus::APPROVED);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collectionResponse(BankStatementTransactionResource::collection($statementTrasactions));
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class ImportBankStatementLogic extends AbstractControllerLogic
|
||||
|
||||
$account->statements()->save($statement);
|
||||
|
||||
CreateBankStatementTransactionOwners::dispatch($statement);
|
||||
// CreateBankStatementTransactionOwners::dispatch($statement);
|
||||
|
||||
|
||||
$sheet->map(function ($row) use ($statement, $account) {
|
||||
|
||||
+1
-7
@@ -2,22 +2,18 @@
|
||||
|
||||
namespace App\Classes\Modules\Accounting\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\StatementTransactionOwnerType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\AccountStatement;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Company;
|
||||
use App\Models\Group;
|
||||
use App\Models\StatementTransaction;
|
||||
use App\Models\StatementTransactionOwner;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use DateTime;
|
||||
|
||||
class CreateBankStatementTransactionOwnersProcessor
|
||||
{
|
||||
@@ -29,7 +25,7 @@ class CreateBankStatementTransactionOwnersProcessor
|
||||
|
||||
$transactions = StatementTransaction::whereDoesntHave('owners', function($query){
|
||||
return $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
})->get();
|
||||
})->orderBy('posting_date')->get();
|
||||
|
||||
// $transactions = StatementTransaction::whereDoesntHave('owners')->where('amount', '<', 0)->get();
|
||||
|
||||
@@ -40,8 +36,6 @@ class CreateBankStatementTransactionOwnersProcessor
|
||||
// Exchange Sales
|
||||
$creditTransactions = $this->getTransactions($transaction->posting_date, $transaction->amount, TransactionType::PAYMENT, Booking::class, PaymentMethodType::WALLET, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
foreach ($creditTransactions as $creditTransaction) {
|
||||
dd($creditTransaction->owner);
|
||||
|
||||
$transaction->owners()->firstOrCreate([
|
||||
'type' => StatementTransactionOwnerType::SALES,
|
||||
'system' => 'EXCHANGE',
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\StatementTransactionOwnerType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
@@ -18,34 +19,28 @@ class BankStatementTransactionOwnerResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$reference = null;
|
||||
|
||||
$referenceLink = null;
|
||||
if($this->system === 'EXCHANGE') {
|
||||
if($this->owner_type === Transaction::class){
|
||||
$transaction = Transaction::find($this->owner_id);
|
||||
|
||||
if($transaction->owner_type === Booking::class){
|
||||
$reference = $transaction->owner->marking;
|
||||
$referenceLink = route('booking.details', $transaction->owner->marking);
|
||||
if($this->type === StatementTransactionOwnerType::SALES){
|
||||
$referenceLink = route('booking.details', $this->owner_reference);
|
||||
}
|
||||
|
||||
if($transaction->owner_type === Wallet::class) {
|
||||
$reference = $transaction->owner->owner->reference;
|
||||
$referenceLink = route('wallet.details', $transaction->owner->owner->reference);
|
||||
if($this->type === StatementTransactionOwnerType::WALLET_TOP_UP){
|
||||
$referenceLink = route('booking.details', $this->owner_reference);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->owner_type === Group::class){
|
||||
$transaction = Group::find($this->owner_id);
|
||||
$reference = $transaction->reference;
|
||||
// $referenceLink = route('booking.details', $transaction->owner->marking);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->system === 'SHIPPING_PORTAL') {
|
||||
if($this->owner_type === Transaction::class){
|
||||
$transaction = Transaction::find($this->owner_id);
|
||||
|
||||
if($this->type === StatementTransactionOwnerType::SALES){
|
||||
$referenceLink = 'https://izyim.cief-malaysia.com/order/show/'. $this->owner_reference;
|
||||
}
|
||||
if($this->type === StatementTransactionOwnerType::WALLET_TOP_UP){
|
||||
$referenceLink = 'https://izyim.cief-malaysia.com/wallet/'. $this->owner_reference .'/details';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +50,8 @@ class BankStatementTransactionOwnerResource extends JsonResource
|
||||
'system' => $this->system,
|
||||
'owner_type' => $this->owner_type,
|
||||
'owner_id' => $this->owner_id,
|
||||
'reference' => $this->owner_reference,
|
||||
'reference_link' => $referenceLink,
|
||||
'reference' => $reference,
|
||||
'invoice_reference' => $this->invoice_reference,
|
||||
'receipt_reference' => $this->receipt_reference,
|
||||
'status' => $this->status
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class BankStatementTransactionResource extends JsonResource
|
||||
@@ -30,7 +31,11 @@ class BankStatementTransactionResource extends JsonResource
|
||||
'transaction_description_3' => $this->transaction_description_3,
|
||||
'transaction_description_4' => $this->transaction_description_4,
|
||||
'transaction_description_5' => $this->transaction_description_5,
|
||||
'owners' => BankStatementTransactionOwnerResource::collection($this->owners)
|
||||
'owners' => [
|
||||
'approved' => BankStatementTransactionOwnerResource::collection($this->owners()->whereIn('status', [ApprovalStatus::APPROVED])->get()),
|
||||
'pending_verification' => BankStatementTransactionOwnerResource::collection($this->owners()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION])->get()),
|
||||
'rejected' => BankStatementTransactionOwnerResource::collection($this->owners()->whereIn('status', [ApprovalStatus::REJECTED])->get())
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class CreateStatementTransactionOwnersTable extends Migration
|
||||
$table->string('system')->nullable();
|
||||
$table->string('owner_type')->nullable();
|
||||
$table->bigInteger('owner_id')->nullable();
|
||||
$table->bigInteger('owner_reference')->nullable();
|
||||
$table->string('owner_reference')->nullable();
|
||||
$table->string('invoice_reference')->nullable();
|
||||
$table->string('receipt_reference')->nullable();
|
||||
$table->string('is_auto_mapped')->default(false);
|
||||
|
||||
+52
-38
@@ -1,44 +1,58 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<validation-wrapper-component :validator="$v.pay_for">
|
||||
<label>Pay For</label>
|
||||
<input type="text" class="form-control" v-model="pay_for" >
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<validation-wrapper-component :validator="$v.system_references">
|
||||
<label>System References</label>
|
||||
<input type="text" class="form-control" v-model="system_references" >
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-group row">
|
||||
<label>Date: {{ item.date }}</label>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label>Transaction Description 1: {{ item.transaction_description_1 }}</label>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label>Transaction Description 2: {{ item.transaction_description_2 }}</label>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label>Transaction Description 3: {{ item.transaction_description_3 }}</label>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label>Transaction Description 4: {{ item.transaction_description_4 }}</label>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label>Transaction Description 5: {{ item.transaction_description_5 }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="row ">
|
||||
<div class="col bg-white padding-15">
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.pay_for">
|
||||
<label>Pay For</label>
|
||||
<input type="text" class="form-control" v-model="pay_for" >
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.system_references">
|
||||
<label>System References</label>
|
||||
<input type="text" class="form-control" v-model="system_references" >
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label>Date: {{ item.posting_date }}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Transaction Description 1: {{ item.transaction_description_1 }}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Transaction Description 2: {{ item.transaction_description_2 }}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Transaction Description 3: {{ item.transaction_description_3 }}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Transaction Description 4: {{ item.transaction_description_4 }}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Transaction Description 5: {{ item.transaction_description_5 }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+41
-20
@@ -4,31 +4,31 @@
|
||||
<div class="row p-b-10 b-b b-grey">
|
||||
<div class="col-2">{{ item.posting_date }}</div>
|
||||
<div class="col-2">{{ item.transaction_description_1 + ' - ' + item.transaction_description_2 }}</div>
|
||||
<div class="col-5" v-if="item.owners.length === 1">
|
||||
<div class="col-5" v-if="item.owners.pending_verification.length === 1">
|
||||
<div class="row">
|
||||
<div class="col">{{item.owners[0].system}}</div>
|
||||
<div class="col">{{ typeString(item.owners[0].type) }}</div>
|
||||
<div class="col"><a :href="item.owners[0].reference_link" target="_blank">{{item.owners[0].reference}}</a></div>
|
||||
<div class="col">{{item.owners.pending_verification[0].system}}</div>
|
||||
<div class="col">{{ typeString(item.owners.pending_verification[0].type) }}</div>
|
||||
<div class="col"><a :href="item.owners.pending_verification[0].reference_link" target="_blank">{{item.owners.pending_verification[0].reference}}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-5" v-if="item.owners.length > 1">
|
||||
<div class="col-5" v-if="item.owners.pending_verification.length > 1">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row" v-for="owner in item.owners">
|
||||
<div class="row" v-for="owner in item.owners.pending_verification">
|
||||
<div class="col">
|
||||
{{ owner.system }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row" v-for="owner in item.owners">
|
||||
<div class="row" v-for="owner in item.owners.pending_verification">
|
||||
<div class="col">
|
||||
{{ typeString(owner.type) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row parentContainer" v-for="owner in item.owners">
|
||||
<div class="row parentContainer" v-for="owner in item.owners.pending_verification">
|
||||
<div class="col d-flex justify-content-between">
|
||||
<a :href="owner.reference_link" target="_blank">{{ owner.reference }}</a>
|
||||
<div v-if="stage === 2">
|
||||
@@ -36,13 +36,13 @@
|
||||
<i class="fa fa-check fa-fw"></i>
|
||||
</button>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" type="approveCorrectMappingTransaction">
|
||||
<general-confirmation-form-component
|
||||
:contentText="returnTextWithVariable(owner.reference)"
|
||||
modalType="confirm"
|
||||
<general-confirmation-form-component
|
||||
:contentText="returnTextWithVariable(owner.reference)"
|
||||
modalType="confirm"
|
||||
class="text-center"
|
||||
:apiRoute="route('api.accounting.bankStatement.details.status.update', owner.id, 'approve')"
|
||||
apiMethod="post"
|
||||
section="statementTransactionComponent"
|
||||
:section="section"
|
||||
>
|
||||
</general-confirmation-form-component>
|
||||
</modal-component>
|
||||
@@ -52,12 +52,33 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-5" v-if="!item.owners.length">
|
||||
<div class="col-5" v-if="!item.owners.pending_verification.length">
|
||||
<div class="row">
|
||||
<div class="col">N/A</div>
|
||||
<div class="col">N/A</div>
|
||||
<div class="col">N/A</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-xs btn-outline-success b-rad-none m-r-5 requestModal" data-type="updateOwner">
|
||||
<i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-xs btn-outline-success b-rad-none m-r-5 requestModal" data-type="updateOwner">
|
||||
<i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-xs btn-outline-success b-rad-none m-r-5 requestModal" data-type="updateOwner">
|
||||
<i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="updateOwner">
|
||||
<edit-single-item-in-list-component :data="item" :section="section"></edit-single-item-in-list-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-1">{{ item.amount }}</div>
|
||||
<div class="col-1" v-if="stage === 1">
|
||||
@@ -65,9 +86,9 @@
|
||||
<i class="fa fa-times fa-fw"></i>
|
||||
</button>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" type="deleteMappingTransaction">
|
||||
<general-confirmation-form-component
|
||||
contentText="Are you sure you want to reject this mapping?"
|
||||
modalType="delete"
|
||||
<general-confirmation-form-component
|
||||
contentText="Are you sure you want to reject this mapping?"
|
||||
modalType="delete"
|
||||
class="text-center"
|
||||
:apiRoute="route('api.accounting.statement_transaction.owner.status.update', item.id, 'reject')"
|
||||
apiMethod="post"
|
||||
@@ -128,7 +149,7 @@
|
||||
case 14:
|
||||
return 'Non-Operational Payment';
|
||||
}
|
||||
},
|
||||
},
|
||||
returnTextWithVariable(variable) {
|
||||
return "Are you sure you want to choose this mapping " + variable + "?";
|
||||
}
|
||||
|
||||
+11
-16
@@ -55,16 +55,16 @@
|
||||
<div class="col"></div>
|
||||
<div class="col-auto pointer bold text-danger" @click="step=0">X</div>
|
||||
</div>
|
||||
<div class="row parentContainer" v-if="step > 0 && stage !== 4">
|
||||
<div class="row parentContainer" v-show="step > 0 && stage !== 4">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div v-if="stage === 1">
|
||||
<div class="btn btn-primary btn-sm m-t-10 requestModal" data-type="approveMappingTransaction">Approve all the Mapping Below</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" type="approveMappingTransaction">
|
||||
<general-confirmation-form-component
|
||||
contentText="Are you sure you want to approve all these Transaction?"
|
||||
modalType="confirm"
|
||||
<general-confirmation-form-component
|
||||
contentText="Are you sure you want to approve all these Transaction?"
|
||||
modalType="confirm"
|
||||
class="text-center"
|
||||
:apiRoute="route('api.accounting.statement_transaction.owner.groupApprove')"
|
||||
apiMethod="post"
|
||||
@@ -89,9 +89,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<list-component ref="bankTransactionsList" section="bankTransactionSection" :endpoint="route('api.accounting.bank.transaction')" :options="this.filter">
|
||||
<list-component ref="bankTransactionsList" section="bankTransactionSection" :endpoint="route('api.accounting.bank.transaction')" :options="this.filter" :key="componentKey">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<statement-transaction-component :data="data" :section="section" :stage="stage"></statement-transaction-component>
|
||||
<statement-transaction-component :data="data" section="bankTransactionSection" :stage="stage"></statement-transaction-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
@@ -134,9 +134,6 @@
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
components: {},
|
||||
|
||||
|
||||
data(){
|
||||
return {
|
||||
type: null,
|
||||
@@ -145,17 +142,17 @@ export default {
|
||||
step: 0,
|
||||
filter: {},
|
||||
section: 'bankTransactionSection',
|
||||
componentKey: 1,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
startMapping(stage){
|
||||
|
||||
this.stage = stage;
|
||||
this.exportStage = 0;
|
||||
if(this.type === 1){
|
||||
switch(this.stage){
|
||||
case 1:
|
||||
this.filter = {min_amount: 0, is_mapped: true, is_mapped_with_multiple: false, statement_transaction_owner_type_in: [1, 2], statement_transaction_owner_status_in: [1], per_page: 100, order_by: {column: 'posting_date', DESC: true}}
|
||||
this.filter = {min_amount: 0, is_mapped: true, is_mapped_with_multiple: false, statement_transaction_owner_type_in: [1, 2], statement_transaction_owner_status_in: [1], per_page: 10000, order_by: {column: 'posting_date', DESC: true}}
|
||||
break;
|
||||
case 2:
|
||||
this.filter = {min_amount: 0, is_mapped: true, is_mapped_with_multiple: true, statement_transaction_owner_type_in: [1, 2], statement_transaction_owner_status_in: [1], per_page: 100, order_by: {column: 'posting_date', DESC: true}}
|
||||
@@ -187,11 +184,9 @@ export default {
|
||||
}
|
||||
|
||||
this.step = 1;
|
||||
|
||||
if(this.$refs.bankTransactionsList){
|
||||
this.$refs.bankTransactionsList.updateFilters(this.filter);
|
||||
}
|
||||
|
||||
this.componentKey += 1;
|
||||
// this.$refs.bankTransactionsList.$forceUpdate();
|
||||
// this.$refs.bankTransactionsList.updateFilters(this.filter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@
|
||||
methods: {
|
||||
test() {
|
||||
console.log('sjhb');
|
||||
}
|
||||
},
|
||||
},
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user