Allow expense account overrides by content type for Apple Store transactions

korrat
Feb 5, 2024, 1:41 PM
UZFKS57SWR5P3BHRONPRANXL5VH5Z6PQRQAFYOHZ2SUD67VBXDCQC

Dependencies

  • [2] UO34MAAG Refactor CSV-based Importers
  • [3] 362NCCMX Add importer for Apple Store
  • [4] MSGK44CS Refactor ImporterProtocol to pass buffers

Change contents

  • edit in importers/apple/src/transaction_history.rs at line 17
    [3.549]
    [2.28470]
    use hashbrown::HashMap;
  • edit in importers/apple/src/transaction_history.rs at line 43
    [3.1184]
    [3.1184]
    #[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
    [3.1245][3.1245:1269]()
    pub payee: String,
  • replacement in importers/apple/src/transaction_history.rs at line 61
    [3.1456][3.1456:1512]()
    pub const NAME: &str = "apple/transaction-history";
    [3.1456]
    [3.1512]
    pub const NAME: &'static str = "apple/transaction-history";
  • edit in importers/apple/src/transaction_history.rs at line 70
    [3.1721]
    [3.1721]
    }
    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
    [3.6039][3.6039:6132]()
    .build_posting(self.config.expense_account.render(&context), |_posting| {});
    [3.6039]
    [3.6132]
    .build_posting(
    self.lookup_expense_account(record.content_type, &context),
    |_posting| {},
    );
  • edit in importers/apple/src/transaction_history.rs at line 223
    [3.6224]
    [3.6224]
    pub fn try_add_content_type_expense_account<A>(
    &mut self,
    name: impl Into<String>,
    account: A,
    ) -> Result<&mut Self, A::Error>
    where
    A: 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
    [3.6506]
    [3.6506]
    content_type_expense_accounts: self.content_type_expense_accounts.clone(),
  • edit in importers/apple/src/transaction_history.rs at line 254
    [3.6763][3.6763:6927]()
    payee: self.payee.clone().context(UninitializedFieldSnafu {
    field: "payee",
    importer: Importer::NAME,
    })?,
  • edit in importers/apple/src/transaction_history.rs at line 262
    [2.30079]
    [2.30079]
    #[serde(rename = "Content Type")]
    content_type: &'r str,
  • edit in importers/apple/Cargo.toml at line 19
    [3.18695]
    [2.33956]
    hashbrown.workspace = true