Php Rent Free [better] Weeks

.free-week background-color: #4caf50; color: white; .paid-week background-color: #f44336; color: white;

function isWeekFree($leaseId, $date) // Check if $date falls inside any rent_free_weeks entry $sql = "SELECT 1 FROM rent_free_weeks WHERE lease_id = ? AND week_start_date <= ? AND week_end_date >= ?"; // return boolean php rent free weeks

public function calculateDailyRate($weeklyRent) return $weeklyRent / 7; .free-week background-color: #4caf50

Real-world rentals rarely start on a Monday. If a tenant moves in on a Wednesday, and week 2 is free, you must prorate the free period. .paid-week background-color: #f44336

$freeLines = array_filter($lines, fn($line) => $line['is_free'] === true); $this->assertCount(1, $freeLines); // Assuming 1 free week in April $this->assertEquals(0, $freeLines[0]['amount']);

$invoices[] = [ 'lease_id' => $leaseId, 'month' => $invoiceMonth, 'amount_due' => $adjustedMonthlyRent, 'due_date' => $invoiceDate->format('Y-m-d'), 'is_free_week_applied' => false // discount already spread ];