Files
expense/app/Helpers/PeriodeHelper.php
T
root 1c1418f3e0
Deploy to VPS (PAT over HTTPS) / deploy (push) Has been cancelled
Initial commit - expense
2026-06-01 15:01:03 +07:00

23 lines
749 B
PHP

<?php
namespace App\Helpers;
use Illuminate\Support\Carbon;
class PeriodeHelper
{
/**
* 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();
// 2. Tentukan tanggal 13 di bulan berikutnya (Bulan berjalan + 1)
$endDate = Carbon::parse("13 $month $year")->addMonth()->endOfDay()->toDateTimeString();
return [$startDate, $endDate];
}
}