Files
basicdata/app/Helpers/Currency.php
Daeng Deni Mardaeni 3a4c5bf4ca feat(basicdata): tambahkan helper untuk penghitungan hari kerja dan pembaruan format mata uang
- Menambahkan helper `workingDays` untuk menghitung jumlah hari kerja antara dua tanggal.
- Menambahkan helper `holidays` untuk mendapatkan daftar tanggal libur.
- Memperbarui fungsi `format_currency` menjadi `currencyFormat` dengan menambahkan dokumentasi yang lebih jelas.
- Mengubah format desimal mata uang IDR menjadi 2 desimal di `CurrencySeeder`.
- Menambahkan file `HolidayCalendar.php` ke dalam daftar autoload di `module.json`.
- Menambahkan proses truncate sebelum insert data di seeder `CurrencySeeder`.
2025-05-04 19:17:04 +07:00

23 lines
882 B
PHP

<?php
use Modules\Basicdata\Models\Currency;
/**
* Format a number as a currency string with appropriate symbol and formatting.
*
* This function retrieves currency information from the database and formats
* the provided number according to the currency's specifications.
*
* @param float|int $number The number to be formatted as currency
* @param string $currency The currency code (default: 'IDR')
* @return string The formatted currency string with symbol and proper number formatting
*/
if(!function_exists('currencyFormat')) {
function currencyFormat($number, $currency = 'IDR') {
$currency = Currency::where('code', $currency)->first();
$symbol = $currency->symbol?? '';
return $symbol . ' ' . number_format($number, $currency->decimal_places, ',', '.');
}
}