Allow expense account overrides by content type for Apple Store transactions
Dependencies
- [2]
UO34MAAGRefactor CSV-based Importers - [3]
362NCCMXAdd importer for Apple Store - [4]
MSGK44CSRefactor ImporterProtocol to pass buffers
Change contents
- edit in importers/apple/src/transaction_history.rs at line 17
use hashbrown::HashMap; - edit in importers/apple/src/transaction_history.rs at line 43
#[serde(default)]#[builder(field(type = "HashMap<String, Account>"))]pub content_type_expense_accounts: HashMap<String, Account>, - edit in importers/apple/src/transaction_history.rs at line 49
pub payee: String, - replacement in importers/apple/src/transaction_history.rs at line 61
pub const NAME: &str = "apple/transaction-history";pub const NAME: &'static str = "apple/transaction-history"; - edit in importers/apple/src/transaction_history.rs at line 70
}fn lookup_expense_account(&self, content_type: &str, context: &TemplateContext<'_>) -> Account {self.config.content_type_expense_accounts.get(content_type).cloned().unwrap_or_else(|| self.config.expense_account.render(context)) - replacement in importers/apple/src/transaction_history.rs at line 212
.build_posting(self.config.expense_account.render(&context), |_posting| {});.build_posting(self.lookup_expense_account(record.content_type, &context),|_posting| {},); - edit in importers/apple/src/transaction_history.rs at line 223
pub fn try_add_content_type_expense_account<A>(&mut self,name: impl Into<String>,account: A,) -> Result<&mut Self, A::Error>whereA: TryInto<Account>,{self.content_type_expense_accounts.insert(name.into(), account.try_into()?);Ok(self)}}impl ImporterBuilder { - edit in importers/apple/src/transaction_history.rs at line 244
content_type_expense_accounts: self.content_type_expense_accounts.clone(), - edit in importers/apple/src/transaction_history.rs at line 254
payee: self.payee.clone().context(UninitializedFieldSnafu {field: "payee",importer: Importer::NAME,})?, - edit in importers/apple/src/transaction_history.rs at line 262
#[serde(rename = "Content Type")]content_type: &'r str, - edit in importers/apple/Cargo.toml at line 19
hashbrown.workspace = true