Metadata-Version: 2.4
Name: ocyan.exactonline
Version: 2.0.1rc1
Summary: Exact Online integration for MandelBlog commerce consumers.
Author: MandelBlog
Classifier: Framework :: Django
Classifier: Framework :: Wagtail
Classifier: Framework :: Ocyan
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: ocyan.core<2,>=1.2.13
Requires-Dist: ocyan.main<3,>=2.0.2
Requires-Dist: ocyan.plugin.wagtail<3,>=2.0.6
Requires-Dist: django-formtools<3,>=2.5
Requires-Dist: ocyan.plugin.oscar_shipping<2,>=1.3.2
Requires-Dist: ocyan.plugin.oscar_odin<3,>=2.0.3
Requires-Dist: ocyan.task<1,>=0.1
Provides-Extra: test
Requires-Dist: ocyan.plugin.testing<3,>=2.0.1; extra == "test"
Requires-Dist: pytest<9,>=8; extra == "test"
Requires-Dist: responses<1,>=0.25; extra == "test"
Requires-Dist: coverage<8,>=7; extra == "test"
Requires-Dist: ruff<1,>=0.8; extra == "test"

# Mandel Exactonline
This package provides for an integration between oscar and exactonline.

You can use this package without using the sync features if you need a completely custom exactonline integration.
For an example see: https://git.mandelblog.com/mandel-projects/godutchlabel

## Features
* Sync stockrecords and prices to oscar.
* Sync orders to exactonline.

## Installation
Add `ocyan.plugin.exactonline` to your projects dependencies. After that configure the exactonline settings in the wagtail admin under **Exactonline > Exact Online Settings**

* **Client Id:**  The Client Id of the api key.
* **Client Secret**: The client secret of the api key.
* **Division**: The division used for all exact requests, this field will be filled in automatically during the login flow.

### Before enabling the plugin
Exactonline is the source of truth on every occasion except for new orders that have not been synced to exactonline yet. This means that some information in oscar can be redundant or outdated since the correct will be pulled from exact.

The following information gets pulled from exact:
* Prices and stockrecords, when sync_stockrecords is enabled.

## Usage
* **Sync order as:** Whether to sync an order to exact as SalesOrder, SalesInvoice or to not sync at all.
* **Stockrecord sync:** Whether to pull stockrecords from exact.

To enable syncing on a product, set the upc of a product in oscar to the same thing as the code of a product in exact and the stockrecords will be pulled from exact for that product.
When an order is placed in oscar, the relation, shipping and billing addresses get sent to exact. Order lines, surcharges, shipping costs and discounts will be sent to exact as order/invoice lines. all products that do not exist in exact will be created automatically. Note that only the Code and Description fields will be filled in on these newly created products.

## Exact Online Sales Order/Invoice Account Structure

When creating orders or invoices in Exact Online, there are three potential Account relationships and two Contact Person relationships that can be linked to each document.

### Account Relationships

In exact you have 3 Accounts Types on a Sales Order / Sales Invoice:
1. **OrderedBy**
2. **DeliverTo**
3. **InvoiceTo**

You then also have 2 contact persons you can link:
1. **DeliverToContactPerson**
2. **InvoiceToContactPerson**

And you can link a delivery address.
1. **DeliveryAddress**

### Default Package Behavior

By default, all the 3 accounts will be the same same accounts.
Accounts will be matched on the email of the user / email entered at checkout.

If no match is found, we create an account with data based on either the shipping or billing address.

Our checkout requires customers to enter the shipping address by default and optionally
you can enter a different billing address.

The account data will be taken from the billing address if entered, otherwise from the shipping address.
