fix(package): the IIF export keeps its typed refusal
`export_iif` turned `journal_to_iif`'s refusal into a string, so a caller could not tell why the file was refused without reading the message. An entry on more than one receivable or payable account is BS-format-10's own refusal (the receiving program will not take the transaction), while every other IIF refusal is BS-format-2's; the bookspec adapter must name the one rule an example expects. Returning `IifError` keeps the two apart by type. The package and the MCP tool still hand the human a string. Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
1 parent
d59eca0c1a
commit
9c299eb768
3 files changed
+4
-4
No files matched your search
@@ -1513,7 +1513,7 @@ impl BooksServer {
|
||||
} else {
|
||||
cash
|
||||
};
|
||||
ledger_package::export_iif(store.ledger(), cash, as_of)
|
||||
ledger_package::export_iif(store.ledger(), cash, as_of).map_err(|e| e.to_string())
|
||||
}
|
||||
/// The general journal as JSON or CSV: each entry posted in the
|
||||
/// period (BS-period-3, as the XLSX journal), in posting order.
|
||||
|
||||
@@ -38,7 +38,7 @@ pub fn export_iif(
|
||||
ledger: &Ledger,
|
||||
cash_codes: &[String],
|
||||
as_of: NaiveDate,
|
||||
) -> Result<ledger_import::Iif, String> {
|
||||
) -> Result<ledger_import::Iif, ledger_import::IifError> {
|
||||
use ledger_import::{QbAccountType as Qb, iif_accounts, iif_classes, journal_to_iif};
|
||||
let fixed: std::collections::HashSet<AccountId> = ledger
|
||||
.registered_assets()
|
||||
@@ -71,5 +71,5 @@ pub fn export_iif(
|
||||
.posted_entries()
|
||||
.filter(|e| e.date() <= as_of && !closes.contains(&e.id()))
|
||||
.collect();
|
||||
journal_to_iif(&accounts, &iif_classes(ledger), &entries).map_err(|e| e.to_string())
|
||||
journal_to_iif(&accounts, &iif_classes(ledger), &entries)
|
||||
}
|
||||
@@ -564,7 +564,7 @@ pub fn build_package<B: PackageBooks + ?Sized>(
|
||||
let seq = books.journal_seq();
|
||||
// The journal through as_of for QuickBooks, closes left out, and what
|
||||
// it writes differently (INVARIANT 8).
|
||||
let iif = export_iif(ledger, cash_codes, as_of)?;
|
||||
let iif = export_iif(ledger, cash_codes, as_of).map_err(|e| e.to_string())?;
|
||||
let (warnings, iif_changes) = (iif.warnings(), iif.changes.len());
|
||||
let receivable_payable: Vec<String> = iif
|
||||
.receivable_payable
|
||||
|
||||
Reference in new issue
Block a user