mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-20 13:04:02 +00:00
Merge branch 'dillon/accounting-bank-mapping' into 'development'
Dillon/accounting bank mapping See merge request CIEFWorldwideSdnBhd/exchange-2.0!137
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) {
|
||||
|
||||
+158
-9
@@ -3,15 +3,20 @@
|
||||
namespace App\Classes\Modules\Accounting\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounting\Services\UpdatesBankStatementDetails;
|
||||
use App\Classes\Modules\Accounting\Services\FetchesBankStatementDetails;
|
||||
use App\Classes\Modules\Accounting\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Accounting\DataTransferObjects\BankStatementDetailObject;
|
||||
use App\Http\Resources\BankStatementDetailResource;
|
||||
use App\Classes\Modules\Accounting\Services\CreatesBankStatementTransactionOwner;
|
||||
use App\Classes\Modules\Accounting\Services\FetchesBankStatementTransaction;
|
||||
use App\Classes\ValueObjects\Constants\StatementTransactionOwnerType;
|
||||
use App\Classes\ValueObjects\Constants\SystemType;
|
||||
use App\Classes\Modules\Accounting\Processors\ChecksBillNumber;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use ErrorException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -35,15 +40,30 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
/** @var FetchesBankStatementDetails */
|
||||
private $fetchesBankStatementDetails;
|
||||
|
||||
/** @var FetchesBankStatementTransaction */
|
||||
private $fetchesBankStatementTransaction;
|
||||
|
||||
/** @var CreatesBankStatementTransactionOwner */
|
||||
private $createsBankStatementTransactionOwner;
|
||||
|
||||
/** @var ChecksBillNumber */
|
||||
private $checksBillNumber;
|
||||
|
||||
/**
|
||||
* UpdateBankStatementDetailLogic constructor.
|
||||
* @param UpdatesBankStatementDetails $updatesBankStatementDetails
|
||||
* @param FetchesBankStatementDetails $fetchesBankStatementDetails
|
||||
* @param fetchesBankStatementTransaction $fetchesBankStatementTransaction
|
||||
* @param CreatesBankStatementTransactionOwner $createsBankStatementTransactionOwner
|
||||
* @param ChecksBillNumber $checksBillNumber
|
||||
*/
|
||||
public function __construct(UpdatesBankStatementDetails $updatesBankStatementDetails, FetchesBankStatementDetails $fetchesBankStatementDetails)
|
||||
public function __construct(UpdatesBankStatementDetails $updatesBankStatementDetails, FetchesBankStatementDetails $fetchesBankStatementDetails, FetchesBankStatementTransaction $fetchesBankStatementTransaction, CreatesBankStatementTransactionOwner $createsBankStatementTransactionOwner, ChecksBillNumber $checksBillNumber)
|
||||
{
|
||||
$this->updatesBankStatementDetails = $updatesBankStatementDetails;
|
||||
$this->fetchesBankStatementDetails = $fetchesBankStatementDetails;
|
||||
$this->fetchesBankStatementTransaction = $fetchesBankStatementTransaction;
|
||||
$this->createsBankStatementTransactionOwner = $createsBankStatementTransactionOwner;
|
||||
$this->checksBillNumber = $checksBillNumber;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,15 +72,144 @@ class UpdateBankStatementDetailLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$object = new BankStatementDetailObject($request->input('pay_for'), $request->input('system_references'));
|
||||
$bankStatementTransaction = $this->fetchesBankStatementTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->fetchesBankStatementDetails->execute(['id' => $request->route('id')]);
|
||||
$owner_type = null;
|
||||
$owner_id = null;
|
||||
$statementTransactionOwnerType = null;
|
||||
$system = null;
|
||||
$owner_reference = null;
|
||||
|
||||
$query = $this->updatesBankStatementDetails->execute($query, $object);
|
||||
switch ($request->input('pay_for')) {
|
||||
case 'sales':
|
||||
if (in_array($request->input('system_references'), ['exchange', 'izyim'])) {
|
||||
// $transaction = $this->verifyBillNumber($request->input('transaction_reference'), $request->input('system_references'));
|
||||
$transaction = $this->checksBillNumber->execute($request->input('transaction_reference'), $request->input('system_references'));
|
||||
|
||||
return $this->resourceResponse(new BankStatementDetailResource($query));
|
||||
// todo-new: update / test on izyim system
|
||||
|
||||
$owner_type = Transaction::class;
|
||||
$owner_id = $transaction->id;
|
||||
// todo-new: owner_reference
|
||||
// booking number / order number
|
||||
$owner_reference = null;
|
||||
$statementTransactionOwnerType = StatementTransactionOwnerType::SALES;
|
||||
$system = $request->input('system_references');
|
||||
} else {
|
||||
|
||||
switch ($request->input('system_references')) {
|
||||
case 'lite':
|
||||
$statementTransactionOwnerType = StatementTransactionOwnerType::SALES_LITE;
|
||||
break;
|
||||
case 'cntr':
|
||||
$statementTransactionOwnerType = StatementTransactionOwnerType::SALES_CNTR;
|
||||
break;
|
||||
case 'probashi':
|
||||
$statementTransactionOwnerType = StatementTransactionOwnerType::SALES_PROBASHI;
|
||||
break;
|
||||
case 'pets':
|
||||
$statementTransactionOwnerType = StatementTransactionOwnerType::SALES_PETS;
|
||||
break;
|
||||
default:
|
||||
throw new MalformedRequestException('System Reference not allowed');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'top_up':
|
||||
|
||||
// $transaction = $this->verifyBillNumber($request->input('transaction_reference'), $request->input('system_references'));
|
||||
$transaction = $this->checksBillNumber->execute($request->input('transaction_reference'), $request->input('system_references'));
|
||||
|
||||
$owner_type = Transaction::class;
|
||||
$owner_id = $transaction->id;
|
||||
// todo-new: owner_reference
|
||||
// top_up - store customer marking
|
||||
$owner_reference = null;
|
||||
$statementTransactionOwnerType = StatementTransactionOwnerType::WALLET_TOP_UP;
|
||||
$system = $request->input('system_references');
|
||||
break;
|
||||
|
||||
case 'internal_bank_transfer':
|
||||
$statementTransactionOwnerType = StatementTransactionOwnerType::INTERNAL_BANK_TRANSFER_IN; // if negative -> out, positive -> in
|
||||
$system = $request->input('system_references');
|
||||
break;
|
||||
|
||||
case 'others':
|
||||
$owner_reference = $request->input('transaction_reference');
|
||||
$statementTransactionOwnerType = StatementTransactionOwnerType::NON_OPERATIONAL;
|
||||
$system = $request->input('system_references');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new MalformedRequestException('Transaction Type Not Allowed');
|
||||
}
|
||||
|
||||
$system == null ? '' : $system = SystemType::SYSTEM_NAMES[$system];
|
||||
|
||||
dd([
|
||||
'type' => $statementTransactionOwnerType,
|
||||
'system' => $system,
|
||||
// 'owner_type' => Transaction::class,
|
||||
// todo-new: make sure owner_type is a class
|
||||
'owner_type' => $owner_type,
|
||||
'owner_id' => $owner_id,
|
||||
'owner_reference' => $owner_reference
|
||||
]);
|
||||
|
||||
$bankStatementTransaction->owners()->firstOrCreate([
|
||||
'type' => $statementTransactionOwnerType,
|
||||
'system' => $system,
|
||||
// 'owner_type' => Transaction::class,
|
||||
// todo-new: make sure owner_type is a class
|
||||
'owner_type' => $owner_type,
|
||||
'owner_id' => $owner_id,
|
||||
'owner_reference' => $owner_reference
|
||||
]);
|
||||
|
||||
dd($bankStatementTransaction->owners()->first());
|
||||
|
||||
// $this->canCreateUser->passes($user_object);
|
||||
|
||||
// $user = $this->createsBankStatementTransactionOwner->execute($bankStatementTransactionObject);
|
||||
|
||||
// return $this->resourceResponse(new BankStatementDetailResource($query));
|
||||
}
|
||||
|
||||
// public function verifyBillNumber($bill_no, $system_reference)
|
||||
// {
|
||||
// if ($system_reference == 'izyim') {
|
||||
// try {
|
||||
// $url = 'https://izyim.cief-malaysia.com/public/api/v1/transactions/query';
|
||||
// $client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
// $response = $client->request('GET', $url . '?api-key=510acd13d8d24375cf038ad626c282565451461a9c2399357e0b65365300787e&filters={"bill_no":' . $bill_no . '}');
|
||||
// $body = $response->getBody();
|
||||
// $data = json_decode($body, true);
|
||||
// dd($data);
|
||||
// $payload = $data['payload'];
|
||||
// $transactions2 = $payload['data'];
|
||||
// dd($transactions2);
|
||||
// return $transactions2;
|
||||
// } catch (\Exception $exception) {
|
||||
// Log::error($exception);
|
||||
// dd($exception);
|
||||
// preg_match('/\{.*\}/s', $exception->getMessage(), $matches);
|
||||
// $jsonError = json_decode($matches[0]);
|
||||
// // Retrieved Transactions failed
|
||||
// throw new MalformedRequestException($jsonError->title);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($system_reference == 'exchange') {
|
||||
// $transaction = Transaction::where('bill_no', $bill_no)->first();
|
||||
// if ($transaction) {
|
||||
// return $transaction;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // if not found
|
||||
// throw new MalformedRequestException('Bill Number Not Found.');
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounting\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ChecksBillNumber
|
||||
{
|
||||
public function execute($bill_no, $system_reference)
|
||||
{
|
||||
if ($system_reference == 'izyim') {
|
||||
try {
|
||||
$url = 'https://izyim.cief-malaysia.com/public/api/v1/transactions/query';
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$response = $client->request('GET', $url . '?api-key=510acd13d8d24375cf038ad626c282565451461a9c2399357e0b65365300787e&filters={"bill_no":' . $bill_no . '}');
|
||||
$body = $response->getBody();
|
||||
$data = json_decode($body, true);
|
||||
dd($data);
|
||||
$payload = $data['payload'];
|
||||
$transactions2 = $payload['data'];
|
||||
dd($transactions2);
|
||||
return $transactions2;
|
||||
} catch (\Exception $exception) {
|
||||
Log::error($exception);
|
||||
dd($exception);
|
||||
preg_match('/\{.*\}/s', $exception->getMessage(), $matches);
|
||||
$jsonError = json_decode($matches[0]);
|
||||
// Retrieved Transactions failed
|
||||
throw new MalformedRequestException($jsonError->title);
|
||||
}
|
||||
}
|
||||
|
||||
if ($system_reference == 'exchange') {
|
||||
$transaction = Transaction::where('bill_no', $bill_no)->first();
|
||||
if ($transaction) {
|
||||
return $transaction;
|
||||
}
|
||||
}
|
||||
|
||||
// if not found
|
||||
throw new MalformedRequestException('Bill Number Not Found.');
|
||||
}
|
||||
}
|
||||
+2
-8
@@ -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',
|
||||
@@ -117,7 +111,7 @@ class CreateBankStatementTransactionOwnersProcessor
|
||||
'system' => 'EXCHANGE',
|
||||
'owner_type' => Group::class,
|
||||
'owner_id'=> $debitTransaction->id,
|
||||
'owner_reference'=> $debitTransaction->bill_no
|
||||
'owner_reference'=> $debitTransaction->reference
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounting\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounting\DataTransferObjects\BankStatementTransactionObject;
|
||||
use App\Models\StatementTransactionOwner;
|
||||
|
||||
class CreatesBankStatementTransactionOwner extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param StatementTransactionOwner $model
|
||||
* @param BankStatementDetailsObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(BankStatementTransactionObject $object)
|
||||
{
|
||||
$model = new StatementTransactionOwner();
|
||||
|
||||
$model->statement_transaction_id = $object->getStatementTransactionId();
|
||||
$model->type = $object->getType();
|
||||
$model->system = $object->getSystem();
|
||||
$model->owner_type = $object->getOwnerType();
|
||||
$model->owner_id = $object->getOwnerId();
|
||||
$model->invoice_reference = $object->getInvoiceReference();
|
||||
$model->receipt_reference = $object->getReceipteReference();
|
||||
$model->is_auto_mapped = $object->getIsAutoMapped();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,12 @@ final class StatementTransactionOwnerType {
|
||||
|
||||
public const NON_OPERATIONAL = 14;
|
||||
|
||||
public const SALES_LITE = 15;
|
||||
|
||||
public const SALES_CNTR = 16;
|
||||
|
||||
public const SALES_PROBASHI = 17;
|
||||
|
||||
public const SALES_PETS = 18;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class SystemType {
|
||||
|
||||
public const EXCHANGE = 'EXCHANGE';
|
||||
|
||||
public const SHIPPING_PORTAL = 'SHIPPING_PORTAL';
|
||||
|
||||
public const SYSTEM_NAMES = [
|
||||
'exchange' => self::EXCHANGE,
|
||||
'shipping_portal' => self::SHIPPING_PORTAL,
|
||||
'izyim' => self::SHIPPING_PORTAL,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Imports;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Imports\Services\GenericImport;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Segment;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment;
|
||||
use App\Classes\Modules\Companies\Processors\AssignSegmentProcessor;
|
||||
use App\Models\Company;
|
||||
use App\Models\SeasonalSegment;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class ImportStatementInvoiceController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function import(Request $request)
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
$file = json_decode($object->getFiles()[0])->file_info->original->file;
|
||||
|
||||
$import = new GenericImport();
|
||||
Excel::import($import, $file);
|
||||
$excelRows = $import->rows;
|
||||
$excelRows = $excelRows->toArray();
|
||||
|
||||
foreach ($excelRows as $row) {
|
||||
dd($row);
|
||||
// $row['debtor_code']
|
||||
|
||||
// attempt 1 - try map by amount and date
|
||||
// $transactionDate = $this->changeExcelDate($row['date']);
|
||||
// $transaction = Transaction::where('original_amount', $row['total'])->whereDate('created_at', $transactionDate)->get();
|
||||
// if ($transaction) {
|
||||
// // check company
|
||||
// // $company = Company::where('debtor', $row['debtor_code'])->first();
|
||||
// // dd($company);
|
||||
// // try to verify is it the correct transaction
|
||||
// }
|
||||
|
||||
// Shipping Info
|
||||
// TOPUP -> map with transaction.bill_no
|
||||
if (str_starts_with($row['shipping_info'], 'TOPUP')) {
|
||||
// find in exchange first, if cannont then find in izyim
|
||||
// (App()->make(ChecksBillNumber::class))->execute($bill_no, 'exchange');
|
||||
}
|
||||
|
||||
// if 5 digits -> exchange booking reference
|
||||
// find transation
|
||||
// find statement_transaction_owners, and fill up the details
|
||||
|
||||
// if <5 digits, find the transaction id (order number in izyim), find the payment in izyim
|
||||
// find transation
|
||||
// find statement_transaction_owners, and fill up the details
|
||||
|
||||
// dd([
|
||||
// 'type' => $statementTransactionOwnerType,
|
||||
// 'system' => $system,
|
||||
// // 'owner_type' => Transaction::class,
|
||||
// // todo-new: make sure owner_type is a class
|
||||
// 'owner_type' => $owner_type,
|
||||
// 'owner_id' => $owner_id,
|
||||
// 'owner_reference' => $owner_reference
|
||||
// ]);
|
||||
|
||||
// $bankStatementTransaction->owners()->firstOrCreate([
|
||||
// 'type' => $statementTransactionOwnerType,
|
||||
// 'system' => $system,
|
||||
// // 'owner_type' => Transaction::class,
|
||||
// // todo-new: make sure owner_type is a class
|
||||
// 'owner_type' => $owner_type,
|
||||
// 'owner_id' => $owner_id,
|
||||
// 'owner_reference' => $owner_reference
|
||||
// ]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function changeExcelDate($date)
|
||||
{
|
||||
$unixTime = (($date - 25569) * 86400);
|
||||
$date = new DateTime("@$unixTime");
|
||||
return $date->format('Y-m-d'); // Change the format to 'Y-m-d'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Imports;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Imports\Services\GenericImport;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Segment;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment;
|
||||
use App\Classes\Modules\Companies\Processors\AssignSegmentProcessor;
|
||||
use App\Models\Company;
|
||||
use App\Models\SeasonalSegment;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class ImportStatementReceiptsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function import(Request $request)
|
||||
{
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
$file = json_decode($object->getFiles()[0])->file_info->original->file;
|
||||
|
||||
$import = new GenericImport();
|
||||
Excel::import($import, $file);
|
||||
$excelRows = $import->rows;
|
||||
$excelRows = $excelRows->toArray();
|
||||
|
||||
foreach ($excelRows as $row) {
|
||||
// if has date column
|
||||
// $transactionDate = $this->changeExcelDate($row['date']);
|
||||
}
|
||||
}
|
||||
|
||||
public function changeExcelDate($date)
|
||||
{
|
||||
$unixTime = (($date - 25569) * 86400);
|
||||
$date = new DateTime("@$unixTime");
|
||||
return $date->format('Y-m-d'); // Change the format to 'Y-m-d'
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
+97
-46
@@ -1,44 +1,68 @@
|
||||
<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-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 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 m-b-15">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component selectable :validator="$v.pay_for_value">
|
||||
<label>Transaction Type</label>
|
||||
<select-component :options="['Sales','Top Up', 'Internal Bank Transfer', 'Others']" v-model="pay_for_value"></select-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m-t-15" v-if="['Sales', 'Top Up'].includes(pay_for_value)">
|
||||
<div class="col">
|
||||
<validation-wrapper-component selectable :key="custom_options_key" :validator="$v.system_references">
|
||||
<label>Service</label>
|
||||
<select-component :options="customOptions()" v-model="system_references"></select-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m-t-15" v-if="['Sales', 'Top Up', 'Others'].includes(pay_for_value)">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.transaction_reference">
|
||||
<label>Transaction ID / Reference</label>
|
||||
<input type="text" class="form-control" v-model.lazy="transaction_reference">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</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>
|
||||
@@ -48,15 +72,21 @@
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
// import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
// import FormHandler from '../../../general/mixins/formHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
error: '',
|
||||
pay_for: "",
|
||||
system_references: ""
|
||||
system_references: "",
|
||||
transaction_reference: "",
|
||||
pay_for_value: "",
|
||||
custom_options_key: 1,
|
||||
pay_for: {
|
||||
status: false,
|
||||
options: ['sales', 'top_up', 'internal_bank_transfer', 'others'],
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -64,26 +94,47 @@
|
||||
this.system_references = this.item.system_references
|
||||
},
|
||||
validations: {
|
||||
pay_for: { required },
|
||||
system_references: { required }
|
||||
system_references: { },
|
||||
transaction_reference: { },
|
||||
pay_for_value: { required },
|
||||
},
|
||||
watch: {
|
||||
'data': function() {
|
||||
this.pay_for = this.item.pay_for;
|
||||
this.system_references = this.item.system_references;
|
||||
},
|
||||
pay_for_value(newVal, oldVal) {
|
||||
this.custom_options_key ++;
|
||||
this.transaction_reference = '';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
this.parameters = {pay_for : this.pay_for, system_references: this.system_references};
|
||||
this.item.pay_for = this.pay_for;
|
||||
this.item.system_references = this.system_references;
|
||||
this.pay_for_value = this.pay_for_value.replace(/\s/g, "_").toLowerCase();
|
||||
this.system_references = this.system_references ? this.system_references.toLowerCase() : '';
|
||||
|
||||
this.parameters = {
|
||||
pay_for : this.pay_for_value,
|
||||
system_references : this.system_references,
|
||||
transaction_reference : this.transaction_reference
|
||||
};
|
||||
|
||||
this.submit(this.route('api.accounting.statement.details.update', this.data.id), 'put', this.section, true, true);
|
||||
},
|
||||
successHandler(){
|
||||
// this.closeModal();
|
||||
// this.formHandler('');
|
||||
},
|
||||
customOptions(){
|
||||
switch (this.pay_for_value) {
|
||||
case 'Sales':
|
||||
return ['Exchange', 'Izyim', 'Lite', 'Cntr', 'Probashi', 'Pets'];
|
||||
case 'Top Up':
|
||||
return ['Exchange', 'Izyim'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
},
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
|
||||
+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 + "?";
|
||||
}
|
||||
|
||||
+50
-6
@@ -105,10 +105,18 @@
|
||||
<div class="btn btn-lg btn-primary" @click="exportStage++">Export Invoices To AutoCount</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center m-t-50 m-b-50 p-t-50 p-b-50" v-show="exportStage === 1">
|
||||
<div class="row text-center m-t-50 m-b-50 p-t-50 p-b-50" v-if="exportStage === 1">
|
||||
<div class="col">
|
||||
<file-upload-component></file-upload-component>
|
||||
<div class="btn btn-lg btn-primary m-t-20" @click="exportStage++">Import Invoices</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<file-input-component :validator="$v.files" v-model="files">
|
||||
<template slot="label">
|
||||
</template>
|
||||
</file-input-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn btn-lg btn-primary m-t-20" @click="importInvoice">Import Invoices</div>
|
||||
<!-- todo-new: delete later --><br><div class="btn btn-lg btn-primary m-t-20" @click="exportStage++">Nest Step</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center m-t-50 m-b-50 p-t-50 p-b-50" v-show="exportStage === 2">
|
||||
@@ -116,10 +124,18 @@
|
||||
<div class="btn btn-lg btn-primary" @click="exportStage++">Export Receipts To AutoCount</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center m-t-50 m-b-50 p-t-50 p-b-50" v-show="exportStage === 3">
|
||||
<div class="row text-center m-t-50 m-b-50 p-t-50 p-b-50" v-if="exportStage === 3">
|
||||
<div class="col">
|
||||
<file-upload-component></file-upload-component>
|
||||
<div class="btn btn-lg btn-primary m-t-20" @click="exportStage++">Import Receipts</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<file-input-component :validator="$v.files" v-model="files">
|
||||
<template slot="label">
|
||||
</template>
|
||||
</file-input-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn btn-lg btn-primary m-t-20" @click="importReceipts">Import Receipts</div>
|
||||
<!-- todo-new: delete later --><br><div class="btn btn-lg btn-primary m-t-20" @click="exportStage++">Nest Step</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center m-t-50 m-b-50 p-t-50 p-b-50" v-show="exportStage === 4">
|
||||
@@ -133,6 +149,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
|
||||
@@ -144,10 +162,36 @@ export default {
|
||||
exportStage: 0,
|
||||
step: 0,
|
||||
filter: {},
|
||||
files: [],
|
||||
parameters: {},
|
||||
section: 'bankTransactionSection',
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
files: {
|
||||
// required // todo-new: set required if is pdf section
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
importInvoice(){
|
||||
this.parameters = {
|
||||
files: this.files
|
||||
};
|
||||
this.submit(this.route('api.import_invoices.upload'), 'post', this.section, true, false);
|
||||
},
|
||||
importReceipts(){
|
||||
this.parameters = {
|
||||
files: this.files
|
||||
};
|
||||
this.submit(this.route('api.import_receipts.upload'), 'post', this.section, true, false);
|
||||
},
|
||||
successHandler(){
|
||||
this.step += 1;
|
||||
|
||||
// reset parameters
|
||||
this.files = [];
|
||||
this.parameters = {};
|
||||
},
|
||||
startMapping(stage){
|
||||
|
||||
this.stage = stage;
|
||||
|
||||
@@ -52,9 +52,9 @@
|
||||
methods: {
|
||||
test() {
|
||||
console.log('sjhb');
|
||||
}
|
||||
},
|
||||
},
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -30,6 +30,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
Route::get('/storage/{fileName}/fetch', 'Documents\RenderDocumentController@fileStorageServe')->where(['fileName' => '.*'])->name('storage.document.file');
|
||||
Route::post('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import')->name('debtor.import');
|
||||
Route::post('/import/upload-honey-trap', 'Imports\ImportHoneyTrapController@import')->name('honey_trap.upload');
|
||||
Route::post('/import/upload-import-invoices', 'Imports\ImportStatementInvoiceController@import')->name('import_invoices.upload');
|
||||
Route::post('/import/upload-import-receipt', 'Imports\ImportStatementReceiptsController@import')->name('import_receipts.upload');
|
||||
|
||||
require __DIR__ . '/company.php';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user