modified logic for proper pending days in invoice in transit #168
@@ -67,14 +67,21 @@ class SendInvoiceTransitReport extends Command
|
||||
'im.id as invoice_master_id',
|
||||
'im.transport_name',
|
||||
DB::raw('CAST(im.transit_days AS INTEGER) as transit_days'),
|
||||
DB::raw('(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE)) as delayed_days')
|
||||
// DB::raw('(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE)) as delayed_days')
|
||||
DB::raw('
|
||||
GREATEST(
|
||||
0,
|
||||
(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE) - 1)
|
||||
- CAST(im.transit_days AS INTEGER)
|
||||
) AS delayed_days
|
||||
')
|
||||
)
|
||||
->when($plantId != 0, fn($q) => $q->where('it.plant_id', $plantId))
|
||||
->whereNotNull('it.lr_bl_aw_date')
|
||||
// ->whereRaw(
|
||||
// '(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE)) >= CAST(im.transit_days AS INTEGER)'
|
||||
// )
|
||||
->whereRaw('(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE) + 1) >= CAST(im.transit_days AS INTEGER)')
|
||||
->whereRaw('
|
||||
(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE))
|
||||
- CAST(im.transit_days AS INTEGER) > 0
|
||||
')
|
||||
->get();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user