Repository navigation
Season 2023 and lamm sales - #37
Merged
Merged
Conversation
…n the customers page Lammandel sales - A paid lammandel invoice can be turned into a sale by hand, with a "Create sale" button on each row of the Lammandel invoices table (enabled for paid invoices; a "Sale created" badge replaces it afterwards). Paying an invoice does not create a sale by itself. - The sale is product "lammkött", category "lammandel", dated at the payment date, with the invoice's quantity and total per share as unit price. Jar size, consistency and apiary are left empty. - The sale follows the invoice: changing the payment date moves it, clearing the payment or deleting the invoice removes it. A second sale for the same invoice is refused (409), an unpaid invoice is refused (400). Schema (migration d2e3f4a5b6c7) - sales.lamm_invoice_id links a sale to its lammandel invoice. - sales.consistency and sales.apiary become nullable (honey-only fields). - Seeds the "lammandel" sale category and the "lammkött" product. Deploy the migration together with this code. Customers page - Lammandel sales count under Lammandel in the Bookings column (not under Sales). A booking is not counted again when a sale already covers it: the sale was made from its invoice, or the customer has a lammandel sale for that season's year. Same rule for the "Shares by season" card. - The Sales list shows the invoice check mark for lammandel invoices too. Bookings table - The Lammandel bookings table no longer has the "Welcome sent" column; Andelsbiodling keeps "Cert. sent". Tests cover creating the sale, refusals, login and origin guards, following the invoice, the buttons and columns, and the customer counts and card.
- Picking the product "lammkött" in the New sale and Edit sale forms swaps the honey fields (skörd, jar size, consistency, quantity, apiary) for Weight (kg) and Price per kg (kr), with the total shown. The honey fields are hidden and disabled, so they are neither validated nor sent. Date, category and customer work as for honey sales, including picking an existing customer or typing a new name. - Stored as one sale: quantity 1, the weight in burk_kg and kg x price per kg as the unit price, so unit price x quantity stays the revenue. Skörd is the year of the sale date; consistency and apiary stay empty (NULL). - Validated server-side by product, not only in the form: weight must be more than 0, price per kg is required (0 is allowed), date and category are required. Honey sales keep their existing validation. - Editing prefills weight and price per kg (unit price / weight) and recomputes the total; a sale can be switched between honey and lammkött. - Sales made from a lammandel invoice (lamm_invoice_id) are treated like andel invoice sales: no Edit button, and the edit endpoint refuses them. New Sale.from_invoice covers both kinds. No migration: the lammkött product and the nullable consistency/apiary columns come from d2e3f4a5b6c7. Tests cover creating, validation, the new-customer path, editing and switching product, the invoice-sale guard and the form markup. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- New product "lammskinn" (migration e3f4a5b6c7d8). Picking it in the New sale and Edit sale forms asks only for date, quantity, price, category and customer; skörd, jar size, consistency and apiary are hidden and disabled, so they are neither validated nor sent. Customer works as for honey sales. - Stored as one sale with the entered quantity and unit price (revenue is quantity x price, like honey). Skörd is the year of the sale date; jar size, consistency and apiary stay empty (NULL). - Server-side validation by product: quantity at least 1, price required (0 is allowed), date and category required. - What a form asks for now follows the product's kind (honey, meat or skin): options carry data-kind and fields data-kinds in sales.html, and _product_kind / _sale_values in sales.py pick the validation. This replaces the lammkött-only switch (data-lamb / _is_lamb), with no change in how lammkött behaves. Deploy the migration together with this code. Tests cover creating, validation, the new-customer path and editing a lammskinn sale, plus the form markup for all three kinds. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Bump VERSION to 1.7.0. - Ignore service-account.json, certificates/, temp/, core, the one-off data clean-up scripts and exports so they are not committed by accident. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.