Refactor number format to Toolbox SYNC 47
This commit is contained in:
parent
d7edd72ec5
commit
0ac449d097
8 changed files with 37 additions and 38 deletions
|
|
@ -17,9 +17,9 @@ use App\Http\Requests\Fo\Orders\SetOrderTimeSlotRequest;
|
|||
use App\Http\Requests\Fo\Orders\ShippingFormRequest;
|
||||
use App\Http\Requests\Fo\Orders\ShippingModeFormRequest;
|
||||
use App\Http\Resources\ShopResource;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use App\Mail\NewOrderIncome;
|
||||
use App\Models\Customer\Customer;
|
||||
use App\Models\Merchandise\Product;
|
||||
use App\Models\Payment\Transaction;
|
||||
use App\Models\Shop\DeliveryMode;
|
||||
use App\Models\Site\GeneralConfig;
|
||||
|
|
@ -721,7 +721,7 @@ class OrderController extends Controller
|
|||
if ($sampleOrder->total_ttc < $minAmountForTransaction) {
|
||||
\redirect()->route('home')
|
||||
->with('warning', trans('Le montant minimal pour une commande est de :minAmount', [
|
||||
'minAmount' => Product::fmtCurrency($minAmountForTransaction)
|
||||
'minAmount' => ToolboxHelper::fmtCurrency($minAmountForTransaction)
|
||||
]))->throwResponse();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,38 @@ use Illuminate\Support\Facades\Validator;
|
|||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Money\Money;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class ToolboxHelper
|
||||
{
|
||||
/**
|
||||
* Get displayable price value
|
||||
*
|
||||
* @param mixed $value Amount in cents.
|
||||
* @param string $suffix Append some text.
|
||||
* @return string
|
||||
*/
|
||||
public static function fmtCurrency($value, string $suffix = 'TTC'): string
|
||||
{
|
||||
return \trim(sprintf(
|
||||
'%s %s',
|
||||
app('phpMoneyFormatter')->format(new Money($value, app('phpMoneyCurrency'))),
|
||||
$suffix
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get displayable price value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public static function fmtSellUnit($value): string
|
||||
{
|
||||
return !empty($value) ? "/ {$value}" : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an unique reference from model on reference column by default
|
||||
*
|
||||
|
|
|
|||
|
|
@ -692,33 +692,4 @@ class Product extends Model implements Buyable
|
|||
// @phpcs:enable
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Get displayable price value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $suffix
|
||||
* @return string
|
||||
*/
|
||||
public static function fmtCurrency($value, string $suffix = 'TTC'): string
|
||||
{
|
||||
return sprintf(
|
||||
'%s € %s',
|
||||
number_format(\intval($value) / 100, 2, ',', ' '),
|
||||
$suffix
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get displayable price value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public static function fmtSellUnit($value): string
|
||||
{
|
||||
return !empty($value) ? "/ {$value}" : '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit c8038a68ea57e586160ddcf902606b520d140727
|
||||
Subproject commit bd61a507a675d85be6ac7d3c80f915ddb2195211
|
||||
|
|
@ -57,8 +57,8 @@
|
|||
src="{{ asset(resize($product->picture, 'boStickers')) }}"
|
||||
alt="{{ Str::limit($product->name, 15) }}">
|
||||
<div class="d-flex flex-column">
|
||||
<small class="text-secondary text-decoration-line-through">{{ \App\Models\Merchandise\Product::fmtCurrency($product->price)}}</small>
|
||||
<span class="text-primary m-0">{{ \App\Models\Merchandise\Product::fmtCurrency($product->discounted_price) }}</span>
|
||||
<small class="text-secondary text-decoration-line-through">{{ \App\Lib\Helpers\ToolboxHelper::fmtCurrency($product->price)}}</small>
|
||||
<span class="text-primary m-0">{{ \App\Lib\Helpers\ToolboxHelper::fmtCurrency($product->discounted_price) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
}, 0), 2, ',', '')
|
||||
]) }}</span><br>
|
||||
@endif
|
||||
<span class="fw-bold text-nowrap">{{ __('TVA : :total', ['total' => \App\Models\Merchandise\Product::fmtCurrency($order->total_ttc - $order->total_ht)]) }}</span>
|
||||
<span class="fw-bold text-nowrap">{{ __('Total TTC : :total', ['total' => \App\Models\Merchandise\Product::fmtCurrency($order->total_ttc)]) }}</span>
|
||||
<span class="fw-bold text-nowrap">{{ __('TVA : :total', ['total' => \App\Lib\Helpers\ToolboxHelper::fmtCurrency($order->total_ttc - $order->total_ht)]) }}</span>
|
||||
<span class="fw-bold text-nowrap">{{ __('Total TTC : :total', ['total' => \App\Lib\Helpers\ToolboxHelper::fmtCurrency($order->total_ttc)]) }}</span>
|
||||
<span class="fw-bold text-nowrap">{{ __('Payé : :total', ['total' => app('phpMoneyFormatter')->format($order->getTotalPayed())]) }}</span>
|
||||
<span class="fw-bold text-nowrap">{{ __('Reboursé : :total', ['total' => app('phpMoneyFormatter')->format($order->getTotalRefunded())]) }}</span>
|
||||
</fieldset>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<tr>
|
||||
<td>{{ $orderModel->reference }}</td>
|
||||
<td><span>{{ $orderModel->created_at->isoFormat('\L\e DD/MM/YYYY \à HH:mm') }}</span></td>
|
||||
<td>{{ \App\Models\Merchandise\Product::fmtCurrency($orderModel->total_ttc, '') }}</td>
|
||||
<td>{{ \App\Lib\Helpers\ToolboxHelper::fmtCurrency($orderModel->total_ttc, '') }}</td>
|
||||
<td>@include('back::pages.orders.parts.badges.validation-status', ['order' => $orderModel])</td>
|
||||
<td>@include('back::pages.orders.parts.badges.payment-status', ['order' => $orderModel])</td>
|
||||
<td>@include('back::pages.orders.parts.badges.delivery-status', ['order' => $orderModel])</td>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
</td>
|
||||
<td><img src="{{ asset($productModel->picture) }}" height="100px"></td>
|
||||
<td>
|
||||
<span>{{ \App\Models\Merchandise\Product::fmtCurrency($productModel->price, 'HT') }}</span>
|
||||
<span>{{ \App\Lib\Helpers\ToolboxHelper::fmtCurrency($productModel->price, 'HT') }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span>{{ Str::limit(strip_tags($productModel->description)) }}</span>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue