Chapter 45: Purchases
A Purchase records a transfer of goods and services from a producer to a consumer at a
particular time. It does not record the associated monetary exchanges.
The producer uses a ProducerAccount and the consumer uses a
ConsumerAccount. These record shared purchases.
There is no need for a denomination parameter on a Purchase because it is only concerned
with recording the goods and services that were transferred.
Nevertheless, the item prices have a denomination, which is implicitly given by the denomination of
the producer's account.
Where products have warranties, the purchase is important for identifying what was transferred, when it was transferred, and who supplied and received it.
The recording of purchases in CATS is mainly intended for use with B-accounts and R-accounts. For an
R-account purchase, there must be a separate monetary exchange matching
totalPrice, so that the correct amount of consumption tax is paid. CATS correlates that
exchange with the purchase without making it part of the Purchase record.
value LineItem
{
String product;
Int64 itemPrice where itemPrice ≥ 0;
Int64 quantity where quantity > 0;
→ Int64 price = quantity * itemPrice;
}
// Monotonically increasing purchase number for a given ProducerAccount
type PurchaseId = Uint64;
entity Purchase
{
ProducerAccount producerAccount;
PurchaseId purchaseId;
ConsumerAccount consumerAccount;
TimeStamp time;
LineItem item*;
→ Int64 totalPrice = item.price.Σsum;
key {producerAccount,purchaseId};
constraints
{
item.Σexists;
}
}
entity ProducerAccount
{
Account account;
Purchase purchase* where purchase.producerAccount = this;
→ Person producer = account.owner;
// Denomination of all prices
→ Denomination denomination = account.denomination;
key {account};
}
entity ConsumerAccount
{
Account account;
async → Purchase purchase* where purchase.consumerAccount = this;
→ Person consumer = account.owner;
key {account};
}
Eventual consistency
The ProducerAccount and ConsumerAccount reside on the nodes of their
respective owners and therefore may not be on the same node. The shared ownership of a
Purchase consequently involves asynchronous propagation of updates to reach eventual
consistency. The ProducerAccount is authoritative for recording purchases when they are
first made. CATS then propagates each purchase to the ConsumerAccount asynchronously.