Skip to content

Instantly share code, notes, and snippets.

@emag
Created December 8, 2024 13:01
Show Gist options
  • Save emag/bdc55281af5be73f6ce702f1af2aa515 to your computer and use it in GitHub Desktop.
Save emag/bdc55281af5be73f6ce702f1af2aa515 to your computer and use it in GitHub Desktop.
仕訳の記帳
"仕訳の記帳" should {
"BS を更新する" in {
// Given
val initA = Map(Cash -> BigDecimal(1_000_000))
val initL = Map(AccruedLiability -> BigDecimal(100_000))
val entry1 = JournalEntry(
date = LocalDate.now(),
debit = BankAccount,
credit = Cash,
amount = BigDecimal(500_000),
description = "入金"
)
val entry2 = JournalEntry(
date = LocalDate.now(),
debit = AccruedLiability,
credit = BankAccount,
amount = BigDecimal(100_000),
description = "foo カード"
)
val entry3 = JournalEntry(
date = LocalDate.now(),
debit = FoodCost,
credit = AccruedLiability,
amount = BigDecimal(3_000),
description = "スーパー"
)
// When
val result = BalanceSheet.NotReady
.initialize(initA, initL)
.flatMap(_.journalize(entry1))
.flatMap(_.journalize(entry2))
.flatMap(_.journalize(entry3))
// Then
result shouldBe Accepted(
NonEmptyChain(
Initialized(initA, initL),
Journalized(entry1),
Journalized(entry2),
Journalized(entry3)
),
Ready(
assets = Map(
Cash -> BigDecimal(500_000),
BankAccount -> BigDecimal(400_000)
),
liabilities = Map(
AccruedLiability -> BigDecimal(3_000)
)
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment