<?php

use Illuminate\Support\Facades\Route;

Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => 'transaction.'], function () {

    Route::get('/list', 'ListTransactionsController@list')->middleware('storage.invoice.check.bytransactions')->name('list');
    Route::delete('/suspend/{id}', 'SuspendTransactionController@suspend')->name('suspend');
    Route::delete('/delete/{id}', 'DeleteTransactionController@delete')->name('delete');
    Route::delete('/delete-payment/{id}', 'DeletePaymentTransactionController@delete')->name('payment.delete');
    Route::put('{id}/status/update/{status}', 'UpdateTransactionStatusController@update')->where('status', 'approve|expire|reject')->name('update');
    route::post('/{invoice_id}/regenerate', 'RegenerateSingleShippingInvoiceTransactionController@regenerate')->name('invoice.regenerate');
    Route::post('/waive/{id}', 'WaiveTransactionController@waive')->name('waive');
    Route::post('/storage-invoice/{invoice_id}/regenerate', 'RegenerateSingleStorageInvoiceTransactionController@regenerate')->name('storage.invoice.regenerate');

    Route::get('wallet/list', 'ListWalletTransactionsController@list')->name('wallet.list');

    Route::group(['prefix' => 'payment', 'as' => 'payment.'], function () {
        Route::post('/create', 'CreatePaymentTransactionController@create')->name('create');
        Route::post('/upload-verification-document/{transaction_id}', 'UploadPaymentVerificationDocumentController@upload')->name('verification.create');
        Route::put('/approve/{transaction_id}/{status}', 'ApprovePaymentTransactionController@approve')->where('status', 'approve|reject')->name('approval');
    });

    Route::group(['prefix' => 'invoice', 'as' => 'invoice.'], function () {
        route::post('/shipping-invoice/create', 'CreateShippingInvoiceTransactionController@create')->name('create');
        route::post('/shipping-invoice/company/{company_module_id}/regenerate', 'RegenerateShippingInvoiceTransactionController@regenerate')->name('company.regenerate');
        route::put('/shipping-invoice/{id}/update', 'UpdateShippingInvoiceTransactionController@update')->name('update');
        route::put('/shipping-invoice/{id}/approve', 'ApproveShippingInvoiceTransactionController@approve')->name('approve');
    });

    route::post('/shipping-invoice/calculator', 'ShippingEstimationCalculatorController@calculate')->name('shipping.estimation.calculator');

    // Route::group(['prefix' => '{id}/payment', 'as' => 'payment.'], function () {
    //     Route::post('quotation', 'FetchBookingPaymentQuotationController@fetch')->name('quotation');
    //     Route::post('create', 'CreateBookingPaymentController@create')->name('create');
    //     Route::post('{payment_id}/verification/create', 'CreatePaymentVerificationController@create')->name('verification.create');
    //     Route::put('/{payment_id}/approval/{status}', 'ApprovePaymentVerificationController@approve')->where('status', 'approve|reject')->name('approval');
    // });


    // route::post('{id}/bill/verification', 'CreatePaymentProofDocumentController@verify')->name('bill.verification');

    // Route::post('booking/{id}/details/update', 'CreatePurchaseOrderTransactionController@create')->name('po.create');

    Route::group(['prefix' => 'groups', 'as' => 'group.'], function () {
        Route::post('/{transaction_ids}/create', 'CreateGroupsController@create')->name('create');
        Route::get('/list', 'ListGroupsController@list')->name('list');
        // Route::get('/list', 'ListGroupsController@list')->middleware('storage.invoice.check.bygroup')->name('list');
        Route::delete('/{id}/delete', 'DeleteGroupController@delete')->name('delete');
        Route::delete('/{id}/delete-paid', 'DeletePaidGroupController@delete')->name('paidGroup.delete');
        Route::put('/{id}/update', 'UpdateGroupController@update')->name('update');
        // Route::post('/{id}/approve', 'CreateBulkPurchaseOrderDocumentController@aprove')->name('approve');
        // Route::post('/bulk/po', 'CreateBulkPurchaseOrderDocumentController@create')->name('bulk.po');
    });

});
