{#if isValid}

Ready to create Wave invoice

All items are linked to Wave. Click below to create the invoice.

{:else if !hasLinkedItems && customerLinked && totalErrors === 0}

No line items

Add at least one linked revenue or project to create the invoice.

{:else}

{totalErrors} item{totalErrors !== 1 ? 's' : ''} need{totalErrors === 1 ? 's' : ''} linking

Link all items to Wave products before creating the invoice.

{/if}

Customer

{customer.customerName} {#if customerLinked} Linked {:else} Not Linked {/if}
{#if customerLinked}

Wave Customer ID: {customer.waveCustomerId}

{:else}

Link this customer to a Wave customer to continue.

{/if}

Revenues

{#if unlinkedRevenues.length > 0} {unlinkedRevenues.length} unlinked {:else if revenues.length > 0} All linked {/if}
{#if revenues.length === 0}

No revenues on this invoice.

{:else}
{#each revenues as revenue (revenue.id)} {@const accountName = getAccountName(revenue.accountId)} {@const isLinked = !!revenue.waveServiceId}
{accountName} {#if isLinked} Linked {:else} Not Linked {/if}

{formatShortDate(revenue.startDate)} {#if revenue.endDate} - {formatShortDate(revenue.endDate)} {:else} - Ongoing {/if}

{#if isLinked}

Product: {getProductName(revenue.waveServiceId)}

{/if}
{formatCurrency(revenue.amount)}
{/each}
{/if}

Projects

{#if unlinkedProjects.length > 0} {unlinkedProjects.length} unlinked {:else if projects.length > 0} All linked {/if}
{#if projects.length === 0}

No projects on this invoice.

{:else}
{#each projects as project (project.id)} {@const isLinked = !!project.waveServiceId}
{project.name} {#if isLinked} Linked {:else} Not Linked {/if}

{formatShortDate(project.date)}

{#if isLinked}

Product: {getProductName(project.waveServiceId)}

{/if}
{formatCurrency(project.amount)}
{/each}
{/if}