Files
expense/app/Helpers/PeriodeHelper.php
T

23 lines
749 B
PHP
Raw Normal View History

2025-05-05 19:40:38 +07:00
<?php
namespace App\Helpers;
2026-06-01 15:01:03 +07:00
2025-05-05 19:40:38 +07:00
use Illuminate\Support\Carbon;
class PeriodeHelper
{
2026-06-01 15:01:03 +07:00
/**
* Mendapatkan rentang tanggal fisik pengakuan untuk sebuah periode akuntansi (Bulan & Tahun)
* Contoh: Periode "april 2026" -> Start: 11 April 2026, End: 13 Mei 2026 (Closing Date)
*/
public static function getPeriodeRange(string $month, int $year): array
{
// 1. Tentukan tanggal 11 di bulan dan tahun yang dipilih
$startDate = Carbon::parse("11 $month $year")->startOfDay()->toDateTimeString();
2025-05-05 19:40:38 +07:00
2026-06-01 15:01:03 +07:00
// 2. Tentukan tanggal 13 di bulan berikutnya (Bulan berjalan + 1)
$endDate = Carbon::parse("13 $month $year")->addMonth()->endOfDay()->toDateTimeString();
2025-05-05 19:40:38 +07:00
2026-06-01 15:01:03 +07:00
return [$startDate, $endDate];
}
}