mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-29 17:34:02 +00:00
E-Invoice - Update to Sales Invoice Report template ref column
This commit is contained in:
@@ -75,17 +75,28 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
|
||||
]);
|
||||
|
||||
// $booking = Booking::where('marking', $ref)->first();
|
||||
// if($booking){
|
||||
// if($docNo != "" && $docNo != "<<New>>"){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo);
|
||||
// }
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
|
||||
$transaction = Transaction::where('bill_no', $ref)->first();
|
||||
$booking = $transaction->owner;
|
||||
if($booking){
|
||||
if($transaction){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo);
|
||||
$this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo);
|
||||
}
|
||||
if($eInvoiceValidationLink){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
$this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
}
|
||||
if($docDate){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCDATE_INVOICE, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate);
|
||||
$this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_DOCDATE_INVOICE, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,10 +93,14 @@ class RegenerateInvoiceBookingProcessor
|
||||
$this->deletesDocument->execute($row);
|
||||
}
|
||||
|
||||
$this->createInvoiceTransactionProcessor->execute($booking, $firstBillNo, true, $isAllowNormalInvoice);
|
||||
$kvpCopies = $currentInvoice->attributesKVP->map(function ($kvp) {
|
||||
return $kvp->replicate();
|
||||
});
|
||||
|
||||
$this->createInvoiceTransactionProcessor->execute($booking, $firstBillNo, $kvpCopies, true, $isAllowNormalInvoice);
|
||||
}
|
||||
else {
|
||||
$this->createInvoiceTransactionProcessor->execute($booking, "", false, $isAllowNormalInvoice);
|
||||
$this->createInvoiceTransactionProcessor->execute($booking, "", null, false, $isAllowNormalInvoice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,14 +94,19 @@ class GenerateCreditNotePdfV2Logic
|
||||
$autoCountInvoiceId = '';
|
||||
$autoCountEInvoiceValidationLink = '';
|
||||
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
|
||||
if($metadata){
|
||||
$autoCountInvoiceId = $metadata->value;
|
||||
}
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
//cief todo: 90 - Credit Note autocount id from autocount need new key
|
||||
// $metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
|
||||
// if($metadata){
|
||||
// if($metadata){
|
||||
// $autoCountInvoiceId = $metadata->value;
|
||||
// }
|
||||
// $metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK)->first();
|
||||
// if($metadata){
|
||||
// $autoCountEInvoiceValidationLink = $metadata->value;
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// }
|
||||
|
||||
Log::info('autoCountInvoiceId: ' . $autoCountInvoiceId);
|
||||
Log::info('autoCountEInvoiceValidationLink: ' . $autoCountEInvoiceValidationLink);
|
||||
|
||||
@@ -69,18 +69,36 @@ class CreateInvoiceDocumentProcessor
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
|
||||
if($metadata){
|
||||
$autoCountInvoiceId = $metadata->value;
|
||||
}
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCDATE_INVOICE)->first();
|
||||
if($metadata){
|
||||
$documentDate = Carbon::parse($metadata->value);
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCDATE_INVOICE)->first();
|
||||
if($metadata){
|
||||
$documentDate = Carbon::parse($metadata->value);
|
||||
}
|
||||
else{
|
||||
$lastDayOfMonth = $documentDate->copy()->endOfMonth();
|
||||
$documentDate = $lastDayOfMonth;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$lastDayOfMonth = $documentDate->copy()->endOfMonth();
|
||||
$documentDate = $lastDayOfMonth;
|
||||
$metadata = $transaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
|
||||
if($metadata){
|
||||
$autoCountInvoiceId = $metadata->value;
|
||||
}
|
||||
$metadata = $transaction->attributesKVP()->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK)->first();
|
||||
if($metadata){
|
||||
$autoCountEInvoiceValidationLink = $metadata->value;
|
||||
}
|
||||
$metadata = $transaction->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();
|
||||
|
||||
@@ -88,11 +88,12 @@ class CreateInvoiceTransactionProcessor
|
||||
/**
|
||||
* @param Booking $booking
|
||||
* @param String $invoiceNo
|
||||
* @param Illuminate\Support\Collection<\App\Models\KeyValuePair> $kvpCopies
|
||||
* @param bool $isAllowEInvoice
|
||||
* @return void
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Booking $booking, String $invoiceNo= "", bool $isAllowEInvoice = false, bool $isAllowNormalInvoice = false)
|
||||
public function execute(Booking $booking, String $invoiceNo= "", $kvpCopies = null, bool $isAllowEInvoice = false, bool $isAllowNormalInvoice = false)
|
||||
{
|
||||
|
||||
if ($booking->status === ApprovalStatus::COMPLETED) {
|
||||
@@ -190,6 +191,12 @@ class CreateInvoiceTransactionProcessor
|
||||
);
|
||||
$invoice_transaction = $this->createsTransaction->execute($purchaseOrder->booking, $transaction_object);
|
||||
|
||||
if ($kvpCopies) {
|
||||
foreach ($kvpCopies as $kvp) {
|
||||
$invoice_transaction->attributesKVP()->save($kvp);
|
||||
}
|
||||
}
|
||||
|
||||
$voucherRedemption = $transaction->voucherRedemption;
|
||||
|
||||
// purchase order
|
||||
|
||||
@@ -9,5 +9,5 @@ class JobResult extends AbstractModel
|
||||
public $fillable = [
|
||||
'job_id',
|
||||
'result'
|
||||
];
|
||||
];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,13 @@ class KeyValuePair extends AbstractModel
|
||||
|
||||
protected $table = 'key_value_pairs';
|
||||
|
||||
protected $fillable = [
|
||||
'owner_type',
|
||||
'owner_id',
|
||||
'key',
|
||||
'value',
|
||||
];
|
||||
|
||||
public function owner(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
Reference in New Issue
Block a user