=== BPro Data Light ===
Contributors: ayachmenev
Tags: woocommerce, analytics, reporting, stock, profitability
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.txt

Adds a BPro profitability and stock report to WooCommerce Analytics, with no database table of its own.

== Description ==

BPro Data Light shows BPro Data (λ0, βI, βO, βL, kI, kR, kL and the BPro amounts XIP ... P) as a "BPro" report in WooCommerce > Analytics, built like the Products report: summary tabs above the chart, one column per value in the table, a "Show" filter, a date range.

Compared with the full WC BPro Data plugin it is "light" in three ways:

1. **One settings page** (WooCommerce > BPro Light) with "Show BPro Data at the WooCommerce Analytics" and the Danger Zone "Reset All". No Import, Structure or Segment pages, metaboxes, Dashboard alerts or admin-bar light.
2. **No wp_wc_bpro_data table.** The BPro values are calculated from the WooCommerce data and cached in transients.
3. **It follows the WooCommerce Analytics data update.** Whenever WooCommerce syncs an order into its Analytics data (`woocommerce_analytics_update_order_stats`, `woocommerce_order_scheduler_after_import_order`), or an order is trashed / deleted, the order is queued and the BPro data is updated about a minute later in one batch. A regular update (every 15 minutes) catches anything else. The "Data status" box at the top right of Analytics > BPro shows when the data was last updated and when the next update runs; its button updates it right now.

= What is stored =

* Transients `bpro_data_light_p_{id}` and `bpro_data_light_index`: the calculated per-product data. They can be rebuilt from WooCommerce at any time; if they are lost the plugin rebuilds them automatically (first run: all orders, in time-boxed batches).
* Option `bpro_data_light_state`: the update queue and the last update time.
* Option `bpro_data_light_restocks`: stock-ins (XLP / XLM). WooCommerce keeps only the current stock quantity, never a history of stock-ins, so these cannot be recalculated; they are recorded when the stock goes up, plus the "starting stock" taken when the plugin is activated.

The calculation of an order's values (XIP, XIM, YIP, YIM, TXP, TXM, YLP, YLM, DP) and of the balances and ratios is the same as in the full plugin, so both give the same numbers for the same orders.

= Notes =

* Do not run it together with the full WC BPro Data plugin (both add a "BPro" report to Analytics): Light pauses itself and shows a notice if the full plugin is active.
* Product cost comes from WooCommerce's Cost of Goods Sold (the cost locked into each order item); stock-ins use the product's current cost.
* The gauge limits are the defaults: the daily bank rate (derived from a 10% annual rate) for βI, βO, βL and 1 for kI, kR, kL. Filters: `bpro_data_light_npv_discount_rate`, `bpro_data_light_daily_bank_rate`, `bpro_data_light_gauge_limit`, `bpro_data_light_sync_interval`, `bpro_data_light_sync_delay`.

== Installation ==

1. Upload the plugin and activate it (WooCommerce must be active).
2. Open WooCommerce > BPro Light, tick "Show BPro Data at the WooCommerce Analytics" and save.
3. Open WooCommerce > Analytics > BPro. The first calculation runs in the background; "Data status" shows its progress.

== Frequently Asked Questions ==

= Does it work without WooCommerce? =

No. WooCommerce must be installed and active.

= Does it send data anywhere? =

No. The plugin makes no external requests; all data stays in your WordPress database.

= What happens to my data when I delete the plugin? =

Everything the plugin stored (options, transients, recorded stock-ins) is removed on deletion.

== Changelog ==

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.0.0 =
First release.
