P3: assets' posted and scheduled depreciation, their bases, and the K-1 on the tax basis (defect 13, D-41)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Book value is cost less what the books posted; the schedule's figure is apart. An asset's acquired date comes from its entry. Contributed property keeps its section 723 carryover basis apart from its depreciable basis (the lower of value and adjusted basis), with its 704(c) built-in gain and method. The K-1 worksheet reports tax-basis capital (Form 1065 Item L) beside the book figures, leaving open what only the CPA knows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3gXMVt7XJPi6ens1or9Dj
This commit is contained in:
81 files changed
+9391
-2604
No files matched your search
@@ -1238,11 +1238,11 @@ impl Books {
|
||||
};
|
||||
let amount = self.asset_register(through)?.unposted_depreciation();
|
||||
let mut periods = std::collections::BTreeSet::new();
|
||||
for a in self
|
||||
.ledger
|
||||
.registered_assets()
|
||||
.filter(|a| a.purchase_date <= through)
|
||||
{
|
||||
for a in self.ledger.registered_assets().filter(|a| {
|
||||
self.ledger
|
||||
.asset_acquired_date(a.id)
|
||||
.is_some_and(|d| d <= through)
|
||||
}) {
|
||||
if matches!(a.status, AssetStatus::Disposed { date, .. } if date <= through) {
|
||||
continue;
|
||||
}
|
||||
@@ -2091,26 +2091,22 @@ fn asset_trails(ledger: &Ledger, journal: &[JournalLine]) -> HashMap<AssetId, As
|
||||
continue;
|
||||
};
|
||||
t.events.push(i);
|
||||
match line.line_type.as_str() {
|
||||
"asset.depreciation_posted" => {
|
||||
if let (Some(period), Some(entry), Some(amount)) = (
|
||||
p.get("period").and_then(|v| v.as_str()),
|
||||
u(p, "entry_id"),
|
||||
p.get("amount")
|
||||
.and_then(|v| v.as_str())
|
||||
.and_then(|s| s.parse::<Decimal>().ok()),
|
||||
) {
|
||||
t.runs.push((entry, amount));
|
||||
t.periods.push(period.to_string());
|
||||
}
|
||||
if line.line_type == "asset.disposed" {
|
||||
t.disposal_entry = u(p, "entry_id");
|
||||
if let Some(a) = asset {
|
||||
gain_loss_accounts.insert(a, u(p, "gain_loss_account"));
|
||||
}
|
||||
"asset.disposed" => {
|
||||
t.disposal_entry = u(p, "entry_id");
|
||||
if let Some(a) = asset {
|
||||
gain_loss_accounts.insert(a, u(p, "gain_loss_account"));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Every run journaled, reversed or not, in the order recorded: the
|
||||
// ledger's runs (each asset.depreciation_posted as replay recorded it),
|
||||
// one reading of the journal, never a second copy read here.
|
||||
for a in ledger.registered_assets() {
|
||||
if let Some(t) = out.get_mut(&a.id) {
|
||||
for run in ledger.depreciation_runs(a.id) {
|
||||
t.runs.push((run.entry, run.amount));
|
||||
t.periods.push(run.period.clone());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
// The runs in effect, by month; a run reversed (and not re-instated)
|
||||
@@ -2168,7 +2164,7 @@ fn asset_trails(ledger: &Ledger, journal: &[JournalLine]) -> HashMap<AssetId, As
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let days = (e.date() - a.purchase_date).num_days().abs();
|
||||
let days = (e.date() - a.in_service_date).num_days().abs();
|
||||
if days > 31 {
|
||||
continue;
|
||||
}
|
||||
@@ -2214,7 +2210,8 @@ fn disposal_true_up(
|
||||
})
|
||||
.sum();
|
||||
}
|
||||
ledger_core::accumulated_depreciation(asset, NaiveDate::MAX).map_or(Decimal::ZERO, |t| t - runs)
|
||||
ledger_core::accumulated_scheduled_through(asset, NaiveDate::MAX)
|
||||
.map_or(Decimal::ZERO, |t| t - runs)
|
||||
}
|
||||
|
||||
/// Entry ids a journal line refers to.
|
||||
|
||||
Reference in new issue
Block a user