Skip to content

Commit 0d842a4

Browse files
committed
Fixe KPI after #482
1 parent 37db9d4 commit 0d842a4

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

app/Services/DeliveryKPIService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public function getDeliveryMonthlyProgress($month ,$year)
3636
{
3737
return DB::table('delivery_lines')
3838
->join('order_lines', 'delivery_lines.order_line_id', '=', 'order_lines.id')
39-
->selectRaw('FLOOR(SUM((order_lines.selling_price * order_lines.qty)-(order_lines.selling_price * order_lines.qty)*(order_lines.discount/100))) AS orderSum')
39+
->selectRaw('FLOOR(SUM((order_lines.selling_price * delivery_lines.qty)-(order_lines.selling_price * delivery_lines.qty)*(order_lines.discount/100))) AS orderSum')
4040
->whereYear('delivery_lines.created_at', '=', $year)
4141
->whereMonth('delivery_lines.created_at', $month)
42-
->get();
42+
->first() ?? (object) ['orderSum' => 0];
4343
}
4444
}

app/Services/OrderKPIService.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ public function getOrderMonthlyRemainingToDelivery($month ,$year)
139139
{
140140
return DB::table('order_lines')
141141
->selectRaw('
142-
FLOOR(SUM((selling_price * qty)-(selling_price * qty)*(discount/100))) AS orderSum
142+
FLOOR(SUM((selling_price * delivered_remaining_qty)-(selling_price * delivered_remaining_qty)*(discount/100))) AS orderSum
143143
')
144144
->whereYear('delivery_date', '=', $year)
145145
->whereMonth('delivery_date', $month)
146146
->groupByRaw('MONTH(delivery_date) ')
147-
->get();
147+
->first() ?? (object) ['orderSum' => 0];
148148
}
149149

150150
/**
@@ -156,10 +156,11 @@ public function getOrderMonthlyRemainingToInvoice()
156156
{
157157
return DB::table('order_lines')
158158
->selectRaw('
159-
FLOOR(SUM((selling_price * qty)-(selling_price * qty)*(discount/100))) AS orderSum
159+
FLOOR(SUM((selling_price * invoiced_remaining_qty)-(selling_price * invoiced_remaining_qty)*(discount/100))) AS orderSum
160160
')
161161
->where('invoice_status', 1)
162-
->get();
162+
->Orwhere('invoice_status', 2)
163+
->first() ?? (object) ['orderSum' => 0];
163164
}
164165

165166
/**

resources/lang/en/general_content.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,9 @@
588588
'no_product_trans_key' => 'No product, go product page for add item',
589589
'announcement_trans_key' => 'Announcements',
590590
'order_to_be_delivered_trans_key' => 'Order to be delivered',
591+
'order_delivered_trans_key' => 'Order delivered',
591592
'order_to_be_invoiced_trans_key' => 'Order to be invoiced',
593+
'order_invoiced_trans_key' => 'Order invoiced',
592594
'delivered_month_in_progress_trans_key' => 'Total Delivered for the month',
593595
'remaining_month_trans_key' => 'Total remaining to deliver',
594596
'remaining_invoice_month_trans_key' => 'Total remaining to invoice',

resources/lang/fr/general_content.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,9 @@
588588
'no_product_trans_key' => 'Aucun produit, accédez à la page du produit pour ajouter un article',
589589
'announcement_trans_key' => 'Annonces',
590590
'order_to_be_delivered_trans_key' => 'Commandes à livrée(s)',
591+
'order_delivered_trans_key' => 'Commandes livrée(s)',
591592
'order_to_be_invoiced_trans_key' => 'Commandes à facturée(s)',
593+
'order_invoiced_trans_key' => 'Commandes facturée(s)',
592594
'delivered_month_in_progress_trans_key' => 'Total livré du mois',
593595
'remaining_month_trans_key' => 'Total restant à livrer',
594596
'remaining_invoice_month_trans_key' => 'Total restant à facturer',

resources/views/dashboard.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,15 @@
281281

282282
<!-- TABLE: DELIVERED -->
283283
<div class="col-lg-6 col-md-12">
284-
<x-adminlte-small-box title="{{ number_format($deliveredMonthInProgress[0]->orderSum,2) ?? 0}} {{ $Factory->curency }}"
284+
<x-adminlte-small-box title="{{ number_format($deliveredMonthInProgress->orderSum,2) ?? 0}} {{ $Factory->curency }}"
285285
text="{{ __('general_content.delivered_month_in_progress_trans_key') }}"
286286
icon="icon fas fa-info"
287287
theme="yellow"
288288
url="{{ route('orders') }}"
289289
url-text="{{ __('general_content.view_details_trans_key') }}"/>
290290
</div>
291291
<div class="col-lg-6 col-md-12">
292-
<x-adminlte-small-box title="{{ number_format($remainingDeliveryOrder[0]->orderSum ?? 0 -$remainingDeliveryOrder[0]->orderSum ?? 0 ,2)}} {{ $Factory->curency }}"
292+
<x-adminlte-small-box title="{{ number_format($remainingDeliveryOrder->orderSum ?? 0 - $deliveredMonthInProgress->orderSum ?? 0 ,2)}} {{ $Factory->curency }}"
293293
text="{{ __('general_content.remaining_month_trans_key') }}"
294294
icon="icon fas fa-info"
295295
theme="danger"

resources/views/workflow/orders-index.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<div class="tab-pane active" id="Dashboard">
2222
<div class="row">
2323
<div class="col-lg-4">
24-
<x-adminlte-small-box title="{{ $deliveredOrdersPercentage }}%" text="{{ __('general_content.order_to_be_delivered_trans_key') }}" icon="fas fa-shipping-fast" theme="success"/>
24+
<x-adminlte-small-box title="{{ $deliveredOrdersPercentage }}%" text="{{ __('general_content.order_delivered_trans_key') }}" icon="fas fa-shipping-fast" theme="success"/>
2525
</div>
2626
<div class="col-lg-4">
27-
<x-adminlte-small-box title="{{ $invoicedOrdersPercentage }} %" text="{{ __('general_content.order_to_be_delivered_trans_key') }}" icon="fas fa-file-invoice-dollar" theme="info"/>
27+
<x-adminlte-small-box title="{{ $invoicedOrdersPercentage }} %" text="{{ __('general_content.order_invoiced_trans_key') }}" icon="fas fa-file-invoice-dollar" theme="info"/>
2828
</div>
2929
<div class="col-lg-4">
3030
<x-adminlte-small-box title="{{ $pendingDeliveries }}" text="Commandes en attente" icon="fas fa-hourglass-half" theme="warning"/>
@@ -33,11 +33,11 @@
3333

3434
<div class="row">
3535
<div class="col-lg-4 col-4">
36-
<x-adminlte-small-box title="{{ number_format($remainingDeliveryOrder[0]->orderSum ?? 0 -$remainingDeliveryOrder[0]->orderSum ?? 0 ,2)}} {{ $Factory->curency }}"
36+
<x-adminlte-small-box title="{{ number_format($remainingDeliveryOrder->orderSum ?? 0 -$remainingDeliveryOrder->orderSum ?? 0 ,2)}} {{ $Factory->curency }}"
3737
text="{{ __('general_content.remaining_month_trans_key') }}"
3838
icon="icon fas fa-info"
3939
theme="danger" />
40-
<x-adminlte-small-box title="{{ number_format($remainingInvoiceOrder[0]->orderSum ?? 0 -$remainingInvoiceOrder[0]->orderSum ?? 0 ,2)}} {{ $Factory->curency }}"
40+
<x-adminlte-small-box title="{{ number_format($remainingInvoiceOrder->orderSum ?? 0)}} {{ $Factory->curency }}"
4141
text="{{ __('general_content.remaining_invoice_month_trans_key') }}"
4242
icon="icon fas fa-info"
4343
theme="warning" />

0 commit comments

Comments
 (0)