E-Invoice - PM request for E-Invoice to use amended document date when import with autocount data

This commit is contained in:
Dillon Ngo
2025-09-08 17:06:28 +08:00
parent ff10b1d0b7
commit 8fb9a19e41
6 changed files with 49 additions and 25 deletions
@@ -15,7 +15,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\Booking;
use Illuminate\Support\Facades\Log;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
{
@@ -81,6 +81,9 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
if($eInvoiceValidationLink){
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
}
if($docDate){
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCDATE_INVOICE, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate);
}
}
$end = new Carbon();
@@ -100,4 +103,12 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
(App()->make(CreatesKeyValuePair::class))->execute($booking, $keyValuePairObject);
}
}
private function convertDocDateToString($value, $format = 'm/d/Y') {
if (is_numeric($value)) {
return Carbon::instance(Date::excelToDateTimeObject($value))->format($format);
}
return Carbon::parse($value)->format($format);
}
}
@@ -63,9 +63,6 @@ class CreateInvoiceDocumentProcessor
if ($bookingCreatedDate->isAfter($eInvoiceStartDate)) {
$lastPaymentTransaction = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->latest()->first();
$documentDate = $lastPaymentTransaction->created_at;
// if(Carbon::parse($booking->updated_at)->isAfter($lastPaymentTransaction->created_at)){ //cief todo: 90 - Batch generate E-Invoice date incorrect
// $documentDate = $booking->updated_at;
// }
}
if($document_type === DocumentType::EINVOICE){
@@ -77,8 +74,14 @@ class CreateInvoiceDocumentProcessor
if($metadata){
$autoCountEInvoiceValidationLink = $metadata->value;
}
$lastDayOfMonth = $documentDate->copy()->endOfMonth();
$documentDate = $lastDayOfMonth;
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCDATE_INVOICE)->first();
if($metadata){
$documentDate = Carbon::parse($metadata->value);
}
else{
$lastDayOfMonth = $documentDate->copy()->endOfMonth();
$documentDate = $lastDayOfMonth;
}
}
$payment = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->first();
$refundAmount = $payment->transactions()->refunds()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->sum('amount');
@@ -29,5 +29,5 @@ final class DocumentType {
public const BILL_GROUP_PAYMENT_PROOF = 'BILL_GROUP_PAYMENT_PROOF';
public const RECEIPT_VOUCHER = 'RECEIPT_VOUCHER';
public const EINVOICE = 'E_INVOICE'; //cief todo: 90 - why is there no E-CREDITNOTE
public const EINVOICE = 'E_INVOICE';
}
@@ -10,6 +10,8 @@ class KVPKey
public const AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT = 'AUTOCOUNT_DOCNO_OR';
public const AUTOCOUNT_DOCDATE_INVOICE = 'AUTOCOUNT_DOCDATE_I';
public const AUTOCOUNT_EINVOICE_VALIDATION_LINK = 'AUTOCOUNT_EINVOICE_VALIDATION_LINK';
public const CREDIT_NOTE_APPROVAL_DATE = 'CREDIT_NOTE_APPROVAL_DATE';
File diff suppressed because one or more lines are too long
+16 -15
View File
@@ -92,21 +92,22 @@
</tbody>
</table>
</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>