Skip to content

customers page: count andel sales as Andelsbiodling, flag unpaid shar… - #35

Merged
valyo merged 1 commit into
mainfrom
fix-count-andels
Nov 3, 2026
Merged

valyo merged 1 commit into
mainfrom
fix-count-andels

Conversation

@valyo

@valyo valyo commented Nov 3, 2026

Copy link
Copy Markdown
Owner

…es, sticky header

Counts

  • Every sale in the "andel" category counts as one Andelsbiodling share on the Customers table, whether it was imported or created from a paid invoice.
  • A booking is only added on top when its share is not already one of those sales: its invoice produced a sale, or the customer has an andel sale for the same harvest year (older shares were imported as sales while the booking was entered separately). This fixes double counting, e.g. Sarah Lindström showing 9 instead of 7 and Shane Saunders 5 instead of 3.
  • Lammandel is still counted from its bookings.

Customer card

  • "Shares by season" uses the same rule as the table, one entry per share (/api/customer/ -> seasons), instead of listing raw bookings. The bookings field still lists real bookings only, so the delete guard is unchanged.

Unpaid shares

  • A share that exists only as a booking has not been paid (paying the invoice creates the sale), so it is flagged: the table's Andelsbiodling badge turns red with a "N not paid" tooltip, and the card shows "2026: Andelsbiodling - not paid" in red.

Layout

  • The title, "New customer" button and table header stay fixed; only the rows scroll, and the table height follows the window.

Tests cover the counting rules (including the Sarah case), the card, the red badge and the sticky header.

…es, sticky header

Counts
- Every sale in the "andel" category counts as one Andelsbiodling share on
  the Customers table, whether it was imported or created from a paid invoice.
- A booking is only added on top when its share is not already one of those
  sales: its invoice produced a sale, or the customer has an andel sale for
  the same harvest year (older shares were imported as sales while the
  booking was entered separately). This fixes double counting, e.g. Sarah
  Lindström showing 9 instead of 7 and Shane Saunders 5 instead of 3.
- Lammandel is still counted from its bookings.

Customer card
- "Shares by season" uses the same rule as the table, one entry per share
  (/api/customer/<id> -> `seasons`), instead of listing raw bookings. The
  `bookings` field still lists real bookings only, so the delete guard is
  unchanged.

Unpaid shares
- A share that exists only as a booking has not been paid (paying the invoice
  creates the sale), so it is flagged: the table's Andelsbiodling badge turns
  red with a "N not paid" tooltip, and the card shows "2026: Andelsbiodling -
  not paid" in red.

Layout
- The title, "New customer" button and table header stay fixed; only the rows
  scroll, and the table height follows the window.

Tests cover the counting rules (including the Sarah case), the card, the red
badge and the sticky header.
@valyo
valyo merged commit b88e153 into main Nov 3, 2026
3 checks passed
@valyo
valyo deleted the fix-count-andels branch November 3, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant