> ## Documentation Index
> Fetch the complete documentation index at: https://docs.younegotiate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calendar Background Jobs

> Jane changes an installment payment date.

## Real-World Example

Jane changes an installment payment date. The portal updates the internal schedule immediately and then dispatches a background job so Google or Microsoft Calendar receives the same date change.

## Visual Flow

```mermaid placement="top-right" actions={true} theme={"system"}
flowchart TD
    A["Schedule amount or date changes"] --> B["Portal updates scheduled transaction"]
    B --> C{"External calendar live update enabled?"}
    C -->|Yes| D["Calendar update job runs"]
    C -->|No| E["Portal calendar remains source of truth"]
    D --> F["External event is created, updated, or deleted"]
    classDef default fill:#F8FAFC,stroke:#64748B,stroke-width:1.5px,color:#0F172A;
    classDef actor fill:#E0F2FE,stroke:#0284C7,stroke-width:2px,color:#0C4A6E;
    classDef system fill:#F8FAFC,stroke:#64748B,stroke-width:1.5px,color:#0F172A;
    classDef decision fill:#FEF3C7,stroke:#D97706,stroke-width:2px,color:#78350F;
    classDef risk fill:#FEE2E2,stroke:#DC2626,stroke-width:2px,color:#7F1D1D;
    classDef outcome fill:#DCFCE7,stroke:#16A34A,stroke-width:2px,color:#14532D;
    class A,B,D,E system;
    class C decision;
    class F outcome;
    linkStyle default stroke:#94A3B8,stroke-width:2px;
```

## How It Should Work

* It should create, update, delete, or change amounts on external events when live sync is enabled.
* It should keep the internal schedule as the source of truth.
* It should handle Google and Microsoft sync without blocking the consumer page.

## How It Should Not Work

* It should not let a calendar job change payment truth by itself.
* It should not fail the main payment action only because an external calendar provider is unavailable.
* It should not update events for consumers who disabled live sync.

## Developer Notes

* Calendar jobs are dispatched from schedule changes, payment processing, and calendar connection flows.
* Use queue-safe, idempotent handling because the same payment can be touched by multiple flows.

## Related App Areas

* `app/Jobs/CreateCalendarEvents.php`
* `app/Jobs/UpdateCalendarEvents.php`
* `app/Jobs/UpdateCalendarEventAmount.php`
* `app/Jobs/DeleteCalendarEvents.php`
* `app/Livewire/Consumer/SchedulePlan.php`
