これはプロトタイプ hkr では実装してなかった機能なので、ちょっと設計を考える必要がある。
しかも面倒・・・・・
まず、定額法しか対応しない!(できない)
で、決算書を読んでみる。
- 名称(種類)
- 面積または数量
- 取得年月
- 取得価額
- 償却の基礎になる金額
- 償却方法
- 耐用年数
- 償却率
- 本年中の償却期間
- 本年分の普通償却費
- 割り増し(特別)償却費
- 本年分の償却費合計
- 事業専用割合
- 本年分の必要経費算入額
- 未償却残高
変わらないデータと、年ごとに変わるデータに分類してみる。
変わらない : 1, 2, 3, 4, 5, 6, 7, 8
変わる : 9, 10, 11, 12, 13, 14, 15
ので、これを2つのモデルで表すこととする。
ただし、「11. 割り増し(特別)償却費」は聞いたことないし、個人事業主レベルでは使うことがなさそうなので、取りあえずは未対応。
「これは対応しません」リストも作らんとなぁ。
変わらないデータ : FixedAsset モデル
- business_unit_id : どこの決算書に計上するか
- account_id : どの科目の資産か(年度末の仕訳帳の科目にも使う)
- name
- acquisition_date : 取得年月(日)
- acquisition_cost : 取得価格
- depreciation_base_amount : 償却の基礎になる金額(取得価格と同じ)
- useful_life : 耐用年数
- depreciation_method : 定額法のみだが、一応
- memo
- is_disposed : 売却したらtrue
- disposed_at : 売却日
- disposal_amount : 売却額
- disposal_account_id : 売却のお金の保存先(預金/現金)
- disposal_gain_loss_account_id : 売却益/損の勘定科目(optional)
変わるデータ : DepreciationEntry モデル
- fixed_asset_id : 親
- journal_entry_id : 仕訳帳を作る時のリレーション(期末、もしくは売却)
- date : 仕訳帳を作った日
- months : 本年中の償却期間(月)
- amount : 本年分の普通償却費
- business_use_ratio : 事業専用割合
- deductible_amount : 必要経費算入額
未償却費残高は FixedAsset に計算させる。
全体の調整は DepriciationService クラスに集約する。
購入時は、同時に仕訳とdepreciationEntryを作成する
(そのため、仕訳データ + 減価償却費に関するデータを渡す)
購入
$service = app(DepreciationService::class);
$app->registerFixedAsset(
businessUnit: $unit,
assetAccount: $unit->accounts()->firstWhere('name', '器具備品'),
paymentAccount: $unit->accounts()->firstWhere('name', '普通預金'),
fixedAssetData: [
'name' => 'ノートPC',
'asset_category' => 'furniture_fixtures',
'acquisition_date' => '2023-08-01',
'acquisition_cost' => 150000,
'useful_life' => 5,
],
transactionData: [
'fiscal_year' => $fiscalYear,
'description' => 'ノートPCの購入',
]
);
その年の減価償却計算の準備
$service = app(DepreciationService::class);
// 帳票データ作成 (各Assetに対する DepreciationEntry が作成される )
$service->prepareEntriesFor($fiscalYear);
減価償却仕訳
$service = app(DepreciationService::class);
$entry = hogehoge();
$service->registerJournalEntryFor($entry);