=== ProstaFaktura dla KSeF ===
Contributors: krklukasz
Tags: ksef, faktura, e-faktura, invoice, vat
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 1.0.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Invoices for companies and individuals - issue and send to Poland's KSeF (FA(3)): KSeF number, UPO and PDF. Independent plugin.

== Description ==

> **Independent plugin.** It is not affiliated with, endorsed by, or an official product of the Polish Ministry of Finance. "KSeF" (Krajowy System e-Faktur, the National e-Invoicing System) is the name of the government system the plugin integrates with, only through its public API.

This plugin lets Polish businesses create **invoices for KSeF** (the Polish National e-Invoicing System run by the Ministry of Finance) directly from WordPress and WooCommerce, following the official **FA(3)** schema. The invoice is built in your dashboard, sent to KSeF, gets a **KSeF number** and **UPO** (official acceptance confirmation), and you download a ready **PDF**.

The plugin talks **directly to the official KSeF API** - no expensive accounting software or middleman required. Ideal for WooCommerce stores and business sites that must comply with the KSeF obligation.

**What the free version does:**

* Connect a KSeF account with a token - step-by-step wizard and a connection test.
* Issue invoices to KSeF manually (full FA(3) form).
* Issue an invoice from a WooCommerce order in one click.
* Reliable sending: acceptance confirmation from KSeF, assigned KSeF number, rejection detection with a readable reason.
* Download the **UPO** (official acceptance confirmation) and the invoice **PDF**.
* Basic invoice numbering and a list of issued sales invoices.
* **Tax ID (NIP)** field on the WooCommerce order (B2B invoices).

**Pro version (optional, a separate product):** fetching **cost invoices** from KSeF, **corrections** (KOR/KOR_ZAL/KOR_ROZ), sales/cost/profit reports, CSV and PDF export, **automatic issuing** from WooCommerce orders, contractor data from the **GUS** business registry by tax ID, and multiple KSeF accounts. The free version works on its own and needs no account or licence - Pro is a separate plugin available at https://prostafakturaksef.pl.

= External services =

This plugin relies on external services. For each service below you will find what it is, what data is sent and exactly when, plus links to that service's terms of use and privacy information.

**1. KSeF - National e-Invoicing System (Krajowy System e-Faktur), run by the Polish Ministry of Finance.**
This is the government e-invoicing system the plugin exists to integrate with. To meet the statutory KSeF obligation, the plugin sends your invoices to KSeF over its official public API.

* Production: https://ksef.mf.gov.pl (API: https://api.ksef.mf.gov.pl)
* Test sandbox: https://ksef-test.mf.gov.pl (API: https://api-test.ksef.mf.gov.pl)

What is sent and when: invoice data (seller, buyer, line items, amounts, dates) and the KSeF authentication token you entered in the plugin settings. It is sent only when you issue an invoice or query its status / fetch invoices - always on your explicit action, never automatically in the background without your configuration.
Service information and rules: https://www.podatki.gov.pl/ksef/
Terms of use and privacy (Ministry of Finance / gov.pl): https://www.podatki.gov.pl/ksef/ (see the system's rules - "Regulamin" - and the data-protection clause published there).

**2. NBP - exchange-rate API of the National Bank of Poland (Narodowy Bank Polski).**
Used only to read the official exchange rate when an invoice is issued in a currency other than PLN.

* API: https://api.nbp.pl

What is sent and when: only a currency code and a date - no personal data and no invoice content - and only at the moment you issue a foreign-currency invoice.
Terms of use: https://api.nbp.pl/ (see the "Terms" / "Zasady korzystania" notice on the API page).

The free version does not connect to any of our own servers (for example prostafakturaksef.pl) and requires no account or licence.

== Installation ==

1. Install and activate the plugin. WooCommerce is optional - when active, it adds issuing from orders and a tax ID field on the order.
2. Open the **KSeF** menu and the **Wizard** - paste your KSeF token, choose the environment and test the connection.
3. Issue your first invoice from the form or (with WooCommerce active) from an order.

You generate the KSeF token in the official KSeF taxpayer application (with the permission to issue and view invoices).

== Frequently Asked Questions ==

= Is the plugin compliant with the FA(3) schema? =
Yes. Invoices are built according to the FA(3) schema and validated before being sent to KSeF.

= Does it work with WooCommerce? =
Yes. With WooCommerce active you can issue an invoice from an order in one click, and the plugin adds a tax ID (NIP) field on the order (B2B invoices). It also works on plain WordPress (manual issuing).

= Can I test without issuing a real invoice? =
Yes. Choose the test environment (the Ministry's sandbox) - you can send a test invoice with no legal effect.

= What is the UPO and where do I find it? =
The UPO is the official acceptance confirmation - proof that the invoice reached KSeF. After the invoice is accepted you download it with the "Download UPO" button in the invoice preview.

= Do I need an account or a licence? =
No. The free version works fully on its own - no registration, and it does not connect to our servers. It connects only to the Ministry of Finance KSeF (see "External services").

= When does KSeF become mandatory? =
For most taxpayers the obligation to issue invoices in KSeF applies from 1 February 2026. Confirm the exact date for your business with your accountant.

= Do I need expensive accounting software? =
No. The plugin connects directly to the KSeF API, so you do not need an extra accounting system just to issue invoices.

== Screenshots ==

1. Issuing an invoice to KSeF - basic data, dates and payment (FA(3) form).
2. Invoice line items - VAT rates, discounts and automatic totals.
3. FA(3) markers and VAT procedures (margin, OSS, reverse charge, cash method).
4. WooCommerce - issuing a KSeF invoice from the order screen.
5. Sales invoice list - KSeF statuses, payments and UPO download.
6. Contractor database - company and person data, deduplication by tax ID, ready for invoices.
7. Settings - FA(3) numbering and the invoice policy for private customers (B2C).
8. KSeF settings - the automatic send-to-KSeF policy.

== Changelog ==

= 1.0.4 =
* Maintenance: removed unused code paths that belonged only to the optional Pro plugin (background fetching of cost invoices and sales sync from KSeF). These were never reachable in the free version - the package is now leaner and contains free features only.

= 1.0.3 =
* Added a "Pro version" page describing the optional paid plugin (cost invoices, corrections, reports, WooCommerce automation, GUS lookup) with a link - informational only, no locked functionality.

= 1.0.2 =
* Robustness and directory-guideline compliance: upload folder resolved solely via wp_upload_dir() (multisite / custom upload paths).

= 1.0.1 =
* All core features available with no usage limits: automatic invoice e-mail, multiple numbering schemes, multiple KSeF accounts, scheduled background sync and the Permissions tab.
* Security hardening: stricter file upload validation and admin page scripts/styles moved to the standard enqueue mechanism.
* Cleanup and directory-guideline compliance.

= 1.0.0 =
* First release: issuing invoices to KSeF (manually and from a WooCommerce order), reliable sending with acceptance confirmation, KSeF number, UPO and PDF download, start wizard, tax ID field on the order.

== Upgrade Notice ==

= 1.0.2 =
Compliance and robustness fixes.

= 1.0.1 =
Core features unlocked, security hardening and compliance cleanup.

= 1.0.0 =
First release.
