from django.core.management.base import BaseCommand
from payments.utils import generate_monthly_invoices
from payments.services import mark_overdue_invoices


class Command(BaseCommand):
    help = "Runs monthly rent cycle (invoice generation + overdue updates)"

    def handle(self, *args, **kwargs):
        created = generate_monthly_invoices()
        overdue = mark_overdue_invoices()

        self.stdout.write(self.style.SUCCESS(
            f"Rent cycle complete: {created} invoices created, {overdue} marked overdue"
        ))