The legal practice: clients, lawyers, contracts, papers, the journal
Lanna Desk's larger work is contracts, general ones and artists', for clients who are Thai or foreign, people or organizations, with several lawyers in the team. The back office gets a Legal section (phase 9 in docs/PLAN.md): - Lawyers: license number, contact, the login of one who uses the app (then "My contracts"), in the team or left. - Clients, as record cards: person or organization, names in English and Thai, stage name or brand, a Thai ID number (checked), a passport or a registration number, the lawyer in charge. - Contracts: code LD-<year>-<n>, the general kinds and the artist kinds (recording, management, publishing, performance, license, merchandise), other party, status, lawyer, dates and value; a contract in force shows its notice day and its end ahead. Filters: general or artists, a lawyer, mine, those over. - Versions: a text kept here, a file (PDF or scan, encrypted as the client's document) or both. They never change: the database refuses UPDATE and DELETE, a version's file cannot be deleted and no document's checksum can change. Any version reads against the one before as a line diff. - Paper copies: the id <code>-P<n> to write on the paper or print as a 90 x 50 mm label with a QR code; where it lies, its state and holder, each move journaled; found again by its id. - The journal: every change in words, in the change's transaction, each entry chained to the one before by SHA-256. The database refuses to change, delete or truncate it; /journal checks the chain and every version's text and fingerprints against its entry, shows the last hash and exports CSV. The sidebar groups its sections: Legal, Visas and stays, Office. Demo data (seed-demo) adds three lawyers, six clients and seven contracts with versions, papers and moves. Documents take a third owner, the client (migration 0009). Checks: fmt, clippy, 115 unit and 62 integration tests (new: versions and the journal, the database refusing changes, a change around the app breaking the chain, paper ids and moves, the demo checking whole); screenshots of the new pages in light, dark and on a phone.
This commit is contained in:
1 parent
424f212b23
commit
16e4cdc73d
32 files changed
+4758
-45
No files matched your search
+30
-20
@@ -48,6 +48,10 @@ pub enum Input {
|
||||
Count,
|
||||
/// A year, the Western one; a Thai year (B.E.) is turned into it.
|
||||
Year,
|
||||
/// One of the lawyers.
|
||||
Lawyer,
|
||||
/// One of the clients of the legal practice.
|
||||
Client,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -66,7 +70,7 @@ pub struct Field {
|
||||
pub section: &'static str,
|
||||
}
|
||||
|
||||
const fn field(name: &'static str, label: &'static str, input: Input) -> Field {
|
||||
pub(crate) const fn field(name: &'static str, label: &'static str, input: Input) -> Field {
|
||||
Field {
|
||||
name,
|
||||
label,
|
||||
@@ -80,19 +84,19 @@ const fn field(name: &'static str, label: &'static str, input: Input) -> Field {
|
||||
}
|
||||
|
||||
impl Field {
|
||||
const fn req(self, missing: &'static str) -> Field {
|
||||
pub(crate) const fn req(self, missing: &'static str) -> Field {
|
||||
Field { missing, ..self }
|
||||
}
|
||||
const fn hint(self, hint: &'static str) -> Field {
|
||||
pub(crate) const fn hint(self, hint: &'static str) -> Field {
|
||||
Field { hint, ..self }
|
||||
}
|
||||
const fn suggest(self, suggest: &'static str) -> Field {
|
||||
pub(crate) const fn suggest(self, suggest: &'static str) -> Field {
|
||||
Field { suggest, ..self }
|
||||
}
|
||||
const fn wide(self) -> Field {
|
||||
pub(crate) const fn wide(self) -> Field {
|
||||
Field { wide: true, ..self }
|
||||
}
|
||||
const fn section(self, section: &'static str) -> Field {
|
||||
pub(crate) const fn section(self, section: &'static str) -> Field {
|
||||
Field { section, ..self }
|
||||
}
|
||||
}
|
||||
@@ -525,7 +529,7 @@ pub static STAY: [&Kind; 6] = [
|
||||
|
||||
// ----------------------------------------------------- checks and chips
|
||||
|
||||
fn val<'a>(v: &'a Values, k: &str) -> &'a str {
|
||||
pub(crate) fn val<'a>(v: &'a Values, k: &str) -> &'a str {
|
||||
v.get(k).map(String::as_str).unwrap_or("")
|
||||
}
|
||||
|
||||
@@ -533,9 +537,9 @@ fn date(v: &Values, k: &str) -> Option<NaiveDate> {
|
||||
dates::parse_date(val(v, k))
|
||||
}
|
||||
|
||||
fn no_check(_: &Values, _: &mut Errors) {}
|
||||
pub(crate) fn no_check(_: &Values, _: &mut Errors) {}
|
||||
|
||||
fn no_status(_: &Values, _: NaiveDate) -> Option<Status> {
|
||||
pub(crate) fn no_status(_: &Values, _: NaiveDate) -> Option<Status> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -683,6 +687,8 @@ pub struct Options {
|
||||
pub passports: Vec<(String, String)>,
|
||||
pub visas: Vec<(String, String)>,
|
||||
pub companies: Vec<(String, String)>,
|
||||
pub lawyers: Vec<(String, String)>,
|
||||
pub clients: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
@@ -691,6 +697,8 @@ impl Options {
|
||||
Input::Passport => &self.passports,
|
||||
Input::Visa => &self.visas,
|
||||
Input::Company => &self.companies,
|
||||
Input::Lawyer => &self.lawyers,
|
||||
Input::Client => &self.clients,
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
@@ -767,7 +775,7 @@ pub fn validate(kind: &Kind, v: &Values, opts: &Options) -> Errors {
|
||||
err(&mut e, fl.name, "Enter digits only.");
|
||||
}
|
||||
}
|
||||
Input::Passport | Input::Visa | Input::Company => {
|
||||
Input::Passport | Input::Visa | Input::Company | Input::Lawyer | Input::Client => {
|
||||
if opts.label_of(fl.input, value).is_none() {
|
||||
err(&mut e, fl.name, "Choose from the list.");
|
||||
}
|
||||
@@ -848,7 +856,9 @@ fn columns(kind: &Kind) -> String {
|
||||
| Input::Year
|
||||
| Input::Passport
|
||||
| Input::Visa
|
||||
| Input::Company => {
|
||||
| Input::Company
|
||||
| Input::Lawyer
|
||||
| Input::Client => {
|
||||
format!("COALESCE({0}::text, '') AS {0}", f.name)
|
||||
}
|
||||
_ => f.name.to_string(),
|
||||
@@ -934,7 +944,7 @@ fn bind_value(qb: &mut QueryBuilder<'_, Postgres>, f: &Field, v: &Values) {
|
||||
Input::Amount => {
|
||||
qb.push_bind(s.parse::<i64>().ok());
|
||||
}
|
||||
Input::Passport | Input::Visa | Input::Company => {
|
||||
Input::Passport | Input::Visa | Input::Company | Input::Lawyer | Input::Client => {
|
||||
qb.push_bind(s.parse::<i64>().ok());
|
||||
}
|
||||
_ => {
|
||||
@@ -1049,7 +1059,7 @@ pub fn form_fields(kind: &Kind, opts: &Options) -> Vec<FormField> {
|
||||
.map(|(a, b)| (a.to_string(), b.to_string()))
|
||||
.collect(),
|
||||
),
|
||||
Input::Passport | Input::Visa | Input::Company => {
|
||||
Input::Passport | Input::Visa | Input::Company | Input::Lawyer | Input::Client => {
|
||||
("select", opts.list(fl.input).to_vec())
|
||||
}
|
||||
Input::Text | Input::Code | Input::Digits | Input::Gps => ("text", vec![]),
|
||||
@@ -1120,16 +1130,17 @@ pub fn shown_value(fl: &Field, raw: &str, opts: &Options) -> Part {
|
||||
.parse::<i64>()
|
||||
.map(|n| format!("{} THB", thousands(n)))
|
||||
.unwrap_or_else(|_| raw.to_string()),
|
||||
Input::Passport | Input::Visa | Input::Company => opts
|
||||
Input::Passport | Input::Visa | Input::Company | Input::Lawyer | Input::Client => opts
|
||||
.label_of(fl.input, raw)
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| format!("record {raw}")),
|
||||
_ => raw.to_string(),
|
||||
};
|
||||
let href = if fl.input == Input::Company {
|
||||
format!("/companies/{raw}")
|
||||
} else {
|
||||
String::new()
|
||||
let href = match fl.input {
|
||||
Input::Company => format!("/companies/{raw}"),
|
||||
Input::Client => format!("/clients/{raw}"),
|
||||
Input::Lawyer => format!("/lawyers/{raw}"),
|
||||
_ => String::new(),
|
||||
};
|
||||
Part { text, href }
|
||||
}
|
||||
@@ -1237,8 +1248,7 @@ mod tests {
|
||||
fn reads_and_checks_an_arrival() {
|
||||
let opts = Options {
|
||||
passports: vec![("7".into(), "C01X00T47 (Germany)".into())],
|
||||
visas: vec![],
|
||||
companies: vec![],
|
||||
..Options::default()
|
||||
};
|
||||
let v = read(
|
||||
&ARRIVALS,
|
||||
|
||||
Reference in new issue
Block a user