The write-capable companion to the read-only dolibarr* skills, scoped to the erp-sandbox. Lets an AI agent rehearse bookkeeping writes against a copy of prod (ADR-0003) before a human promotes the reviewed change to prod. - scripts/dol-write.sh: write wrapper that REFUSES any host that is not erp-sandbox.arcodange.lab (the structural prod-safety guarantee) using the ai_agent_sandbox key from a gitignored .env. - scripts/thirdparty-create.sh: create client/supplier fiches; codes auto-assign via the elephant mask (code="-1"). - scripts/invoice-create.sh: customer (/invoices) or supplier (/supplierinvoices) invoices with product/service lines + ref_supplier, optional validate. - scripts/payment-record.sh: record a règlement (VIR/CB/CHQ/LIQ); customer pays full + marks paid, supplier needs an amount. - SKILL.md (safety model + workflows + the human-gated promote flow), .env.example, example input. Proven end-to-end live against the sandbox: client -> invoice (service+product lines, HT 1100 / TTC 1320) -> validate -> payment (paid); supplier -> supplier invoice (ref_supplier carried) -> validate. Host guard verified to refuse a prod URL before sending. Avoirs (credit notes) and bin/arcodange CLI wiring are planned follow-ups. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
2.0 KiB
Bash
Executable File
51 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Create a client and/or supplier thirdparty (fiche tiers) in the SANDBOX.
|
|
#
|
|
# Input: a JSON object on stdin (or a file path in $1). Fields:
|
|
# name (required)
|
|
# role "client" | "supplier" | "both" (default "client")
|
|
# country_id numeric, default 1 (France)
|
|
# client_code / supplier_code default "-1" = auto-generate via the code mask
|
|
# siret, tva_intra, address, zip, town, email, phone, idprof1 (optional)
|
|
#
|
|
# Emits the new thirdparty id on stdout. All writes go through dol-write.sh,
|
|
# which refuses any host that is not the sandbox.
|
|
#
|
|
# Examples:
|
|
# echo '{"name":"KissMetrics","role":"client","tva_intra":"US.."}' | thirdparty-create.sh
|
|
# thirdparty-create.sh fournisseur.json
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
W="${SCRIPT_DIR}/dol-write.sh"
|
|
|
|
SRC="${1:-}"
|
|
if [[ -n "${SRC}" && "${SRC}" != "-" ]]; then INPUT="$(cat "${SRC}")"; else INPUT="$(cat)"; fi
|
|
|
|
PYF="$(mktemp -t dolpy.XXXXXX)"; trap 'rm -f "${PYF}"' EXIT
|
|
cat > "${PYF}" <<'PY'
|
|
import json, sys
|
|
d = json.loads(sys.stdin.read())
|
|
if not d.get("name"):
|
|
sys.exit("thirdparty-create.sh: 'name' is required")
|
|
role = d.get("role", "client").lower()
|
|
is_client = role in ("client", "both")
|
|
is_supp = role in ("supplier", "fournisseur", "both")
|
|
body = {
|
|
"name": d["name"],
|
|
"client": "1" if is_client else "0",
|
|
"fournisseur": "1" if is_supp else "0",
|
|
"country_id": str(d.get("country_id", 1)),
|
|
# "-1" => Dolibarr auto-assigns the next code from the mask
|
|
# (COMPANY_ELEPHANT_MASK_CUSTOMER / _SUPPLIER); "0" when that role is off.
|
|
"code_client": (d.get("client_code", "-1") if is_client else "0"),
|
|
"code_fournisseur": (d.get("supplier_code", "-1") if is_supp else "0"),
|
|
}
|
|
for k in ("siret", "tva_intra", "address", "zip", "town", "email", "phone", "idprof1"):
|
|
if d.get(k):
|
|
body[k] = d[k]
|
|
print(json.dumps(body))
|
|
PY
|
|
|
|
BODY="$(printf '%s' "${INPUT}" | python3 "${PYF}")"
|
|
"${W}" POST /thirdparties "${BODY}"
|