Currencies
Description
Currencies adds currency and exchange-rate management to Enso.
The package exposes CRUD flows for currencies and exchange rates, keeps track of the application's default currency, links currencies to countries through currency codes, and provides a conversion service together with a conversion endpoint.
It is intended for private Enso deployments that need administrative currency management and server-side amount conversion.
Installation
This is a proprietary package distributed through the private Enso registry.
Run the package migrations:
php artisan migrate
Optional publishes:
php artisan vendor:publish --tag=currencies-config
php artisan vendor:publish --tag=currency-seeder
Default configuration:
return [
'converterPrecision' => 4,
];
Features
- Currency CRUD and selector endpoints.
- Exchange-rate CRUD endpoints with per-date conversion values.
- Default currency protection against accidental deletion.
- Server-side conversion service with configurable precision and fallback to the most recent rate when the requested date has no exact match.
- Included seeders and factories for bootstrapping data.
Usage
Use the conversion service in code:
use LaravelEnso\Currencies\Models\Currency;
use LaravelEnso\Currencies\Services\Conversion;
$from = Currency::whereCode('EUR')->firstOrFail();
$to = Currency::whereCode('RON')->firstOrFail();
$amount = (new Conversion())
->from($from)
->to($to)
->amount('100.00')
->handle();
You can also convert to the default currency directly:
Conversion::toDefault($from, '100.00');
API
HTTP routes
Currencies:
GET api/administration/currencies/createPOST api/administration/currenciesGET api/administration/currencies/{currency}/editPATCH api/administration/currencies/{currency}DELETE api/administration/currencies/{currency}GET api/administration/currencies/initTableGET api/administration/currencies/tableDataGET api/administration/currencies/exportExcelGET api/administration/currencies/optionsGET api/administration/currencies/convert
Exchange rates:
GET api/administration/exchangeRates/createPOST api/administration/exchangeRatesGET api/administration/exchangeRates/{exchangeRate}/editPATCH api/administration/exchangeRates/{exchangeRate}DELETE api/administration/exchangeRates/{exchangeRate}GET api/administration/exchangeRates/initTableGET api/administration/exchangeRates/tableDataGET api/administration/exchangeRates/exportExcel
Depends On
Required Enso packages:
laravel-enso/api↗laravel-enso/core↗laravel-enso/countries↗laravel-enso/forms↗laravel-enso/helpers↗laravel-enso/migrator↗laravel-enso/select↗laravel-enso/tables↗
Companion frontend package: