icedcoffee-sync
icedcoffee-sync has three layers: a typed Frappe/ERPNext REST client, idempotent document provisioning, and reconciliation of a declared set against a site. This is version 0.1.0; today the diff/apply/prune engine handles charts of accounts only. The intention is to extend that process to other document types.
Installation
Requires Python 3.14. To include pre-releases:
pip install --pre icedcoffee-sync
# or
uv add --prerelease allow icedcoffee-sync
Client
icedcoffee_sync.frappe.client provides typed sync and async clients.
SiteConfig.may_submit defaults to false, guarding against accidental submits,
cancellations, known committing methods, and document writes that set docstatus.
The API key's server-side permissions enforce access.
Replace the site URL, API credentials, and document names in these examples. Both clients return document dictionaries from reads and close connections on exit.
from icedcoffee_sync.frappe.client import Client, SiteConfig
config = SiteConfig(
url="https://erp.example.com",
api_key="your-api-key",
api_secret="your-api-secret",
)
with Client(config) as client:
company = client.get("Company", "Example Company")
print(company["name"])
The async equivalent:
import asyncio
from icedcoffee_sync.frappe.client import AsyncClient, SiteConfig
config = SiteConfig(
url="https://erp.example.com",
api_key="your-api-key",
api_secret="your-api-secret",
)
async def main():
async with AsyncClient(config) as client:
company = await client.get("Company", "Example Company")
print(company["name"])
asyncio.run(main())
icedcoffee_sync.frappe.access: provision roles, permission grants, users and API keys, and probe that a key cannot submit.icedcoffee_sync.site.require_safe_site_url: call before sending credentials. It refuses a URL that carries a credential, has no hostname, is not HTTPS on port 443, has a path, query or fragment past the site root, or names a host the caller refused. The clients do not call it for you.
Document provisioning
icedcoffee_sync.erpnext.ensure.ensure_by_name gets a document by name and
inserts it only if missing, never rewriting one a person changed. It returns
true for an insert and false for an existing document. Supply a dict whose
inserted document will have the name you check. This get-or-insert pattern is
the provisioning layer for Supplier, Item, Purchase Order, Custom Field and
Webhook documents today.
from icedcoffee_sync.erpnext.ensure import ensure_by_name
from icedcoffee_sync.frappe.client import Client, SiteConfig
config = SiteConfig(
url="https://erp.example.com",
api_key="your-api-key",
api_secret="your-api-secret",
)
with Client(config) as client:
created = ensure_by_name(
client,
"Item",
"EXAMPLE-ITEM",
{
"item_code": "EXAMPLE-ITEM",
"item_name": "Example Item",
"item_group": "All Item Groups",
"stock_uom": "Nos",
},
)
print(created)
icedcoffee_sync.erpnext.documents: Supplier, Item and Purchase Order documents, and the Custom Fields that mark them as yours.icedcoffee_sync.erpnext.webhook: provision Purchase Order Webhooks pointed at your receiver.icedcoffee_sync.erpnext.purchase: typed Purchase Order reads and draft Purchase Receipt documents.icedcoffee_sync.erpnext.company: validate, set and clear Company default-account links.icedcoffee_sync.erpnext.comment: add and list comments on documents.
Your namespace
The documents, Webhooks and Purchase Order reads take a Namespace: the names
your integration leaves on a site. name prefixes the Custom Fields
(<name>_source, <name>_ref, <name>_order_no) and the Webhook names, and
is the marker stamped on every document you write. label prefixes the field
labels a person sees on the form. site_header carries your site id on each
Webhook delivery, so one receiving URL can tell sites apart.
from icedcoffee_sync.erpnext.documents import DesiredSupplier, custom_fields
from icedcoffee_sync.erpnext.namespace import Namespace
ns = Namespace(name="acme", label="Acme", site_header="X-Acme-Site")
fields = custom_fields(ns) # ensure these before writing documents
supplier = DesiredSupplier(vendor_id="v-123", supplier_name="Example Supplier")
print(supplier.as_document(namespace=ns))
# {'supplier_name': 'Example Supplier', 'disabled': 0, 'acme_source': 'acme', 'acme_ref': 'v-123'}
Pick the namespace once per site. Documents written under one name are invisible to readers under another, and the old fields and Webhooks stay on the site.
Reconciliation
icedcoffee_sync.apply reconciles charts through the synchronous client.
Declare account numbers and parent numbers; roots must already exist and are
matched by root type. This example declares an expense root and one child.
Before pruning, declare every account you want to keep in the company.
Warning: apply_chart and execute_prune write to the site. Review each
printed plan before continuing; the example pauses before each write step.
from icedcoffee_sync.apply.diff import diff
from icedcoffee_sync.apply.execute import apply_chart
from icedcoffee_sync.apply.model import DesiredAccount
from icedcoffee_sync.apply.prune import execute_prune, plan_prune
from icedcoffee_sync.erpnext.accounts import accounts_with_entries, company_abbr, read_chart
from icedcoffee_sync.frappe.client import Client, SiteConfig
config = SiteConfig(
url="https://erp.example.com",
api_key="your-api-key",
api_secret="your-api-secret",
)
company = "Example Company"
desired = [
DesiredAccount("5000", "Expenses", None, True, "Expense"),
DesiredAccount("5202", "Bank Charges", "5000", False, "Expense"),
]
with Client(config) as client:
live = read_chart(client, company)
entries = accounts_with_entries(client, [a.document_name for a in live])
plan = diff(desired, live, entries)
print(plan)
input("Review the diff; Enter to apply, Ctrl-C to stop: ")
print(apply_chart(client, plan, live, {a.number: a for a in desired}, company_abbr(client, company), company))
live = read_chart(client, company)
entries = accounts_with_entries(client, [a.document_name for a in live])
plan = diff(desired, live, entries)
pruning = plan_prune([extra.live for extra in plan.extras], live, entries)
print(pruning)
input("Review the prune plan; Enter to execute, Ctrl-C to stop: ")
print(execute_prune(client, pruning))
diff reports creates, renames, type changes, re-enables, extras and refusals
without writes. apply_chart runs changes in dependency order; any refusal
blocks the entire apply, and extras are left alone. plan_prune protects roots,
accounts with ledger entries and parents with surviving children.
execute_prune deletes selected extras, falling back to disabling them for
certain ERPNext business-rule errors.
Development
Requires Python 3.14 and uv.
just install # create the virtualenv
just check # lock, lint, typecheck, deptry
just test # pytest, excluding tests that need a live site
just lint-fix # apply ruff fixes
Tests marked live_frappe hit a real Frappe site and need the
ICEDCOFFEE_TEST_* environment variables; just test skips them.
Metadata
Release files for icedcoffee-sync 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| icedcoffee_sync-0.1.0.tar.gz | 114.7 kB | With provenance | Details for icedcoffee_sync-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| icedcoffee_sync-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for icedcoffee_sync-0.1.0-py3-none-any.whl |
Total release size: 175.7 kB
Release files / icedcoffee_sync-0.1.0.tar.gz
| Download URL | icedcoffee_sync-0.1.0.tar.gz |
|---|---|
| Size | 114.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
657bbdc765f2c694e22fea872fa0daad99d915770f167fcafaf243220b444797
|
|
BLAKE2b-256 checksum How to use checksums |
11187e70af822121748c45236ee578affabb92eaac1374e6fd538b1ea70f8d96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / icedcoffee_sync-0.1.0-py3-none-any.whl
| Download URL | icedcoffee_sync-0.1.0-py3-none-any.whl |
|---|---|
| Size | 61.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59e24e736cb369fa52ae46b50def768bb8d7dcee0dd8361203570b1f712760cc
|
|
BLAKE2b-256 checksum How to use checksums |
26f72bd096f587e19e93e7f5a8f1b3e23ab848322fd4b8a10127b0642f60949f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for icedcoffee-sync 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for icedcoffee_sync-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.