=== TEG-FARM ===
Contributors: theeldestgeek
Tags: farm, agriculture, crops, livestock, csa, virginia, compliance
Requires at least: 5.8
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 0.14.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A whole-farm back office for WordPress, tuned for the Commonwealth of Virginia.

== Description ==

A whole-farm back office for WordPress, tuned for the Commonwealth of Virginia. Fields and plantings, livestock and herds, the inputs store (seed, feed, fertilizer and chemicals counted in lots with EPA registration numbers and expiry), a spray/application log built to what Virginia asks a pesticide applicator to record, harvest and traceability lots, equipment and its maintenance, the work log, and the sales side - farm stand, CSA, wholesale and an online store on your own customer page, where customers order and pay by themselves - with card payments online through your own Square, Stripe or PayPal account, and Square Terminal at the counter.

On top of that a Virginia compliance center and a document room that prints the records a VA farm is actually asked for: application logs, nutrient-management records, FSMA produce-safety logs, livestock health certificates, the agritourism warning sign, CSA agreements, invoices and labels.

Data lives in the site's own wp_tfm_* tables. Licensed like the rest of the family: a 30-day Pro trial is baked in. If a license lapses the farm is paused, not locked: every record stays readable, printable and exportable.

NOT legal advice. The Virginia content is built from public VDACS, DCR, Virginia Cooperative Extension and Virginia Code sources to help a farm keep the right records; a farm still confirms its own obligations and filings.

== Installation ==

1. Upload the teg-farm folder to /wp-content/plugins/ and activate it.
2. Open Farm > Settings and enter the farm name and units.
3. Optional: Farm > Settings > Data & updates > Load the sample farm, to look around. It can be removed again.
4. The customer page is made for you. To show it on another page, put [teg-farm-account] on that page (full list: Help Center > Shortcodes).

== Changelog ==

= 0.14.1 =
* Help: the Help Center now has one Shortcodes section listing every shortcode this plugin adds, with what each does and an example, and a question about it in the FAQ. No other change.

= 0.14.0 =
* Shortcode renamed: the farm customer page is now [teg-farm-account] (was [teg-farm-portal]); the old name is not kept. The page made by the one-click setup uses the new name.
* First-time setup: a short setup page (opened once after the plugin is first activated, and from Settings > Data & updates with Run setup again) for the farm's details, the customer page and, on a farm with no records yet, the rich sample data - Finish removes the sample again unless you keep it. On a farm already in use, administrators see a one-line notice offering the setup until they start it or press No thanks.
* Backups (Settings > Data & updates): back up everything the farm holds to a private folder on this server, download it, upload it again and restore it (a safety backup is taken first, you type RESTORE to confirm, and a backup from a newer version is refused). Scheduled backups, off until you switch them on: every night at the time you set, kept here and, if you choose, copied off-site (SFTP, FTP / FTPS, Amazon S3 / Wasabi / S3-compatible). Passwords and keys are never put in a backup.
* What's new: after an update the notes behind the Dashboard's "What's new" button list every release since the one you last opened, not only the newest.
* Get support: a "Get support" button at the top right of every farm screen (and in the WordPress bar) opens Farm > Support & feature requests - report a problem or request a feature, with the plugin and site details sent along so we can help. Nothing is sent until you press Send.
* Help: a new Help Center under Farm > Help - a full manual of every screen and settings tab with a search box and questions and answers - and a round "?" at the top right of every farm screen that opens the part about that screen. It replaces the short help page.

= 0.13.0 =
* New: an online store. Your customers order from your website, put things in a basket, choose pickup (your places and days) or delivery (your fee and area), leave you a note and pay through the same pay link an e-mailed invoice uses. Available in the Standard and Pro editions.
* The store is off until you turn it on under Settings > Online store. Nothing changes on your customer page until you do.
* Farm > Online store: list your products with a description, unit, price, tax class and a photo. Choose how stock works: not counted, a number you keep, or what is left of your harvest. Sold-out products say so instead of selling what you do not have.
* Visitors can order without signing in. You get an e-mail for each order, and every online order appears under Sales like any other order, with its invoice and in your reports.
* An unpaid online order holds its stock for a limited time, then the stock goes back on sale. Nothing is deleted behind your back.
* New: Farm > Organic, for a farm that is organic, in transition or thinking about it. Set your stage, certifier, certificate number and what you are certified for.
* Fields: the last day a prohibited product went on a field, the first day it can be harvested as organic (36 months later) and how long is left.
* Inputs: mark each one allowed, allowed with limits, not allowed, or not checked yet. A product not yet checked only warns you. If you later mark it not allowed, the field's date moves. Raw manure reminds you of the days before harvest.
* Harvest lots and animals carry their organic marks. Invoices print "Certified organic" only on organic lots of a certified farm. A warning tells you if an animal was given a product that is not allowed.
* Organic records for your inspector print from the Organic page (CSV download with Pro). It is a summary, not legal advice: your certifier decides.
* What's new is now a button on the dashboard, "What's new in 0.13.0". The notes open only when you press it, and the button stands out until you have read them.
* Money: amounts, tax and totals now round the same way on every PHP version. An order you saved earlier keeps its total.
* Help: new sections "Online store" and "Organic". The sample farms show both.

= 0.12.0 =
* New: your farm's customer page. The farm makes a page on your website (its address ends in /teg-farm/) that shows the farm's name, your welcome and what you sell - farm stand, CSA shares, wholesale - to anybody, with nothing private on it.
* Your customers sign in there with the e-mail address you have for them: we e-mail a one-time link, there is no password. The page answers every address the same way, so nobody can use it to find out who your customers are.
* Signed in, a customer sees only their own orders and what is still owed, each invoice to print with a "Pay online" link on an unpaid one, their CSA share and agreement, bills of lading from their orders, and their contact details. They never see your notes.
* Settings > Customer page: switch it on or off, write the welcome, choose what it shows. Farm > Portal sign-in: who is signed in, how long links last, sign everybody out. If a license lapses the page rests kindly; nothing is lost.
* New: Farm > Credits & offsets. It tracks nutrient credits (nitrogen and phosphorus: certified, retired, released and sold pounds kept apart, with a warning if a sale is larger than what is left to sell and the report dates you need), and it lets you track enrolment in private, voluntary forest carbon programs and other carbon contracts - parcels, contract dates, payments, harvests and site visits. Cost-share and tax credit records can be kept there too.
* Credits & offsets prints a credit ledger (one record or the whole farm) and exports to CSV with Pro. A card on the compliance center shows what is due. It is a record-keeping aid, not legal or tax advice.
* New: Farm > Reports. Thirteen everyday reports, each for this month, last month, the season so far, this year or dates you pick, with a plain sentence on top: sales by channel and product (paid and still owed), top customers, CSA shares, money in and what is still owed, harvest, spray intervals, expiring inputs, tasks and compliance. Every report prints; the CSV download is Pro, like every export.
* Along the top of Reports: sales this month against last month, what is still owed, the harvest this season, intervals open now and items due.
* TEG Companion: the Reports tab in the phone app now shows farm cards - sales by channel, still owed, harvest, spray intervals open now, inputs expiring, tasks overdue and compliance due.
* The sample farm now has customers with orders, invoices, CSA agreements and a bill of lading, a nutrient credit project, a forest carbon contract, a tax credit record, and more harvests and sales, so each new screen has something to show. Remove sample data takes them away again. On a demo site a "DEMO: sign in as" button signs a visitor in as a sample customer.
* Help: new sections "Your farm's customer page", "Credits & offsets" and "Reports".

= 0.11.0 =
* The TEG Companion and TEG Rover phone apps can show their screens in another language when your farm has the Pro edition and a language pack. This needs the next update of the apps; until then nothing changes.
* An invoice opened on the phone always shows exactly what your customer gets, in the farm's language.
* Shared parts brought up to date: TEG Companion core 2.18.1, TEG Rover core 1.11.0, language 1.2.0, and the license and update check.
* Help refresh: the Language help now covers the phone apps.

= 0.10.0 =
* New Language screen in Settings. Each staff member can pick their own language on their profile, and the farm has a language of its own for what customers receive.
* Invoices, bills of lading, CSA agreements, e-mails and text messages to customers are always written in the farm's language, no matter who clicked the button.
* Language packs (Spanish first) arrive later and need the Pro edition. Until a pack is installed everything stays in English, exactly as before.
* The compliance checklist is now saved in the farm's language, not in the language of whoever happened to open the screen first.
* Two food-safety notes now say "under" and "over" in words instead of the < and > signs (produce safety exemption and honey cottage-food limit); the amounts are unchanged.
* Shared parts brought up to date: language 1.1.0, payments 1.5.0, app payments 1.3.0.

= 0.9.2 =
* TEG Companion reports can show older months too (this month, last month and up to 10 more; set how many in Companion).
* Shared parts brought up to date: TEG Companion core 2.16.0.

= 0.9.1 =
* Payments: the currency symbol always matches the currency (a US shop never shows £).
* App payments list shows the date your region's way.
* Shared parts brought up to date: payments 1.4.0, app payments 1.2.2.

= 0.9.0 =
* Dates now follow your region: the United States shows 11/09/2026, the United Kingdom 09/11/2026, an EU farm its own country's way - on every screen, print, e-mail and in TEG Companion. Leave the date format blank under Settings > Region, money and tax to use your region's, or type your own; a format you already typed is kept. The WordPress date setting no longer leaks in.
* Spray application times, and input lot expiry dates in the lot picker, are written the same way (2:30 pm in the US, 14:30 in the UK and EU).
* TEG Companion: the app is told your date format, so dates on the phone match the farm's; the Customer notes panel writes dates your region's way too.
* TEG Rover: the dispatch and route screens, the map, the call window and each visit's On the way / Arrived / Finished times follow your region's date and time format too.

= 0.8.3 =
* TEG Companion: an order of several lines now reads as the whole order - "What: Salad mix, Kale (2 items)" - instead of describing only its first line; How much, Price each, Unit and Harvest lot show for a one-line order only, and every line keeps its own quantity and price under Lines.
* The sample farm gives a farm still called by the site's own name a farm name ("Cedar Spring Farm"), so the Companion app and the documents do not show the website's title; Remove sample data puts the old name back. A farm with its own name keeps it.

= 0.8.2 =
* Square Terminal: a payment cancelled from TEG Companion is only shown as cancelled once Square confirms it; unconfirmed cancels are retried automatically and a forgotten checkout is cancelled after 15 minutes.
* TEG Rover and TEG Companion: an update a phone sends late, after being out of signal, is recorded once with the time it really happened, and the job's timeline says "Recorded offline" when it waited.
* Device pairing works when only TEG Companion is switched on (before, it could refuse with "This shop does not hand out that kind of phone key").
* Online card payments: Square payment notices are no longer missed when the address in your Square dashboard was typed with or without www, and a PayPal payment is checked against the right bill before it is taken.

= 0.8.1 =
* Shared modules brought up to date: payments 1.2.0 (pay-by-QR codes under Ways to pay; a bank transfer can be recorded by hand), Companion 2.13.0 (report card dates follow your date format), Rover 1.8.0 (Device pairing masks IP addresses) and the licence check (it now names the Back Office bank feed add-on). TEG Back Office already lists the farm's staff.

= 0.8.0 =
* Payments: the farm takes card payments online through your own Square, Stripe or PayPal account, and on Square Terminal at the counter. Customers pay an order (a farm-stand sale, a wholesale order, a CSA share) from its invoice: the "Pay online" link on the invoice and in the new "E-mail the invoice with its pay link" e-mail. The money goes straight to your account; card details never reach this website.
* Payments: each order has a Payments box - every payment and refund, "Record a payment" for cash, a check, SNAP / EBT (United States), Zelle and the rest, refunds (a card refund goes back through its gateway, never more than was paid) and "Send to Square Terminal". Part payments are fine; an order paid in full becomes Paid, and a refund that leaves it owing puts it back to Fulfilled.
* Settings > Payments: the ways you accept (only the ones your region uses, with the details a customer needs), part payments, Square, PayPal and Stripe, pay-by-QR codes for Zelle / Venmo / Cash App, card terminals. A saved secret is never shown again; webhooks are signed and a replayed one never books a payment twice.
* The invoice shows what was paid, what is owed and the ways to pay. The "Pay online" line is on screen only, never on paper.
* Payments CSV on the Orders list (this month's payments and refunds) - an export of your own money, never licence-gated.
* TEG Companion: Take payment on an order - Square Terminal at the counter, a Square pay link the customer opens from a QR code, or cash / check / SNAP / EBT; Zelle, Venmo and PayPal taken on the phone wait for the office to confirm them. A payment taken on the phone may be part of what is owed and goes into the same payments list; the invoice on the phone lists its payments; the day close adds up the day's payments.
* TEG Rover: money confirmed after a delivery goes into the order's payments (a part payment leaves the rest owing).
* Orders marked Paid before 0.8.0 are written into the payments list once when you update (the way and the day from the phone's or TEG Rover's note, otherwise "Other"). An order with payments can no longer be deleted: refund it and set it to Canceled.
* The demo site never takes money.
* TEG Back Office: it now sees the farm's payments and refunds (the payments list), not just its orders; and its page sits under the Farm menu as "Back Office" instead of a menu of its own.

= 0.7.9 =
* Spray log: "REI until" and "PHI until" are always worked out from the date and time you wrote down, whatever the site's or the server's time zone. A stored re-entry time that could not be right (before the spray, or not a whole number of hours after it) is corrected the next time the farm screens open. Records you saved are never changed.
* Spray log: an application drawn from a lot that had already expired is flagged - a warning when you save it, an "expired lot" tag in the list and a note on its form.
* Inputs: a Veterinary category; "1 lot expired" reads right; an unknown category shows capitalized.
* Livestock: a treatment's lot list offers veterinary products (and Other) only, not pesticides or fertilizer.
* TEG Companion: "Open orders" lists Open orders only; a Fulfilled order is under its own stage.
* Sample data: the sample spray is at a sensible hour and from a good lot; ivermectin withdrawals all 48 days; one phone format; a CSA share is not tax exempt and says how long it runs; last year's sales so "This year vs last year" has something to compare.

= 0.7.8 =
* Harvests: the pre-harvest interval warning now only counts sprays made on or before the harvest. A harvest picked before a field was sprayed is no longer flagged.
* Orders: the unit box is wide enough for "bunch", and the harvest-lot box suggests your recent lots.
* Livestock: a flock or group kept as one record has a Head count, and the herd adds it up (140 hens on one record count as 140). A sex stored as a letter ("F") shows as the word.
* Spray log: the wind-speed and air-temperature boxes are wider.
* Compliance center: US spelling ("center"), and every group heading is capitalized.
* Sample data reads like a real farm: no "(sample)" after names and no "Sample Worker". Its order lines carry harvest lots, and every machine has its own hours and costs. Remove sample data still deletes all of it.
* TEG Companion: the order list shows the date once, and a sale with no customer says "Walk-up".

= 0.7.7 =
* Licence check knows the new TEG Total Auction Management (TAM) product.

= 0.7.6 =
* Back Office shows as Back Office in Setup; the pairing page is called Device pairing everywhere.
* TEG Companion: the home screen no longer offers a "New customer" button the app could not show.

= 0.7.5 =
* Fresh installs now get the 30-day Pro trial the readme promised. Earlier zips shipped an empty trial file, so a new site was paused until a licence was entered.

= 0.7.4 =
* The licence check and the updater now share one tested core: a slow licence server can no longer slow the shop down.

= 0.7.3 =
* Money in another currency is always written with its own symbol.
* Product names in the licence screen use the new spelling (TEG-DELI, TEG-FOODTRUCK, TEG-BUTCHER, TEG-BAKERY).

= 0.7.2 =
* Money in another currency is written with its own symbol on the TEG Rover cards.

= 0.7.1 =
* TEG Rover collects on an invoice in the currency it was issued in, and its cards count one currency at a time.
* The "Not counted above, in another currency" line writes each currency its own way (for example 1.190,00 €).

= 0.7.0 =
* Region setting: one tick switches the shop between the United States, the United Kingdom and the European Union - currency, dates, tax, address wording, spelling and the ways customers can pay. Invoices already issued never change. The sample data now reads as a US business.
* The new Settings tab "Region, money and tax" also holds the currency, the date format, the tax label and two tax rates: one on food and one on other goods. Each order line is Food or Other goods. In the United States both rates start at 0, so nothing is charged until you set your state's rates; in the UK food is zero-rated; in the EU food starts at the country's reduced rate.
* An order keeps the currency, dates and tax rates it was taken with, on the screen, on the invoice, in the document room and in the CSV export, even after the region changes. Orders from before this version print exactly as they did.
* The ways a customer can pay in the Companion app follow the region (Zelle and Venmo only in the US, no check in the EU; SNAP / EBT in the US), and a payment already taken still shows how it was paid.
* CSV exports are safe to open in a spreadsheet: a cell that starts like a formula is shown as text.
* American spelling throughout (license, center, canceled, fertilizer); a farm in the UK or the EU sees British spelling.
* Totals and reports now count one currency at a time: after a region switch, money in the old currency is listed apart instead of being added in. The TEG Companion app shows every invoice in the currency it was issued in.

= 0.6.0 =
* Fixed: opening an order or New order on the Sales screen no longer fails. Before, it ran out of memory and showed an error instead of the order form.
* Every customer now has one Customer notes box, on the desktop and in the Companion app: the general notes first, then the notes from their orders, with who wrote each one and which came from a member of Staff.
* On the computer the box is on the customer's own screen (Sales > Customers > the customer), with "Add a note". Each note from an order says "From Order #12" and links to the order; the order screen links back to all of the customer's notes.
* A note written on a customer in the Companion app is now kept as its own note in that box, instead of being added to the end of the customer's Notes field. Notes already in the field stay where they are.
* The printed invoice no longer shows the order's notes. Those notes are for the farm only (they include notes from the phone and "Paid ... (TEG Companion)" lines), so a customer never sees them on paper.

= 0.5.1 =
* Report cards on your phone now open the matching screen on the computer: the sales cards open the Sales list, cancelled orders open the Sales list showing only cancelled orders, and the customer cards (customers who came back, regulars to call, where new customers came from) open the Customers list.
* Card names that fit a farm: "Refunds and voids" is now "Cancelled orders", "Busiest times" is now "Busiest days" (the farm records the day of a sale, not the hour), and "Where new customers come from" no longer mentions money spent.
* Clearer date ranges on the cards: "October 1" instead of "October 1-1", and "Jan 5-10, 2031" instead of "Jan 5, 2031 to Jan 10, 2031".

= 0.5.0 =
* Report cards on your phone: in the TEG Companion app each person picks the cards they want to see, laid out in sections (money, customers, everyday). Tap a card to see the orders behind the number.
* A new Reports cards page on the computer (Farm > Reports cards): the same cards side by side, compared with last period, the same time last year or dates you choose. Set goals and see how close you are, save the figures as a CSV file or print them.
* The farm's own cards, all counted the same way as the total on the Sales list (every order except cancelled ones, by its order date): sales this month against last month, the average order, this year against last year, your busiest days of the week, customers who came back, cancelled orders, regulars who have not been back, and where new customers came from (farm stand, CSA, farmers market or wholesale). Sales tax shows as zero because farm orders carry no tax.
* Lost customers: choose after how many days a regular counts as lost (Settings > Farm > "Lost customers after N days", 90 days unless you change it). The card and the list follow your choice.
* An optional monthly summary e-mail of the cards you pick. It stays off until you choose who gets it and save.
* Turning the plugin off now also stops its scheduled e-mails, and removing the plugin also removes the report settings and goals. Help has a new Reports cards section.

= 0.4.0 =
* Import your lists from a spreadsheet: Settings > Data has a new CSV importer for customers, fields, livestock and equipment. Upload the file, tell it which column is which, and run a test first - it shows what would be added without changing anything. When you are happy, import it, and if you change your mind you can undo the whole import.
* Errands for your phone crew: on Farm > Phones you can hand out errands (pick up feed, run to the supply store) to a worker's phone, with a place on the map. The worker can record what they spent, and the office sees it on the payments screen. Rover is still off until you switch it on, and workers only see their own errands.
* Sample data is richer and easier to manage: Settings > Data can add a fuller sample farm and take it out again, without touching anything you entered yourself.
* Smoother setup for new sites and a few small fixes.

= 0.3.0 =
* New: E-mail test mode (Settings > E-mail test mode). Turn it on before going live and every e-mail the site sends - invoices, receipts, reminders, status notes, staff alerts - goes to one address you choose and to nobody else. The subject starts with [TEST to ...] so you can see who it was meant for; the message is exactly what the customer would get. Administrators can switch it from the TEG Companion app too (Settings > E-mail test mode), and a red notice shows on every admin page while it is on. Text messages are not e-mail and still go out.
* TEG Companion and TEG Rover (owner 2026-10-28: Companion and Rover in every shop). Companion: the farm on a phone - customers, orders (farm stand, CSA, wholesale) with their harvest lots, Fulfilled, notes, photos and signatures, the invoice, and the payment of an order (paid in full, nothing e-mailed); pair under Farm > Phones (QR or 9-digit code); the store's home-screen defaults there too. Rover: deliveries of orders to a farm hand's phone (customer, address, the lines; delivering marks the order Fulfilled; money at the door waits for the office), switched OFF by default - the setting **Rover (drivers / field staff)** on Farm > Phones. Help: a Companion app section. DB 3: the new tables are made on update (maybe_upgrade now runs on load). Shared Companion core 2.4.0 and Rover core 1.5.0 (generated).

= 0.2.0 =
* Farm reminders: once a day ONE e-mail to the farm office with what is due (Settings > Farm: on/off, who gets it, how many days ahead), replacing the vet-clinic mail module.
* Sample data only on an empty or demo site, with a Remove sample data button.
* The update details and the What's new card name the plugin TEG-FARM.
* Updates: an update whose manifest publishes no SHA-256 checksum is never offered or installed. DB 2.

= 0.1.0 =
* First release: fields, crops, livestock, inputs, applications, harvests, equipment, tasks, sales, Virginia compliance center and document room.
* Dashboard: tasks due, applications inside their REI, expiring input lots, compliance items due.
* Sample Virginia farm, removable.
