Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 49 minutes ago History
exchange_send.py · 1.9 KB · 42 lines
1"""action_exchange_send -- send a business record to a trading partner.
2
3POST {collection, record_id, partner?, response?, credits_invoice_id?}
4
5Makes the signed document for one record and queues it in exchange_outbox;
6the daemon delivers it (system_exchange_deliver). What a record becomes:
7
8- an orders row of doc_type purchase -> purchase_order (name the partner);
9- an orders row of doc_type sale -> order_confirmation (to the partner whose
10 purchase order it came from; `response` accepted | rejected | amended);
11- an invoices row -> invoice, or credit_note for doc_type credit_note
12 (to the partner whose purchase order the invoice's source order came
13 from, or the one named; `credits_invoice_id` refers a credit note to the
14 invoice it credits);
15- a supplier_bills row a person marked paid -> remittance (to the supplier
16 it came from);
17- a receipts row (app-receiving) that is received -> receipt (to the
18 supplier of its purchase order).
19
20Sending commits the business, so the caller must be staff (an admin, the
21owner role or role:manager; a plain registered user is a customer, who owns
22the orders and invoices checkout raises for them) AND allowed to UPDATE the
23record (object_access). One document per record and type:
24a second send is refused naming the first. The partner must be connected
25and the type switched on for sending to them.
26"""
27
28import object_exchange
29import object_exchange_box as box
30
31
32def POST(request):
33 try:
34 return box.send(box.base_dir(), request.get("_identity"),
35 collection=request.get("collection") or "",
36 record_id=request.get("record_id") or "",
37 partner_domain=request.get("partner") or "",
38 requested=request)
39 except box.Refusal as refusal:
40 return refusal.answer()
41 except object_exchange.ExchangeUnavailable as exc:
42 return {"status": 409, "code": "exchange_unavailable", "error": str(exc)}