mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'dillon/90-e-invoice-f' into vapor/production
This commit is contained in:
@@ -15,6 +15,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
@@ -71,19 +72,29 @@ class ProcessCreditNoteReportV2CommandJob implements ShouldQueue
|
||||
'EInvoiceValidationLink' => $eInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$booking = Booking::where('marking', $ref)->first();
|
||||
if($booking){
|
||||
// $booking = Booking::where('marking', $ref)->first();
|
||||
// if($booking){
|
||||
// if($docNo != "" && $docNo != "<<New>>"){
|
||||
// $payments = $booking->transactions()->payments()->get();
|
||||
// foreach ($payments as $payment) {
|
||||
// $refundTransaction = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->latest()->first();
|
||||
// if($refundTransaction){
|
||||
// $this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE, $docNo);
|
||||
// if($eInvoiceValidationLink){
|
||||
// $this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE, $eInvoiceValidationLink);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
$transaction = Transaction::where('bill_no', $ref)->first();
|
||||
if($transaction){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$payments = $booking->transactions()->payments()->get();
|
||||
foreach ($payments as $payment) {
|
||||
$refundTransaction = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->latest()->first();
|
||||
if($refundTransaction){
|
||||
$this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE, $docNo);
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($refundTransaction, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE, $eInvoiceValidationLink);
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE, $docNo);
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE, $eInvoiceValidationLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class ExportsARCreditNoteReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
$refundRemarkGroupAccNo = null;
|
||||
$company = $transaction->owner->owner;
|
||||
$kvps = KeyValuePair::where('value', $transaction->id)
|
||||
->where('key', 'App\Models\Transaction')
|
||||
->where('key', KVPKey::TRANSACTION_MODEL_CLASS)
|
||||
->orderByDesc('created_at')
|
||||
->get();
|
||||
|
||||
@@ -119,7 +119,7 @@ class ExportsARCreditNoteReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
'<<New>>', //DocNo
|
||||
$formattedDocumentDate, //DocDate
|
||||
$company->debtor, //DebtorCode
|
||||
$booking ? $booking->marking : '', //Ref
|
||||
$transaction->bill_no ?? '', //Ref
|
||||
$refundRemarkGroup ?? '', //Description
|
||||
$refundRemarkGroup ?? '', //Reason
|
||||
'C', //DeptNo
|
||||
|
||||
+30
-13
@@ -94,26 +94,43 @@ class GenerateCreditNotePdfV2Logic
|
||||
if($eInvoiceStarted) {
|
||||
$eInvoiceStarted = false; //reset to re-evaluate second time
|
||||
|
||||
$kvp = KeyValuePair::where('key', KVPKey::TRANSACTION_MODEL_CLASS)->where('value', $transaction->id)->first();
|
||||
$refundTransaction = $kvp ? $kvp->owner : null;
|
||||
if($refundTransaction && $refundTransaction->type === TransactionType::REFUND){
|
||||
$metadata = $refundTransaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
//OLD BUSINESS LOGIC
|
||||
// $kvp = KeyValuePair::where('key', KVPKey::TRANSACTION_MODEL_CLASS)->where('value', $transaction->id)->first();
|
||||
// $refundTransaction = $kvp ? $kvp->owner : null;
|
||||
// if($refundTransaction && $refundTransaction->type === TransactionType::REFUND){
|
||||
// $metadata = $refundTransaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
// if($metadata){
|
||||
// $autoCountInvoiceId = $metadata->value;
|
||||
// }
|
||||
// $metadata = $refundTransaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE)->first();
|
||||
// if($metadata){
|
||||
// $autoCountEInvoiceValidationLink = $metadata->value;
|
||||
// }
|
||||
|
||||
// if($autoCountInvoiceId && $autoCountEInvoiceValidationLink){
|
||||
// $eInvoiceStarted = true;
|
||||
// }
|
||||
// }
|
||||
if($transaction && $transaction->type === TransactionType::CREDIT_NOTE){
|
||||
$metadata = $transaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
if($metadata){
|
||||
$autoCountInvoiceId = $metadata->value;
|
||||
}
|
||||
$metadata = $refundTransaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
$metadata = $transaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
|
||||
Log::info('AUTOCOUNT_DOCNO_CREDIT_NOTE: ' . $autoCountInvoiceId);
|
||||
Log::info('AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE: ' . $autoCountEInvoiceValidationLink);
|
||||
if($autoCountInvoiceId && $autoCountEInvoiceValidationLink){
|
||||
$eInvoiceStarted = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
if($autoCountInvoiceId && $autoCountEInvoiceValidationLink){
|
||||
$eInvoiceStarted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Log::info('AUTOCOUNT_DOCNO_CREDIT_NOTE: ' . $autoCountInvoiceId);
|
||||
Log::info('AUTOCOUNT_EINVOICE_VALIDATION_LINK_CREDIT_NOTE: ' . $autoCountEInvoiceValidationLink);
|
||||
|
||||
if($eInvoiceStarted)
|
||||
{
|
||||
|
||||
@@ -111,10 +111,10 @@ class CreditWalletProcessor
|
||||
$wallet = $this->updatesWallet->execute($wallet, $walletObject);
|
||||
|
||||
if($relatedTransaction && $relatedTransaction instanceof Transaction){
|
||||
$kvp = $relatedTransaction->attributesKVP()->where('key', 'App\Models\Transaction')->where('value', $transaction->id)->latest()->first();
|
||||
$kvp = $relatedTransaction->attributesKVP()->where('key', KVPKey::TRANSACTION_MODEL_CLASS)->where('value', $transaction->id)->latest()->first();
|
||||
if(!$kvp){
|
||||
$keyValuePairObject = new KeyValuePairObject(
|
||||
"App\Models\Transaction",
|
||||
KVPKey::TRANSACTION_MODEL_CLASS,
|
||||
$transaction->id
|
||||
);
|
||||
$this->createsKeyValuePair->execute($relatedTransaction, $keyValuePairObject);
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -40,9 +41,13 @@ class TransactionResource extends JsonResource
|
||||
|
||||
$eInvoice = false;
|
||||
if($booking && $this->type === TransactionType::REFUND){
|
||||
$kvp = $this->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
if($kvp){
|
||||
$eInvoice = true;
|
||||
$kvp = $this->attributesKVP()->where('key', KVPKey::TRANSACTION_MODEL_CLASS)->first();
|
||||
$transactionCreditNote = Transaction::where('id', $kvp->value)->first();
|
||||
if($transactionCreditNote){
|
||||
$kvp = $transactionCreditNote->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_CREDIT_NOTE)->first();
|
||||
if($kvp){
|
||||
$eInvoice = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,9 @@
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-r-0 m-l-0 text-muted small">
|
||||
<em>Note: Date filter not applicable to import</em>
|
||||
</div>
|
||||
<div class="row m-r-0 m-l-0" v-if="error">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
|
||||
@@ -119,25 +119,27 @@
|
||||
<td width="80%">
|
||||
|
||||
</td>
|
||||
<td align="center" width="20%" style="float: right;">
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
<tr align="center">
|
||||
<td>
|
||||
<img src="{{ url(config('qr.qr_code_img_url') . $autocountEInvoiceValidationLink ) }}" style="width: 230px; height: 230px;" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr align="center">
|
||||
<td>
|
||||
<h2 style="margin: 0 !important;"><strong>{{ $autocountEInvoiceValidationLink }}</strong></h2>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<td width="20%" valign="top" align="center">
|
||||
<div style="display: inline-block; text-align: center; max-width: 230px; width: 100%;">
|
||||
|
||||
<img src="{{ url(config('qr.qr_code_img_url') . $autocountEInvoiceValidationLink ) }}"
|
||||
style="width: 40%; height: auto; display: block;" />
|
||||
|
||||
<div style="margin-top: 5px;
|
||||
word-break: break-word;
|
||||
overflow-wrap: break-word;
|
||||
white-space: normal;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
text-align: center;">
|
||||
<strong>{{ $autocountEInvoiceValidationLink }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
|
||||
|
||||
Reference in New Issue
Block a user