mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 22:44:03 +00:00
E-Invoice - Automapping Issues, Sales Invoice Report
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Transaction;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
@@ -69,14 +70,14 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
$end_date = Carbon::now()->endOfDay();
|
||||
}
|
||||
|
||||
$query = Transaction::query();
|
||||
$query = Booking::where('status', ApprovalStatus::COMPLETED);
|
||||
|
||||
$query->where('type', TransactionType::PAYMENT)->where('payment_method', '!=', PaymentMethodType::WALLET);
|
||||
// $query->where('type', TransactionType::PAYMENT);
|
||||
$query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
$query->whereHas('booking.transactions', function ($query) {
|
||||
$query->where('type', TransactionType::PURCHASE_ORDER)->complete();
|
||||
});
|
||||
// $query = Transaction::query();
|
||||
// $query->where('type', TransactionType::PAYMENT)->where('payment_method', '!=', PaymentMethodType::WALLET);
|
||||
// $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
// $query->whereHas('booking.transactions', function ($query) {
|
||||
// $query->where('type', TransactionType::PURCHASE_ORDER)->complete();
|
||||
// });
|
||||
|
||||
if($start_date && $end_date) {
|
||||
$query->whereBetween('created_at', [
|
||||
@@ -95,14 +96,13 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
* @param Booking $booking
|
||||
* @return array
|
||||
*/
|
||||
public function map($transaction): array
|
||||
public function map($booking): array
|
||||
{
|
||||
$booking = $transaction->owner()->first();
|
||||
// $transaction = $booking->transactions()->payments()->complete()->first();
|
||||
$purchaseOrder = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
|
||||
//$purchaseOrder = $booking->transactions()->payments()->complete()->first();
|
||||
$company = $booking->company()->first();
|
||||
|
||||
$lastPaymentTransaction = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->latest()->first();
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Exports\ExportController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
Route::group(['prefix' => 'export', 'as' => 'export.', 'namespace' => 'Exports'], function () {
|
||||
Route::group(['prefix' => 'transactions', 'as' => 'transaction.'], function () {
|
||||
Route::get('/sales-invoices', 'ExportController@salesInvoices')->name('sales-invoices');
|
||||
Route::get('/sales-invoices', [ExportController::class, 'salesInvoices'])->name('sales-invoices');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user