[ledger] Sharing: payment.shared/unshared, splits that always add up, share links, capture tokens, account; QR Platba with checked IBAN
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
use crate::date::{Date, Timestamp};
|
||||
use crate::import::StatementLine;
|
||||
use crate::money::Haler;
|
||||
use crate::split::Share;
|
||||
use crate::state::Glyph;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Ids are opaque strings the app generates (random, unguessable); the core never makes one up.
|
||||
@@ -10,6 +12,7 @@ pub type EventId = String;
|
||||
pub type PaymentId = String;
|
||||
pub type BudgetId = String;
|
||||
pub type RuleId = String;
|
||||
pub type SplitId = String;
|
||||
/// A category id, e.g. `groceries` (see [`crate::categories`]).
|
||||
pub type Category = String;
|
||||
|
||||
@@ -35,6 +38,24 @@ pub enum Decision {
|
||||
Cancel,
|
||||
}
|
||||
|
||||
/// How a share of a split was settled.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Settlement {
|
||||
/// Paid by QR Platba.
|
||||
Qr,
|
||||
/// Marked paid by hand (cash, another way).
|
||||
Marked,
|
||||
}
|
||||
|
||||
/// Which phone a capture token is for.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum CaptureKind {
|
||||
Iphone,
|
||||
Android,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum EventBody {
|
||||
@@ -73,4 +94,34 @@ pub enum EventBody {
|
||||
/// Keep or cancel a subscription (by its key), seen at `amount` (a positive cost) on `on`.
|
||||
#[serde(rename = "subscription.decided")]
|
||||
SubscriptionDecided { subscription: String, decision: Decision, amount: Haler, on: Date },
|
||||
/// A shared budget's log: a member put this payment (as they see it) into the budget.
|
||||
#[serde(rename = "payment.shared")]
|
||||
PaymentShared {
|
||||
payment: PaymentId,
|
||||
budget: BudgetId,
|
||||
amount: Haler,
|
||||
date: Date,
|
||||
merchant: String,
|
||||
category: Option<Category>,
|
||||
glyph: Glyph,
|
||||
},
|
||||
/// A shared budget's log: the payment is taken out of the budget again.
|
||||
#[serde(rename = "payment.unshared")]
|
||||
PaymentUnshared { payment: PaymentId, budget: BudgetId },
|
||||
/// The payment's amount, split among people (see [`crate::split::split_equal`]).
|
||||
#[serde(rename = "split.created")]
|
||||
SplitCreated { split: SplitId, payment: PaymentId, payer: String, shares: Vec<Share> },
|
||||
#[serde(rename = "split.settled")]
|
||||
SplitSettled { split: SplitId, person: String, how: Settlement },
|
||||
/// A phone's capture token: only its SHA-256 in lowercase hex. The token itself lives in Custos.
|
||||
#[serde(rename = "capture.token_added")]
|
||||
CaptureTokenAdded { token: String, name: String, kind: CaptureKind },
|
||||
#[serde(rename = "capture.token_revoked")]
|
||||
CaptureTokenRevoked { token: String },
|
||||
/// A share link for one person of a split: only the SHA-256 of the link's token, in lowercase hex.
|
||||
#[serde(rename = "share.link_created")]
|
||||
ShareLinkCreated { link: String, split: SplitId, person: String, expires: Date },
|
||||
/// The account people pay back to by QR Platba.
|
||||
#[serde(rename = "account.set")]
|
||||
AccountSet { iban: String, name: String },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user