=== CatCode Sales to freee for WooCommerce ===
Contributors: catcodestudio
Tags: freee, accounting, japan, consumption tax, woocommerce
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Records every WooCommerce sale in freee accounting as a deal, split by consumption tax rate, without duplicates and without CSV files.

== Description ==

You sell with WooCommerce and keep your books in freee. This plugin records each sale in freee by itself, so nobody exports files or types orders in by hand.

WooCommerce の売上を freee 会計へ取引として自動で登録します。10% と 8%（軽減）の税率ごとに明細を分け、同じ注文を二重に登録しません。

freee is a third-party product. This is an independent integration, not affiliated with or endorsed by freee K.K.

= What it does =

* **Sale to deal.** When an order reaches the statuses you choose, it goes to freee as an income deal through the freee API, not through a CSV file.
* **Split by tax rate.** Lines at 10% and at 8% (reduced) become separate lines of the deal, with the tax categories you choose from your own freee company. Lines without tax have their own category.
* **Exact totals.** Products, shipping and fees are recorded after discounts, in whole yen, and the deal adds up to the order total to the yen.
* **Stores without tax lines.** If WooCommerce taxes are off, you say what your prices include and which tax class means 8%, and freee works the tax amount out itself.
* **No duplicates.** One deal per order, with the order number in the reference number. If an answer from freee is lost, the plugin looks for the deal before trying again.
* **No customer data.** Deals carry the order number and amounts, not names or addresses.

= Built not to lose a sale =

* Sales wait in a queue and run one at a time, in the background, so that checkout never waits for freee.
* If freee does not answer, the sale is tried again later. If freee asks to wait, the plugin waits and keeps every sale.
* The Activity tab shows what is waiting, what failed and why, with a Retry button.
* The connection renews itself in the background, as freee requires, even when there are no orders.
* A staging copy stays quiet. If the site's address changes, sending stops until you confirm that this is the real store, otherwise test orders would land in your books.

= What it does not do =

* Deals are recorded as unsettled. You match them to the money in freee.
* It does not change a deal after it is recorded. A refund or a cancellation leaves a note on the order so that you can record it in freee.
* It takes orders in yen only, because freee does.
* It does not send anything back from freee to the store.

// @pro-begin
= Pro =

Sold on [catcode.com.ua](https://catcode.com.ua/modules/freee-woocommerce/) with a 7-day trial:

* **Settled deals.** Each payment method is paid into the freee account you choose, so a paid order goes in settled. A cash on delivery order is settled when it is paid.
* **Refunds and cancellations.** Recorded by themselves on the day they happen, at the right tax rate, as freee's help describes. The original deal stays as it is.
* **Your accounts.** Separate accounts for shipping and fees, and an account and department for each product category.
* **Partner and memo tag** on every deal.
* **Send past orders** in bulk from the orders list.
* **E-mail alerts** when freee stops accepting the connection or a sale gives up.

// @pro-end
== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. Open **WooCommerce > freee** and copy the callback URL from the Connection tab.
3. In the freee app store for developers, create a private app in your real company and enter the callback URL. An app made in a test company does not work with real books.
4. Paste the Client ID and Client Secret, press Connect and choose your company in freee.
5. On the **Accounting** tab check the sales account and the tax categories, and save.
6. Place a test order and check the deal in freee before relying on it.

== Frequently Asked Questions ==

= Does this need a CatCode account? =

No. The plugin talks to freee directly, through an app you own in your freee company.

= Why do I create my own freee app? =

A private app belongs to your company and needs no outside server: the tokens stay on your site, encrypted with your site's keys.

= Will old orders be sent when I connect? =

No. Only orders placed after connecting are sent automatically. An older one can be sent from its own screen.

= A sale was not sent. What now? =

The Activity tab and a note on the order give the reason. Fix it and press Retry.

= Which date does the deal get? =

The day the order was paid, or the day it was placed if it is not paid yet, in your site's time zone.

= How many API calls does it use? =

One call per sale, plus a call about every five and a half hours to renew the connection. freee allows 3,000 to 10,000 calls a day for one company and one app, depending on the plan. The Activity tab shows the calls made today.

= freee says the connection has ended. Why? =

freee wants its tokens renewed before they end, and the plugin does that in the background through WP-Cron. On a site with no visitors for many hours, WP-Cron may not run, and then you connect again on the Connection tab. No sale is lost: they wait. A real server cron avoids this.

== External services ==

This plugin connects to freee accounting, a service run by freee K.K., because recording your sales there is its purpose.

It sends, from your server to accounts.secure.freee.co.jp and api.freee.co.jp:

* when you connect and every few hours after that: the Client ID and Client Secret of your freee app and the tokens freee issued, to keep the connection alive;
* when you connect or press the test button: a request for the accounts, tax categories and company name of your freee company;
* when an order reaches a chosen status, or you press Send: the order number, date, amounts, the tax category and account of each line.

No customer names, addresses or e-mail addresses are sent. Nothing is sent before you connect. freee: [terms of service](https://www.freee.co.jp/terms/), [privacy policy](https://corp.freee.co.jp/privacy/).

== Changelog ==

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.0.0 =
First release.
