mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 05:23:58 +00:00
Merge branch 'dillon/90-e-invoice-e-1' into vapor/staging
This commit is contained in:
@@ -14,6 +14,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;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
||||
@@ -73,16 +74,29 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
|
||||
'EInvoiceValidationLink' => $eInvoiceValidationLink,
|
||||
]);
|
||||
|
||||
$booking = Booking::where('marking', $ref)->first();
|
||||
if($booking){
|
||||
// $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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
$firstItem ? '<<New>>' : '',
|
||||
$formattedDocumentDate,
|
||||
$company->debtor,
|
||||
$booking->marking,
|
||||
$invoiceTransaction->bill_no,
|
||||
$booking->marking,
|
||||
'500-0000',
|
||||
'PRODUCT NAME :',
|
||||
@@ -200,7 +200,7 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
'',
|
||||
$formattedDocumentDate,
|
||||
$company->debtor,
|
||||
$booking->marking,
|
||||
$invoiceTransaction->bill_no,
|
||||
$booking->marking,
|
||||
'500-0000',
|
||||
'PRODUCT NAME :',
|
||||
@@ -246,7 +246,7 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
'',
|
||||
$formattedDocumentDate,
|
||||
$company->debtor,
|
||||
$booking->marking,
|
||||
$invoiceTransaction->bill_no,
|
||||
$booking->marking,
|
||||
'500-0000',
|
||||
'PRODUCT NAME :',
|
||||
|
||||
@@ -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