mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
E-Invoice - Automapping Issues, Receive Payment for Booking Report (Import) Partial Completion
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Models\Booking;
|
||||
use App\Models\KeyValuePair;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -55,6 +56,8 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$reportType = $request->input('report_type');
|
||||
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
@@ -113,14 +116,20 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
$this->processSalesInvoiceReport($sheet);
|
||||
}
|
||||
else if ($reportType === '01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]'){
|
||||
$this->processPaymentReport($sheet);
|
||||
$result = $this->processPaymentReport($sheet);
|
||||
$result = [
|
||||
'message' => empty($result)
|
||||
? ''
|
||||
: 'Some payments are unprocessed: ',
|
||||
'data' => $result
|
||||
];
|
||||
}
|
||||
else{
|
||||
throw new MalformedRequestException('Cannot process report type: ' . $reportType);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
private function updateOrCreateKeyValuePair($booking, $key, $value)
|
||||
@@ -186,6 +195,7 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
}
|
||||
|
||||
private function processPaymentReport($sheet){
|
||||
$unprocessedKnockOffs = [];
|
||||
$rows = $sheet->skip(1);
|
||||
|
||||
foreach ($rows as $index => $details) {
|
||||
@@ -207,15 +217,25 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
'KnockOffDocNo' => $knockOffDocNo,
|
||||
]);
|
||||
|
||||
// $booking = Booking::where('marking', $ref)->first();
|
||||
// if($booking){
|
||||
// if($docNo != "" && $docNo != "<<New>>"){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO, $docNo);
|
||||
// }
|
||||
// if($eInvoiceValidationLink){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// }
|
||||
// }
|
||||
if($knockOffDocNo)
|
||||
{
|
||||
$kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO)->where('value', $knockOffDocNo)->first();
|
||||
Log::info('key: ' . json_encode($kvp));
|
||||
$booking = $kvp->owner;
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_OFFICIAL_RECEIPT_DOCNO, $docNo);
|
||||
}
|
||||
// if($eInvoiceValidationLink){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// }
|
||||
}
|
||||
else{
|
||||
$unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $unprocessedKnockOffs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ class KVPKey
|
||||
|
||||
public const AUTOCOUNT_DOCNO = 'AUTOCOUNT_DOCNO';
|
||||
|
||||
public const AUTOCOUNT_OFFICIAL_RECEIPT_DOCNO = 'AUTOCOUNT_OR_DOCNO';
|
||||
|
||||
public const AUTOCOUNT_EINVOICE_VALIDATION_LINK = 'AUTOCOUNT_EINVOICE_VALIDATION_LINK';
|
||||
|
||||
public const CREDIT_NOTE_APPROVAL_DATE = 'CREDIT_NOTE_APPROVAL_DATE';
|
||||
|
||||
@@ -9,9 +9,13 @@ use Illuminate\Http\Request;
|
||||
|
||||
class ImportController extends Controller
|
||||
{
|
||||
|
||||
public function salesInvoices(Request $request, ImportExcelLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
public function officialReceipt(Request $request, ImportExcelLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<span>Import</span>
|
||||
</button>
|
||||
<modal-component type="uploadDocumentModel">
|
||||
<upload-component :section="section" :report-type="parameters.reportType"></upload-component>
|
||||
<upload-component :url="importUrl" v-on:importSuccess="importSuccess($event)" :section="section" :report-type="parameters.reportType"></upload-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
<div class="col-12 col-md-auto p-md-0">
|
||||
@@ -122,6 +122,18 @@ export default {
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
importUrl() {
|
||||
const reportType = this.parameters.reportType;
|
||||
|
||||
const importRoutesMap = {
|
||||
'Sales Invoice Report': route('api.import.sales_invoices'),
|
||||
'01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT]': route('api.import.official_receipt'),
|
||||
};
|
||||
|
||||
return importRoutesMap[reportType] || '';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
options() {
|
||||
return [
|
||||
@@ -190,6 +202,9 @@ export default {
|
||||
this.isDownloading = false;
|
||||
this.error = error.message + '. Please try again with a shorter date span between the two date filters.';
|
||||
},
|
||||
importSuccess(payload) {
|
||||
this.error = payload.message + payload.data;
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
};
|
||||
|
||||
@@ -58,6 +58,10 @@
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
@@ -77,8 +81,15 @@
|
||||
report_type: this.reportType
|
||||
};
|
||||
|
||||
this.submit(this.route('api.import.sales_invoices'), 'post', this.section, true, true);
|
||||
}
|
||||
this.submit(this.url, 'post', this.section, true, true);
|
||||
},
|
||||
successHandler(response) {
|
||||
this.closeModal();
|
||||
this.formHandler();
|
||||
if(this.url === route('api.import.official_receipt')){
|
||||
this.$emit('importSuccess', response.payload);
|
||||
}
|
||||
},
|
||||
},
|
||||
mixins: [ModalFromHandler]
|
||||
|
||||
|
||||
+2
-1
@@ -20,5 +20,6 @@ Route::group(['prefix' => 'export', 'as' => 'export.', 'namespace' => 'Exports']
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'import', 'as' => 'import.', 'namespace' => 'Imports'], function () {
|
||||
Route::post('/import', [ImportController::class, 'salesInvoices'])->name('sales_invoices');
|
||||
Route::post('/import/sales-invoice', [ImportController::class, 'salesInvoices'])->name('sales_invoices');
|
||||
Route::post('/import/offical-receipt', [ImportController::class, 'officialReceipt'])->name('official_receipt');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user