Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into centralize-izyim-exchange

This commit is contained in:
JiaSheng
2023-11-24 17:14:34 +08:00
7 changed files with 71 additions and 23 deletions
@@ -0,0 +1,22 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class WhereHasOwnersAndNotNull implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereHas('owners', function ($query) use ($value) {
return $query->whereNotNull($value);
});
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class WhereHasOwnersAndNull implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereHas('owners', function ($query) use ($value) {
return $query->whereNull($value);
});
}
}
@@ -57,13 +57,13 @@ class ImportStatementInvoiceController
}
// if still unable to map, will try to check the shipping_info without TOPUP
foreach (['exchange','izyim'] as $system) {
$returnReference = $this->mappingTopUp($row, $system);
if ($returnReference) {
$row['mapped_result_reference'] = $returnReference;
$row['mapped_status'] = 'success';
}
}
// foreach (['exchange','izyim'] as $system) {
// $returnReference = $this->mappingTopUp($row, $system);
// if ($returnReference) {
// $row['mapped_result_reference'] = $returnReference;
// $row['mapped_status'] = 'success';
// }
// }
return $row;
}
@@ -155,16 +155,18 @@ class ImportStatementInvoiceController
private function mappingExchange(Array $row) {
$date = $row['date'];
$transactions = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where('statement_transactions.amount', $row['net_total'])->whereRaw("DATE(posting_date) = '$date'")->get();
if ($transactions && $transactions->count() == 0) {
$transactions = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where(DB::raw('FLOOR(statement_transactions.amount)'), floor($row['net_total']))->whereRaw("DATE(posting_date) = '$date'")->get();
$transaction = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where('owner_reference', $row['shipping_info'])->first();
if ($transaction && $transaction->count() == 0) {
$transaction = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where('statement_transactions.amount', $row['net_total'])->whereRaw("DATE(posting_date) = '$date'")->first();
}
if ($transactions && $transactions->count() == 1) {
foreach ($transactions as $key => $transaction) {
return $this->updateTransactionOwnerReference($transaction, $row['doc_no']);
}
if ($transaction && $transaction->count() == 0) {
$transaction = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where(DB::raw('FLOOR(statement_transactions.amount)'), floor($row['net_total']))->whereRaw("DATE(posting_date) = '$date'")->first();
}
if ($transaction && $transaction->count() > 0) {
return $this->updateTransactionOwnerReference($transaction, $row['doc_no']);
}
return false;
}
@@ -34,7 +34,8 @@ class BankStatementTransactionResource extends JsonResource
'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())
'rejected' => BankStatementTransactionOwnerResource::collection($this->owners()->whereIn('status', [ApprovalStatus::REJECTED])->get()),
'completed' => BankStatementTransactionOwnerResource::collection($this->owners()->whereIn('status', [ApprovalStatus::COMPLETED])->get()),
]
];
}
@@ -6,11 +6,11 @@
<div class="col-2">{{ item.transaction_description_1 + ' - ' + item.transaction_description_2 }}</div>
<div class="col-7">
<div class="row">
<div class="col">{{item.owners.approved[0].system}}</div>
<div class="col">{{ typeString(item.owners.approved[0].type) }}</div>
<div class="col"><a :href="item.owners.approved[0].reference_link" target="_blank">{{item.owners.approved[0].reference}}</a></div>
<div class="col">{{item.owners.approved[0].invoice_reference}}</div>
<div class="col">{{item.owners.approved[0].receipt_reference}}</div>
<div class="col">{{item.owners.completed[0].system}}</div>
<div class="col">{{ typeString(item.owners.completed[0].type) }}</div>
<div class="col"><a :href="item.owners.completed[0].reference_link" target="_blank">{{item.owners.completed[0].reference}}</a></div>
<div class="col">{{item.owners.completed[0].invoice_reference}}</div>
<div class="col">{{item.owners.completed[0].receipt_reference}}</div>
</div>
</div>
@@ -57,7 +57,7 @@
},
methods: {
getReportFilter() {
this.filter = {min_amount: 0, is_mapped: true, statement_transaction_owner_type_in: [1, 2], statement_transaction_owner_status_in: [2], statement_transaction_owner_invoice_or_receipt_ref_not_null: true, per_page: 100, order_by: {column: 'posting_date', DESC: true}};
this.filter = {min_amount: 0, is_mapped: true, statement_transaction_owner_type_in: [1, 2], statement_transaction_owner_status_in: [3], per_page: 100, order_by: {column: 'posting_date', DESC: true}};
this.step = 1
}
@@ -277,7 +277,8 @@ export default {
exportReceiptToAutoCount(){
const checkedStatementTransactions = this.getCheckedStatementOwners();
this.filter['statement_transaction_owner_type_in'] = [3,4,5,7,13,14];
this.filter['where_has_owners_and_null'] = 'statement_transaction_owners.receipt_reference';
this.filter['where_has_owners_and_not_null'] = 'statement_transaction_owners.invoice_reference';
let route = this.route('receiptTransactions.export')+'?filter='+JSON.stringify(this.filter);
if (checkedStatementTransactions) {
route += '&bankStatementTransactionId='+checkedStatementTransactions;