wip: pause checkpoint — P6 feature complete, gate interrupted (not for merge)
This commit is contained in:
1 parent
cc4f104f06
commit
ce36640874
68 files changed
+4592
-374
No files matched your search
@@ -708,3 +708,41 @@ pub(crate) fn resolve_instrument(store: &Store, r: &str) -> Result<InstrumentId,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
/// An annotation as a tool answers with it (plan P6 step 5).
|
||||
pub(crate) fn annotation_out(a: &ledger_core::Annotation) -> AnnotationOut {
|
||||
AnnotationOut {
|
||||
receipt_number: a.fields.receipt_number,
|
||||
payee: a.fields.payee.clone(),
|
||||
amount: a.fields.amount.map(money),
|
||||
date: a.fields.date.map(|d| d.to_string()),
|
||||
instrument: a.fields.instrument.clone(),
|
||||
category: a.fields.category.clone(),
|
||||
source: a.fields.source.clone(),
|
||||
reimbursable_to: a.fields.reimbursable_to.clone(),
|
||||
note: a.note.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// A file name's stem, for a page picture's or a text file's name: what is
|
||||
/// before the last dot, or "attachment" when there is nothing.
|
||||
pub(crate) fn stem(file_name: &str) -> String {
|
||||
let stem = file_name
|
||||
.rsplit_once('.')
|
||||
.map_or(file_name, |(stem, _)| stem)
|
||||
.trim();
|
||||
if stem.is_empty() {
|
||||
"attachment".to_string()
|
||||
} else {
|
||||
stem.chars().take(80).collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// The largest character boundary at or below `at` in `text`.
|
||||
pub(crate) fn floor_char_boundary(text: &str, at: usize) -> usize {
|
||||
let mut cut = at.min(text.len());
|
||||
while !text.is_char_boundary(cut) {
|
||||
cut -= 1;
|
||||
}
|
||||
cut
|
||||
}
|
||||
Reference in new issue
Block a user