<?php

use App\Http\Controllers\Transactions\ETLPurchaseOrderTransactionController;
use App\Http\Controllers\Transactions\ListTransactionsController;
use App\Http\Controllers\Transactions\ListTransactionsJobController;
use App\Http\Controllers\Transactions\ListUrgentTransactionsController;
use App\Http\Controllers\Transactions\SuspendTransactionController;
use App\Http\Controllers\Transactions\CreateSupplierTransactionController;
use App\Http\Controllers\Transactions\CreateSupplierBillGroupController;
use App\Http\Controllers\Transactions\CreatePaymentProofDocumentController;
use App\Http\Controllers\Transactions\UpdatePaymentTransactionStatusController;
use App\Http\Controllers\Transactions\UpdateRefundTransactionStatusController;
use App\Http\Controllers\Transactions\DeleteRefundTransactionController;
use App\Http\Controllers\Transactions\DeletePaymentProofDocumentController;
use App\Http\Controllers\Transactions\CreatePurchaseOrderTransactionController;
use App\Http\Controllers\Transactions\ImportPurchaseOrderTransactionController;
use App\Http\Controllers\Transactions\CreateBulkPurchaseOrderTransactionController;
use App\Http\Controllers\Transactions\ListWalletTransactionsController;
use App\Http\Controllers\Transactions\FetchCompanyAccountBalanceController;
use App\Http\Controllers\Transactions\FetchCompanyTransactionStatementController;
use App\Http\Controllers\Transactions\FetchBankAccountBalanceController;
use App\Http\Controllers\Transactions\ListGroupsController;
use App\Http\Controllers\Transactions\DeleteGroupController;
use App\Http\Controllers\Transactions\UpdateGroupController;
use App\Http\Controllers\Transactions\UpdateGroupTransferFeeController;
use App\Http\Controllers\Transactions\CreateBulkPurchaseOrderDocumentController;
use App\Http\Controllers\Transactions\ListBillGroupsController;
use App\Http\Controllers\Transactions\CreateBillGroupPaymentProofDocumentController;
use App\Http\Controllers\Transactions\ApproveBillGroupPaymentVerificationController;
use App\Http\Controllers\Transactions\DeleteBillGroupController;
use App\Http\Controllers\Transactions\CancelBillGroupController;
use App\Http\Controllers\Transactions\CreateBillGroupPaymentTransactionController;
use App\Http\Controllers\Transactions\UpdateCreditNoteOptController;
use Illuminate\Support\Facades\Route;

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

    Route::get('/list', [ListTransactionsController::class, 'list'])->name('list');
    Route::get('/list/job', [ListTransactionsJobController::class, 'list'])->name('list.job');
    Route::get('/list/urgent', [ListUrgentTransactionsController::class, 'list'])->name('list.urgent');
    Route::delete('/suspend/{id}', [SuspendTransactionController::class, 'suspend'])->name('suspend');

    Route::post('/supplier/{id}/bill/create', [CreateSupplierTransactionController::class, 'create'])->name('supplier.create');
    Route::post('/supplier/{id}/bill/group/create', [CreateSupplierBillGroupController::class, 'create'])->name('supplier.bill_group.create');
    Route::post('{id}/bill/verification', [CreatePaymentProofDocumentController::class, 'verify'])->name('bill.verification');
    Route::post('{id}/bill/pay', [CreatePaymentProofDocumentController::class, 'pay'])->name('bill.pay');
    Route::put('/{id}/bill/{status}', [UpdatePaymentTransactionStatusController::class, 'update'])->where('status', 'pending|complete')->name('bill.status');
    Route::put('/{id}/refund/status/update/{status}', [UpdateRefundTransactionStatusController::class, 'update'])->name('refund.status.update');

    Route::delete('/refund/{id}/delete', [DeleteRefundTransactionController::class, 'delete'])->name('refund.delete');

    Route::delete('{id}/bill/delete', [DeletePaymentProofDocumentController::class, 'delete'])->name('bill.delete');

    Route::post('booking/{id}/details/update', [CreatePurchaseOrderTransactionController::class, 'create'])->name('po.create');
    Route::post('booking/{id}/details/import', [ImportPurchaseOrderTransactionController::class, 'import'])->name('po.import');
    Route::post('booking/{id}/details/etl', [ETLPurchaseOrderTransactionController::class, 'etl'])->name('po.etl');

    Route::get('bulk/po/{issuer_id}/{start_date}/{end_date}', [CreateBulkPurchaseOrderTransactionController::class, 'create'])->name('po.bulk.create');

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

    Route::get('/company/{id}/account/balance', [FetchCompanyAccountBalanceController::class, 'fetch'])->name('company.account.balance');
    Route::get('/company/{id}/transaction/fetch', [FetchCompanyTransactionStatementController::class, 'fetch'])->name('company.transaction.fetch');

    Route::get('/bank/{id}/account/balance', [FetchBankAccountBalanceController::class, 'fetch'])->name('bank.account.balance');

    Route::group(['prefix' => 'groups', 'as' => 'group.'], function () {
        Route::get('/list', [ListGroupsController::class, 'list'])->name('list');
        Route::delete('/{id}/delete', [DeleteGroupController::class, 'delete'])->name('delete');
        Route::put('/{id}/update', [UpdateGroupController::class, 'update'])->name('update');
        Route::put('/{id}/update/fee', [UpdateGroupTransferFeeController::class, 'update'])->name('fee.update');
        Route::post('/{id}/approve', [CreateBulkPurchaseOrderDocumentController::class, 'aprove'])->name('approve');
        Route::post('/bulk/po', [CreateBulkPurchaseOrderDocumentController::class, 'create'])->name('bulk.po');

        Route::group(['prefix' => 'bills', 'as' => 'bill.'], function () {
            Route::get('/list', [ListBillGroupsController::class, 'list'])->name('list');
            Route::post('/transaction/{id}', [CreateBillGroupPaymentProofDocumentController::class, 'create'])->name('payment_proof.create');
            Route::post('/transaction/{id}/approval/{status}', [ApproveBillGroupPaymentVerificationController::class, 'approve'])->where('status', 'approve|reject')->name('payment_proof.approval');
            Route::delete('/{id}/delete', [DeleteBillGroupController::class, 'delete'])->name('delete');
            Route::put('/{id}/cancel', [CancelBillGroupController::class, 'cancel'])->name('cancel');
            Route::post('/{id}/pay', [CreateBillGroupPaymentTransactionController::class, 'pay'])->name('pay');
            // Route::post('/bulk/po', [CreateBulkPurchaseOrderDocumentController::class, 'create'])->name('bulk.po');
        });
    });

    Route::get('/refund/{id}/opt', [UpdateCreditNoteOptController::class, 'opt'])->name('refund.opt');
});
