@k2works/claude-code-booster 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +42 -42
- package/bin/claude-code-booster +90 -90
- package/lib/assets/.claude/README.md +239 -239
- package/lib/assets/.claude/scripts/generate-inception-deck.mjs +911 -911
- package/lib/assets/.claude/settings.json +11 -11
- package/lib/assets/.claude/skills/ai-agent-guidelines/SKILL.md +111 -111
- package/lib/assets/.claude/skills/analyzing-architecture/SKILL.md +83 -83
- package/lib/assets/.claude/skills/analyzing-business/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-data-model/SKILL.md +77 -77
- package/lib/assets/.claude/skills/analyzing-domain-model/SKILL.md +117 -88
- package/lib/assets/.claude/skills/analyzing-inception-deck/SKILL.md +84 -84
- package/lib/assets/.claude/skills/analyzing-non-functional/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-operation/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-requirements/SKILL.md +91 -91
- package/lib/assets/.claude/skills/analyzing-tech-stack/SKILL.md +101 -101
- package/lib/assets/.claude/skills/analyzing-test-strategy/SKILL.md +89 -89
- package/lib/assets/.claude/skills/analyzing-ui-design/SKILL.md +80 -80
- package/lib/assets/.claude/skills/analyzing-usecases/SKILL.md +72 -72
- package/lib/assets/.claude/skills/creating-adr/SKILL.md +113 -113
- package/lib/assets/.claude/skills/developing-backend/SKILL.md +100 -100
- package/lib/assets/.claude/skills/developing-frontend/SKILL.md +93 -93
- package/lib/assets/.claude/skills/developing-release/SKILL.md +120 -120
- package/lib/assets/.claude/skills/generating-slides/SKILL.md +94 -94
- package/lib/assets/.claude/skills/git-commit/SKILL.md +81 -81
- package/lib/assets/.claude/skills/killing-processes/SKILL.md +44 -44
- package/lib/assets/.claude/skills/operating-backup/SKILL.md +59 -59
- package/lib/assets/.claude/skills/operating-cicd/SKILL.md +54 -54
- package/lib/assets/.claude/skills/operating-deploy/SKILL.md +67 -67
- package/lib/assets/.claude/skills/operating-docs/SKILL.md +219 -219
- package/lib/assets/.claude/skills/operating-provision/SKILL.md +77 -77
- package/lib/assets/.claude/skills/operating-setup/SKILL.md +63 -63
- package/lib/assets/.claude/skills/orchestrating-analysis/SKILL.md +104 -104
- package/lib/assets/.claude/skills/orchestrating-development/SKILL.md +162 -161
- package/lib/assets/.claude/skills/orchestrating-operation/SKILL.md +158 -158
- package/lib/assets/.claude/skills/orchestrating-project/SKILL.md +144 -144
- package/lib/assets/.claude/skills/planning-releases/SKILL.md +119 -119
- package/lib/assets/.claude/skills/syncing-github-project/SKILL.md +151 -151
- package/lib/assets/.claude/skills/tracking-progress/SKILL.md +91 -91
- package/lib/assets/.claude/skills/validating-iteration-plan/SKILL.md +215 -215
- package/lib/assets/.devcontainer/devcontainer.json +34 -34
- package/lib/assets/.env.example +17 -17
- package/lib/assets/.gitattributes +4 -4
- package/lib/assets/.github/workflows/docker-publish.yml +77 -77
- package/lib/assets/.github/workflows/mkdocs.yml +39 -39
- package/lib/assets/AGENTS.md +94 -94
- package/lib/assets/CLAUDE.md +183 -183
- package/lib/assets/README.md +254 -254
- package/lib/assets/docker-compose.yml +33 -33
- package/lib/assets/docs/adr/index.md +10 -10
- package/lib/assets/docs/article/functional-desgin-ppp/all/01-immutability-and-data-transformation.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/all/02-function-composition.md +519 -519
- package/lib/assets/docs/article/functional-desgin-ppp/all/03-polymorphism.md +537 -537
- package/lib/assets/docs/article/functional-desgin-ppp/all/04-data-validation.md +300 -300
- package/lib/assets/docs/article/functional-desgin-ppp/all/05-property-based-testing.md +320 -320
- package/lib/assets/docs/article/functional-desgin-ppp/all/06-tdd-and-functional.md +498 -498
- package/lib/assets/docs/article/functional-desgin-ppp/all/07-composite-pattern.md +298 -298
- package/lib/assets/docs/article/functional-desgin-ppp/all/08-decorator-pattern.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/all/09-adapter-pattern.md +336 -336
- package/lib/assets/docs/article/functional-desgin-ppp/all/10-strategy-pattern.md +303 -303
- package/lib/assets/docs/article/functional-desgin-ppp/all/11-command-pattern.md +286 -286
- package/lib/assets/docs/article/functional-desgin-ppp/all/12-visitor-pattern.md +322 -322
- package/lib/assets/docs/article/functional-desgin-ppp/all/13-abstract-factory-pattern.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/all/14-abstract-server-pattern.md +365 -365
- package/lib/assets/docs/article/functional-desgin-ppp/all/15-gossiping-bus-drivers.md +156 -156
- package/lib/assets/docs/article/functional-desgin-ppp/all/16-payroll-system.md +178 -178
- package/lib/assets/docs/article/functional-desgin-ppp/all/17-video-rental-system.md +312 -312
- package/lib/assets/docs/article/functional-desgin-ppp/all/18-concurrency-system.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/all/19-wa-tor-simulation.md +286 -286
- package/lib/assets/docs/article/functional-desgin-ppp/all/20-pattern-interactions.md +274 -274
- package/lib/assets/docs/article/functional-desgin-ppp/all/21-best-practices.md +294 -294
- package/lib/assets/docs/article/functional-desgin-ppp/all/22-oo-to-fp-migration.md +337 -337
- package/lib/assets/docs/article/functional-desgin-ppp/all/index.md +388 -388
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/01-immutability-and-data-transformation.md +273 -273
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/02-function-composition.md +380 -380
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/03-polymorphism.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/04-clojure-spec.md +350 -350
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/05-property-based-testing.md +352 -352
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/06-tdd-in-functional.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/07-composite-pattern.md +529 -529
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/08-decorator-pattern.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/09-adapter-pattern.md +399 -399
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/10-strategy-pattern.md +485 -485
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/11-command-pattern.md +566 -566
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/12-visitor-pattern.md +567 -567
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/13-abstract-factory-pattern.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/14-abstract-server-pattern.md +462 -462
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/15-gossiping-bus-drivers.md +325 -325
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/16-payroll-system.md +401 -401
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/17-video-rental-system.md +450 -450
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/18-concurrency-system.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/19-wator-simulation.md +739 -739
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/20-pattern-interactions.md +567 -567
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/21-best-practices.md +518 -518
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/22-oo-to-fp-migration.md +532 -532
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/index.md +241 -241
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/01-immutability-and-data-transformation.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/02-function-composition.md +374 -374
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/03-polymorphism.md +375 -375
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/04-data-validation.md +195 -195
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/05-property-based-testing.md +268 -268
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/06-tdd-and-fp.md +294 -294
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/07-effects-and-pure-functions.md +164 -164
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/08-error-handling-strategies.md +168 -168
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/09-io-and-external-systems.md +254 -254
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/10-concurrency-patterns.md +269 -269
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/11-command-pattern.md +148 -148
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/12-visitor-pattern.md +176 -176
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/13-abstract-factory-pattern.md +604 -604
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/14-abstract-server-pattern.md +729 -729
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/15-gossiping-bus-drivers.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/16-payroll-system.md +420 -420
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/17-video-rental-system.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/18-concurrency-system.md +466 -466
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/19-wator-simulation.md +523 -523
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/20-pattern-interactions.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/21-best-practices.md +340 -340
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/22-oo-to-fp-migration.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/index.md +248 -248
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/01-immutability-and-data-transformation.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/02-function-composition.md +452 -452
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/03-polymorphism.md +495 -495
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/04-data-validation.md +416 -416
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/05-property-based-testing.md +382 -382
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/06-tdd-functional.md +687 -687
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/07-composite-pattern.md +442 -442
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/08-decorator-pattern.md +479 -479
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/09-adapter-pattern.md +479 -479
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/10-strategy-pattern.md +427 -427
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/11-command-pattern.md +428 -428
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/12-visitor-pattern.md +339 -339
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/13-abstract-factory-pattern.md +309 -309
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/14-abstract-server-pattern.md +596 -596
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/15-gossiping-bus-drivers.md +355 -355
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/16-payroll-system.md +350 -350
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/17-video-rental-system.md +414 -414
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/18-concurrency-system.md +367 -367
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/19-wator-simulation.md +403 -403
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/20-pattern-interactions.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/21-best-practices.md +324 -324
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/22-oo-to-fp-migration.md +332 -332
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/index.md +274 -274
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/01-immutability-and-data-transformation.md +298 -298
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/02-function-composition.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/03-polymorphism.md +362 -362
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/04-data-validation.md +257 -257
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/05-property-based-testing.md +254 -254
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/06-tdd-functional.md +283 -283
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/07-composite-pattern.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/08-decorator-pattern.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/09-adapter-pattern.md +382 -382
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/10-strategy-pattern.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/11-command-pattern.md +303 -303
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/12-visitor-pattern.md +326 -326
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/13-abstract-factory-pattern.md +332 -332
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/14-abstract-server-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/15-gossiping-bus-drivers.md +177 -177
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/16-payroll-system.md +219 -219
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/17-video-rental-system.md +244 -244
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/18-concurrency-system.md +363 -363
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/19-wator-simulation.md +438 -438
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/20-pattern-interactions.md +325 -325
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/21-best-practices.md +403 -403
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/22-oo-to-fp-migration.md +469 -469
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/index.md +174 -174
- package/lib/assets/docs/article/functional-desgin-ppp/index.md +90 -90
- package/lib/assets/docs/article/functional-desgin-ppp/rust/01-immutability-and-data-transformation.md +450 -450
- package/lib/assets/docs/article/functional-desgin-ppp/rust/02-function-composition.md +463 -463
- package/lib/assets/docs/article/functional-desgin-ppp/rust/03-polymorphism.md +425 -425
- package/lib/assets/docs/article/functional-desgin-ppp/rust/04-data-validation.md +273 -273
- package/lib/assets/docs/article/functional-desgin-ppp/rust/05-property-based-testing.md +247 -247
- package/lib/assets/docs/article/functional-desgin-ppp/rust/06-tdd-and-functional.md +841 -841
- package/lib/assets/docs/article/functional-desgin-ppp/rust/07-composite-pattern.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/rust/08-decorator-pattern.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/rust/09-adapter-pattern.md +339 -339
- package/lib/assets/docs/article/functional-desgin-ppp/rust/10-strategy-pattern.md +331 -331
- package/lib/assets/docs/article/functional-desgin-ppp/rust/11-command-pattern.md +356 -356
- package/lib/assets/docs/article/functional-desgin-ppp/rust/12-visitor-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/rust/13-abstract-factory-pattern.md +361 -361
- package/lib/assets/docs/article/functional-desgin-ppp/rust/14-abstract-server-pattern.md +392 -392
- package/lib/assets/docs/article/functional-desgin-ppp/rust/15-gossiping-bus-drivers.md +300 -300
- package/lib/assets/docs/article/functional-desgin-ppp/rust/16-payroll-system.md +297 -297
- package/lib/assets/docs/article/functional-desgin-ppp/rust/17-video-rental-system.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/rust/18-concurrency-system.md +315 -315
- package/lib/assets/docs/article/functional-desgin-ppp/rust/19-wator-simulation.md +311 -311
- package/lib/assets/docs/article/functional-desgin-ppp/rust/20-pattern-interactions.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/rust/21-best-practices.md +336 -336
- package/lib/assets/docs/article/functional-desgin-ppp/rust/22-oo-to-fp-migration.md +349 -349
- package/lib/assets/docs/article/functional-desgin-ppp/rust/index.md +243 -243
- package/lib/assets/docs/article/functional-desgin-ppp/scala/01-immutability-and-data-transformation.md +328 -328
- package/lib/assets/docs/article/functional-desgin-ppp/scala/02-function-composition.md +348 -348
- package/lib/assets/docs/article/functional-desgin-ppp/scala/03-polymorphism.md +357 -357
- package/lib/assets/docs/article/functional-desgin-ppp/scala/04-data-validation.md +364 -364
- package/lib/assets/docs/article/functional-desgin-ppp/scala/05-property-based-testing.md +515 -515
- package/lib/assets/docs/article/functional-desgin-ppp/scala/06-tdd-functional.md +557 -557
- package/lib/assets/docs/article/functional-desgin-ppp/scala/07-composite-pattern.md +363 -363
- package/lib/assets/docs/article/functional-desgin-ppp/scala/08-decorator-pattern.md +327 -327
- package/lib/assets/docs/article/functional-desgin-ppp/scala/09-adapter-pattern.md +517 -517
- package/lib/assets/docs/article/functional-desgin-ppp/scala/10-strategy-pattern.md +441 -441
- package/lib/assets/docs/article/functional-desgin-ppp/scala/11-command-pattern.md +407 -407
- package/lib/assets/docs/article/functional-desgin-ppp/scala/12-visitor-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/scala/13-abstract-factory-pattern.md +398 -398
- package/lib/assets/docs/article/functional-desgin-ppp/scala/14-abstract-server-pattern.md +476 -476
- package/lib/assets/docs/article/functional-desgin-ppp/scala/15-gossiping-bus-drivers.md +391 -391
- package/lib/assets/docs/article/functional-desgin-ppp/scala/16-payroll-system.md +342 -342
- package/lib/assets/docs/article/functional-desgin-ppp/scala/17-video-rental-system.md +324 -324
- package/lib/assets/docs/article/functional-desgin-ppp/scala/18-concurrency-system.md +730 -730
- package/lib/assets/docs/article/functional-desgin-ppp/scala/19-wator-simulation.md +624 -624
- package/lib/assets/docs/article/functional-desgin-ppp/scala/20-pattern-interactions.md +512 -512
- package/lib/assets/docs/article/functional-desgin-ppp/scala/21-best-practices.md +433 -433
- package/lib/assets/docs/article/functional-desgin-ppp/scala/22-oo-to-fp-migration.md +688 -688
- package/lib/assets/docs/article/functional-desgin-ppp/scala/index.md +243 -243
- package/lib/assets/docs/article/getting-start-tdd/clojure/01-todo-list-and-first-test.md +166 -166
- package/lib/assets/docs/article/getting-start-tdd/clojure/02-fake-it-and-triangulation.md +162 -162
- package/lib/assets/docs/article/getting-start-tdd/clojure/03-obvious-implementation-and-refactoring.md +135 -135
- package/lib/assets/docs/article/getting-start-tdd/clojure/04-version-control-and-conventional-commits.md +88 -88
- package/lib/assets/docs/article/getting-start-tdd/clojure/05-package-management-and-static-analysis.md +299 -299
- package/lib/assets/docs/article/getting-start-tdd/clojure/06-task-runner-and-ci-cd.md +241 -241
- package/lib/assets/docs/article/getting-start-tdd/clojure/07-protocols-and-records.md +131 -131
- package/lib/assets/docs/article/getting-start-tdd/clojure/08-multimethods-and-design-patterns.md +130 -130
- package/lib/assets/docs/article/getting-start-tdd/clojure/09-namespaces-and-module-design.md +127 -127
- package/lib/assets/docs/article/getting-start-tdd/clojure/10-higher-order-functions-and-composition.md +114 -114
- package/lib/assets/docs/article/getting-start-tdd/clojure/11-persistent-data-and-pipeline.md +138 -138
- package/lib/assets/docs/article/getting-start-tdd/clojure/12-error-handling-and-spec.md +161 -161
- package/lib/assets/docs/article/getting-start-tdd/clojure/index.md +65 -65
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter01.md +232 -232
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter02.md +244 -244
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter03.md +202 -202
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter04.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter05.md +256 -256
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter06.md +195 -195
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter07.md +214 -214
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter08.md +249 -249
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter09.md +174 -174
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter10.md +166 -166
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter11.md +192 -192
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter12.md +211 -211
- package/lib/assets/docs/article/getting-start-tdd/csharp/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/elixir/01-todo-list-and-first-test.md +87 -87
- package/lib/assets/docs/article/getting-start-tdd/elixir/02-fake-it-and-triangulation.md +95 -95
- package/lib/assets/docs/article/getting-start-tdd/elixir/03-obvious-implementation-and-refactoring.md +109 -109
- package/lib/assets/docs/article/getting-start-tdd/elixir/04-version-control-and-conventional-commits.md +96 -96
- package/lib/assets/docs/article/getting-start-tdd/elixir/05-package-management-and-static-analysis.md +88 -88
- package/lib/assets/docs/article/getting-start-tdd/elixir/06-task-runner-and-ci-cd.md +71 -71
- package/lib/assets/docs/article/getting-start-tdd/elixir/07-structs-and-protocols.md +110 -110
- package/lib/assets/docs/article/getting-start-tdd/elixir/08-pattern-matching-and-guards.md +108 -108
- package/lib/assets/docs/article/getting-start-tdd/elixir/09-module-design-and-behaviours.md +104 -104
- package/lib/assets/docs/article/getting-start-tdd/elixir/10-higher-order-functions-and-pipeline.md +178 -178
- package/lib/assets/docs/article/getting-start-tdd/elixir/11-stream-and-lazy-evaluation.md +142 -142
- package/lib/assets/docs/article/getting-start-tdd/elixir/12-error-handling-and-with.md +145 -145
- package/lib/assets/docs/article/getting-start-tdd/elixir/index.md +35 -35
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter01.md +202 -202
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter02.md +246 -246
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter03.md +218 -218
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter04.md +179 -179
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter05.md +267 -267
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter06.md +190 -190
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter07.md +161 -161
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter08.md +175 -175
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter09.md +222 -222
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter10.md +189 -189
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter11.md +212 -212
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter12.md +215 -215
- package/lib/assets/docs/article/getting-start-tdd/fsharp/index.md +71 -71
- package/lib/assets/docs/article/getting-start-tdd/go/01-todo-list-and-first-test.md +213 -213
- package/lib/assets/docs/article/getting-start-tdd/go/02-fake-it-and-triangulation.md +302 -302
- package/lib/assets/docs/article/getting-start-tdd/go/03-obvious-implementation-and-refactoring.md +339 -339
- package/lib/assets/docs/article/getting-start-tdd/go/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/go/05-package-management-and-static-analysis.md +272 -272
- package/lib/assets/docs/article/getting-start-tdd/go/06-task-runner-and-ci-cd.md +233 -233
- package/lib/assets/docs/article/getting-start-tdd/go/07-encapsulation-and-polymorphism.md +394 -394
- package/lib/assets/docs/article/getting-start-tdd/go/08-design-patterns.md +422 -422
- package/lib/assets/docs/article/getting-start-tdd/go/09-solid-principles-and-module-design.md +400 -400
- package/lib/assets/docs/article/getting-start-tdd/go/10-higher-order-functions-and-composition.md +226 -226
- package/lib/assets/docs/article/getting-start-tdd/go/11-immutable-data-and-pipeline.md +296 -296
- package/lib/assets/docs/article/getting-start-tdd/go/12-error-handling-and-type-safety.md +411 -411
- package/lib/assets/docs/article/getting-start-tdd/go/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/haskell/01-todo-list-and-first-test.md +279 -279
- package/lib/assets/docs/article/getting-start-tdd/haskell/02-fake-it-and-triangulation.md +337 -337
- package/lib/assets/docs/article/getting-start-tdd/haskell/03-obvious-implementation-and-refactoring.md +257 -257
- package/lib/assets/docs/article/getting-start-tdd/haskell/04-version-control-and-conventional-commits.md +182 -182
- package/lib/assets/docs/article/getting-start-tdd/haskell/05-package-management-and-static-analysis.md +313 -313
- package/lib/assets/docs/article/getting-start-tdd/haskell/06-task-runner-and-ci-cd.md +309 -309
- package/lib/assets/docs/article/getting-start-tdd/haskell/07-algebraic-data-types-and-type-classes.md +412 -412
- package/lib/assets/docs/article/getting-start-tdd/haskell/08-pattern-matching-and-guards.md +390 -390
- package/lib/assets/docs/article/getting-start-tdd/haskell/09-module-design-and-smart-constructors.md +461 -461
- package/lib/assets/docs/article/getting-start-tdd/haskell/10-higher-order-functions-and-currying.md +434 -434
- package/lib/assets/docs/article/getting-start-tdd/haskell/11-function-composition-and-point-free.md +392 -392
- package/lib/assets/docs/article/getting-start-tdd/haskell/12-monad-and-error-handling.md +631 -631
- package/lib/assets/docs/article/getting-start-tdd/haskell/index.md +49 -49
- package/lib/assets/docs/article/getting-start-tdd/index.md +93 -93
- package/lib/assets/docs/article/getting-start-tdd/integration/01-language-overview.md +375 -375
- package/lib/assets/docs/article/getting-start-tdd/integration/02-test-framework-comparison.md +349 -349
- package/lib/assets/docs/article/getting-start-tdd/integration/03-tdd-pattern-comparison.md +445 -445
- package/lib/assets/docs/article/getting-start-tdd/integration/04-type-system-comparison.md +409 -409
- package/lib/assets/docs/article/getting-start-tdd/integration/05-dev-environment-comparison.md +330 -330
- package/lib/assets/docs/article/getting-start-tdd/integration/06-learning-roadmap.md +290 -290
- package/lib/assets/docs/article/getting-start-tdd/integration/index.md +69 -69
- package/lib/assets/docs/article/getting-start-tdd/java/01-todo-list-and-first-test.md +234 -234
- package/lib/assets/docs/article/getting-start-tdd/java/02-fake-it-and-triangulation.md +261 -261
- package/lib/assets/docs/article/getting-start-tdd/java/03-obvious-implementation-and-refactoring.md +185 -185
- package/lib/assets/docs/article/getting-start-tdd/java/04-version-control-and-conventional-commits.md +115 -115
- package/lib/assets/docs/article/getting-start-tdd/java/05-package-management-and-static-analysis.md +382 -382
- package/lib/assets/docs/article/getting-start-tdd/java/06-task-runner-and-ci-cd.md +272 -272
- package/lib/assets/docs/article/getting-start-tdd/java/07-encapsulation-and-polymorphism.md +626 -626
- package/lib/assets/docs/article/getting-start-tdd/java/08-design-patterns.md +393 -393
- package/lib/assets/docs/article/getting-start-tdd/java/09-solid-principles-and-module-design.md +310 -310
- package/lib/assets/docs/article/getting-start-tdd/java/10-higher-order-functions-and-composition.md +188 -188
- package/lib/assets/docs/article/getting-start-tdd/java/11-immutable-data-and-pipeline.md +167 -167
- package/lib/assets/docs/article/getting-start-tdd/java/12-error-handling-and-type-safety.md +205 -205
- package/lib/assets/docs/article/getting-start-tdd/java/index.md +61 -61
- package/lib/assets/docs/article/getting-start-tdd/node/01-todo-list-and-first-test.md +244 -244
- package/lib/assets/docs/article/getting-start-tdd/node/02-fake-it-and-triangulation.md +262 -262
- package/lib/assets/docs/article/getting-start-tdd/node/03-obvious-implementation-and-refactoring.md +169 -169
- package/lib/assets/docs/article/getting-start-tdd/node/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/node/05-package-management-and-static-analysis.md +314 -314
- package/lib/assets/docs/article/getting-start-tdd/node/06-task-runner-and-ci-cd.md +235 -235
- package/lib/assets/docs/article/getting-start-tdd/node/07-encapsulation-and-polymorphism.md +327 -327
- package/lib/assets/docs/article/getting-start-tdd/node/08-design-patterns.md +322 -322
- package/lib/assets/docs/article/getting-start-tdd/node/09-solid-principles-and-module-design.md +285 -285
- package/lib/assets/docs/article/getting-start-tdd/node/10-higher-order-functions-and-composition.md +199 -199
- package/lib/assets/docs/article/getting-start-tdd/node/11-immutable-data-and-pipeline.md +207 -207
- package/lib/assets/docs/article/getting-start-tdd/node/12-error-handling-and-type-safety.md +295 -295
- package/lib/assets/docs/article/getting-start-tdd/node/index.md +56 -56
- package/lib/assets/docs/article/getting-start-tdd/php/01-todo-list-and-first-test.md +259 -259
- package/lib/assets/docs/article/getting-start-tdd/php/02-fake-it-and-triangulation.md +200 -200
- package/lib/assets/docs/article/getting-start-tdd/php/03-obvious-implementation-and-refactoring.md +248 -248
- package/lib/assets/docs/article/getting-start-tdd/php/04-version-control-and-conventional-commits.md +141 -141
- package/lib/assets/docs/article/getting-start-tdd/php/05-package-management-and-static-analysis.md +410 -410
- package/lib/assets/docs/article/getting-start-tdd/php/06-task-runner-and-ci-cd.md +321 -321
- package/lib/assets/docs/article/getting-start-tdd/php/07-encapsulation-and-polymorphism.md +372 -372
- package/lib/assets/docs/article/getting-start-tdd/php/08-design-patterns.md +453 -453
- package/lib/assets/docs/article/getting-start-tdd/php/09-solid-principles-and-module-design.md +460 -460
- package/lib/assets/docs/article/getting-start-tdd/php/10-higher-order-functions-and-composition.md +182 -182
- package/lib/assets/docs/article/getting-start-tdd/php/11-immutable-data-and-pipeline.md +266 -266
- package/lib/assets/docs/article/getting-start-tdd/php/12-error-handling-and-type-safety.md +308 -308
- package/lib/assets/docs/article/getting-start-tdd/php/index.md +84 -84
- package/lib/assets/docs/article/getting-start-tdd/python/01-todo-list-and-first-test.md +201 -201
- package/lib/assets/docs/article/getting-start-tdd/python/02-fake-it-and-triangulation.md +247 -247
- package/lib/assets/docs/article/getting-start-tdd/python/03-obvious-implementation-and-refactoring.md +199 -199
- package/lib/assets/docs/article/getting-start-tdd/python/04-version-control-and-conventional-commits.md +87 -87
- package/lib/assets/docs/article/getting-start-tdd/python/05-package-management-and-static-analysis.md +274 -274
- package/lib/assets/docs/article/getting-start-tdd/python/06-task-runner-and-ci-cd.md +190 -190
- package/lib/assets/docs/article/getting-start-tdd/python/07-encapsulation-and-polymorphism.md +208 -208
- package/lib/assets/docs/article/getting-start-tdd/python/08-design-patterns.md +172 -172
- package/lib/assets/docs/article/getting-start-tdd/python/09-solid-principles-and-module-design.md +130 -130
- package/lib/assets/docs/article/getting-start-tdd/python/10-higher-order-functions-and-composition.md +122 -122
- package/lib/assets/docs/article/getting-start-tdd/python/11-immutable-data-and-pipeline.md +116 -116
- package/lib/assets/docs/article/getting-start-tdd/python/12-error-handling-and-type-safety.md +126 -126
- package/lib/assets/docs/article/getting-start-tdd/python/index.md +55 -55
- package/lib/assets/docs/article/getting-start-tdd/ruby/01-todo-list-and-first-test.md +231 -231
- package/lib/assets/docs/article/getting-start-tdd/ruby/02-fake-it-and-triangulation.md +238 -238
- package/lib/assets/docs/article/getting-start-tdd/ruby/03-obvious-implementation-and-refactoring.md +228 -228
- package/lib/assets/docs/article/getting-start-tdd/ruby/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/ruby/05-package-management-and-static-analysis.md +287 -287
- package/lib/assets/docs/article/getting-start-tdd/ruby/06-task-runner-and-ci-cd.md +248 -248
- package/lib/assets/docs/article/getting-start-tdd/ruby/07-encapsulation-and-polymorphism.md +279 -279
- package/lib/assets/docs/article/getting-start-tdd/ruby/08-design-patterns.md +329 -329
- package/lib/assets/docs/article/getting-start-tdd/ruby/09-solid-principles-and-module-design.md +196 -196
- package/lib/assets/docs/article/getting-start-tdd/ruby/10-higher-order-functions-and-composition.md +175 -175
- package/lib/assets/docs/article/getting-start-tdd/ruby/11-immutable-data-and-pipeline.md +237 -237
- package/lib/assets/docs/article/getting-start-tdd/ruby/12-error-handling-and-type-safety.md +398 -398
- package/lib/assets/docs/article/getting-start-tdd/ruby/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/rust/01-todo-list-and-first-test.md +211 -211
- package/lib/assets/docs/article/getting-start-tdd/rust/02-fake-it-and-triangulation.md +264 -264
- package/lib/assets/docs/article/getting-start-tdd/rust/03-obvious-implementation-and-refactoring.md +233 -233
- package/lib/assets/docs/article/getting-start-tdd/rust/04-version-control-and-conventional-commits.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/rust/05-package-management-and-static-analysis.md +212 -212
- package/lib/assets/docs/article/getting-start-tdd/rust/06-task-runner-and-ci-cd.md +164 -164
- package/lib/assets/docs/article/getting-start-tdd/rust/07-encapsulation-and-polymorphism.md +142 -142
- package/lib/assets/docs/article/getting-start-tdd/rust/08-design-patterns.md +145 -145
- package/lib/assets/docs/article/getting-start-tdd/rust/09-solid-principles-and-module-design.md +110 -110
- package/lib/assets/docs/article/getting-start-tdd/rust/10-higher-order-functions-and-composition.md +94 -94
- package/lib/assets/docs/article/getting-start-tdd/rust/11-immutable-data-and-pipeline.md +105 -105
- package/lib/assets/docs/article/getting-start-tdd/rust/12-error-handling-and-type-safety.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/rust/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/scala/01-todo-list-and-first-test.md +111 -111
- package/lib/assets/docs/article/getting-start-tdd/scala/02-fake-it-and-triangulation.md +107 -107
- package/lib/assets/docs/article/getting-start-tdd/scala/03-obvious-implementation-and-refactoring.md +99 -99
- package/lib/assets/docs/article/getting-start-tdd/scala/04-version-control-and-conventional-commits.md +123 -123
- package/lib/assets/docs/article/getting-start-tdd/scala/05-package-management-and-static-analysis.md +196 -196
- package/lib/assets/docs/article/getting-start-tdd/scala/06-task-runner-and-ci-cd.md +186 -186
- package/lib/assets/docs/article/getting-start-tdd/scala/07-case-classes-and-traits.md +139 -139
- package/lib/assets/docs/article/getting-start-tdd/scala/08-pattern-matching-and-sealed-traits.md +106 -106
- package/lib/assets/docs/article/getting-start-tdd/scala/09-packages-and-module-design.md +75 -75
- package/lib/assets/docs/article/getting-start-tdd/scala/10-higher-order-functions-and-composition.md +104 -104
- package/lib/assets/docs/article/getting-start-tdd/scala/11-collections-and-lazy-evaluation.md +94 -94
- package/lib/assets/docs/article/getting-start-tdd/scala/12-error-handling-and-type-safety.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/scala/index.md +65 -65
- package/lib/assets/docs/article/grokking-concurrency/all/index.md +404 -404
- package/lib/assets/docs/article/grokking-concurrency/all/part-1-ch02-sequential.md +554 -554
- package/lib/assets/docs/article/grokking-concurrency/all/part-2-ch04-05-threads.md +469 -469
- package/lib/assets/docs/article/grokking-concurrency/all/part-3-ch06-multitasking.md +520 -520
- package/lib/assets/docs/article/grokking-concurrency/all/part-4-ch07-parallel-patterns.md +420 -420
- package/lib/assets/docs/article/grokking-concurrency/all/part-5-ch08-09-synchronization.md +510 -510
- package/lib/assets/docs/article/grokking-concurrency/all/part-6-ch10-11-nonblocking-io.md +435 -435
- package/lib/assets/docs/article/grokking-concurrency/all/part-7-ch12-async.md +465 -465
- package/lib/assets/docs/article/grokking-concurrency/all/part-8-ch13-mapreduce.md +377 -377
- package/lib/assets/docs/article/grokking-concurrency/clojure/index.md +116 -116
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-1.md +108 -108
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-2.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-3.md +122 -122
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-4.md +123 -123
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-5.md +118 -118
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-6.md +89 -89
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-7.md +100 -100
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-8.md +120 -120
- package/lib/assets/docs/article/grokking-concurrency/csharp/index.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-1.md +97 -97
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-2.md +123 -123
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-3.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-4.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-5.md +99 -99
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-6.md +61 -61
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-7.md +84 -84
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-8.md +92 -92
- package/lib/assets/docs/article/grokking-concurrency/fsharp/index.md +65 -65
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-1.md +80 -80
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-2.md +103 -103
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-3.md +94 -94
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-4.md +110 -110
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-5.md +104 -104
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-6.md +93 -93
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-7.md +121 -121
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-8.md +107 -107
- package/lib/assets/docs/article/grokking-concurrency/haskell/index.md +248 -248
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-1.md +96 -96
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-2.md +96 -96
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-3.md +91 -91
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-4.md +106 -106
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-5.md +99 -99
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-6.md +95 -95
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-7.md +111 -111
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-8.md +118 -118
- package/lib/assets/docs/article/grokking-concurrency/index.md +66 -66
- package/lib/assets/docs/article/grokking-concurrency/java/index.md +102 -102
- package/lib/assets/docs/article/grokking-concurrency/java/part-1.md +308 -308
- package/lib/assets/docs/article/grokking-concurrency/java/part-2.md +334 -334
- package/lib/assets/docs/article/grokking-concurrency/java/part-3.md +221 -221
- package/lib/assets/docs/article/grokking-concurrency/java/part-4.md +213 -213
- package/lib/assets/docs/article/grokking-concurrency/java/part-5.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/java/part-6.md +69 -69
- package/lib/assets/docs/article/grokking-concurrency/java/part-7.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/java/part-8.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/python/index.md +313 -313
- package/lib/assets/docs/article/grokking-concurrency/python/part-1.md +239 -239
- package/lib/assets/docs/article/grokking-concurrency/python/part-2.md +418 -418
- package/lib/assets/docs/article/grokking-concurrency/python/part-3.md +227 -227
- package/lib/assets/docs/article/grokking-concurrency/python/part-4.md +299 -299
- package/lib/assets/docs/article/grokking-concurrency/python/part-5.md +315 -315
- package/lib/assets/docs/article/grokking-concurrency/python/part-6.md +297 -297
- package/lib/assets/docs/article/grokking-concurrency/python/part-7.md +314 -314
- package/lib/assets/docs/article/grokking-concurrency/python/part-8.md +360 -360
- package/lib/assets/docs/article/grokking-concurrency/rust/index.md +270 -270
- package/lib/assets/docs/article/grokking-concurrency/rust/part-1.md +108 -108
- package/lib/assets/docs/article/grokking-concurrency/rust/part-2.md +120 -120
- package/lib/assets/docs/article/grokking-concurrency/rust/part-3.md +126 -126
- package/lib/assets/docs/article/grokking-concurrency/rust/part-4.md +175 -175
- package/lib/assets/docs/article/grokking-concurrency/rust/part-5.md +158 -158
- package/lib/assets/docs/article/grokking-concurrency/rust/part-6.md +94 -94
- package/lib/assets/docs/article/grokking-concurrency/rust/part-7.md +133 -133
- package/lib/assets/docs/article/grokking-concurrency/rust/part-8.md +155 -155
- package/lib/assets/docs/article/grokking-concurrency/scala/index.md +69 -69
- package/lib/assets/docs/article/grokking-concurrency/scala/part-1.md +78 -78
- package/lib/assets/docs/article/grokking-concurrency/scala/part-2.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/scala/part-3.md +93 -93
- package/lib/assets/docs/article/grokking-concurrency/scala/part-4.md +110 -110
- package/lib/assets/docs/article/grokking-concurrency/scala/part-5.md +119 -119
- package/lib/assets/docs/article/grokking-concurrency/scala/part-6.md +83 -83
- package/lib/assets/docs/article/grokking-concurrency/scala/part-7.md +131 -131
- package/lib/assets/docs/article/grokking-concurrency/scala/part-8.md +129 -129
- package/lib/assets/docs/article/grokkingfp/all/index.md +368 -368
- package/lib/assets/docs/article/grokkingfp/all/part-1-ch01-fp-introduction.md +530 -530
- package/lib/assets/docs/article/grokkingfp/all/part-1-ch02-pure-functions.md +923 -923
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch03-immutable-data.md +1128 -1128
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch04-higher-order-functions.md +1104 -1104
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch05-flatmap.md +1026 -1026
- package/lib/assets/docs/article/grokkingfp/all/part-3-ch06-option.md +785 -785
- package/lib/assets/docs/article/grokkingfp/all/part-3-ch07-either-adt.md +871 -871
- package/lib/assets/docs/article/grokkingfp/all/part-4-ch08-io-monad.md +972 -972
- package/lib/assets/docs/article/grokkingfp/all/part-4-ch09-streams.md +926 -926
- package/lib/assets/docs/article/grokkingfp/all/part-5-ch10-concurrency.md +870 -870
- package/lib/assets/docs/article/grokkingfp/all/part-6-ch11-application.md +715 -715
- package/lib/assets/docs/article/grokkingfp/all/part-6-ch12-testing.md +626 -626
- package/lib/assets/docs/article/grokkingfp/all/writing-plan.md +712 -712
- package/lib/assets/docs/article/grokkingfp/clojure/index.md +276 -276
- package/lib/assets/docs/article/grokkingfp/clojure/part-1.md +667 -667
- package/lib/assets/docs/article/grokkingfp/clojure/part-2.md +643 -643
- package/lib/assets/docs/article/grokkingfp/clojure/part-3.md +620 -620
- package/lib/assets/docs/article/grokkingfp/clojure/part-4.md +697 -697
- package/lib/assets/docs/article/grokkingfp/clojure/part-5.md +751 -751
- package/lib/assets/docs/article/grokkingfp/clojure/part-6.md +721 -721
- package/lib/assets/docs/article/grokkingfp/csharp/index.md +246 -246
- package/lib/assets/docs/article/grokkingfp/csharp/part-1.md +811 -811
- package/lib/assets/docs/article/grokkingfp/csharp/part-2.md +971 -971
- package/lib/assets/docs/article/grokkingfp/csharp/part-3.md +981 -981
- package/lib/assets/docs/article/grokkingfp/csharp/part-4.md +949 -949
- package/lib/assets/docs/article/grokkingfp/csharp/part-5.md +947 -947
- package/lib/assets/docs/article/grokkingfp/csharp/part-6.md +739 -739
- package/lib/assets/docs/article/grokkingfp/elixir/index.md +203 -203
- package/lib/assets/docs/article/grokkingfp/elixir/part-1.md +712 -712
- package/lib/assets/docs/article/grokkingfp/elixir/part-2.md +838 -838
- package/lib/assets/docs/article/grokkingfp/elixir/part-3.md +985 -985
- package/lib/assets/docs/article/grokkingfp/elixir/part-4.md +974 -974
- package/lib/assets/docs/article/grokkingfp/elixir/part-5.md +1286 -1286
- package/lib/assets/docs/article/grokkingfp/elixir/part-6.md +1049 -1049
- package/lib/assets/docs/article/grokkingfp/fsharp/index.md +210 -210
- package/lib/assets/docs/article/grokkingfp/fsharp/part-1.md +714 -714
- package/lib/assets/docs/article/grokkingfp/fsharp/part-2.md +961 -961
- package/lib/assets/docs/article/grokkingfp/fsharp/part-3.md +972 -972
- package/lib/assets/docs/article/grokkingfp/fsharp/part-4.md +832 -832
- package/lib/assets/docs/article/grokkingfp/fsharp/part-5.md +911 -911
- package/lib/assets/docs/article/grokkingfp/fsharp/part-6.md +922 -922
- package/lib/assets/docs/article/grokkingfp/haskell/index.md +234 -234
- package/lib/assets/docs/article/grokkingfp/haskell/part-1.md +591 -591
- package/lib/assets/docs/article/grokkingfp/haskell/part-2.md +866 -866
- package/lib/assets/docs/article/grokkingfp/haskell/part-3.md +915 -915
- package/lib/assets/docs/article/grokkingfp/haskell/part-4.md +878 -878
- package/lib/assets/docs/article/grokkingfp/haskell/part-5.md +845 -845
- package/lib/assets/docs/article/grokkingfp/haskell/part-6.md +844 -844
- package/lib/assets/docs/article/grokkingfp/index.md +143 -143
- package/lib/assets/docs/article/grokkingfp/java/index.md +211 -211
- package/lib/assets/docs/article/grokkingfp/java/part-1.md +648 -648
- package/lib/assets/docs/article/grokkingfp/java/part-2.md +675 -675
- package/lib/assets/docs/article/grokkingfp/java/part-3.md +672 -672
- package/lib/assets/docs/article/grokkingfp/java/part-4.md +771 -771
- package/lib/assets/docs/article/grokkingfp/java/part-5.md +959 -959
- package/lib/assets/docs/article/grokkingfp/java/part-6.md +1328 -1328
- package/lib/assets/docs/article/grokkingfp/python/index.md +258 -258
- package/lib/assets/docs/article/grokkingfp/python/part-1.md +443 -443
- package/lib/assets/docs/article/grokkingfp/python/part-2.md +958 -958
- package/lib/assets/docs/article/grokkingfp/python/part-3.md +1004 -1004
- package/lib/assets/docs/article/grokkingfp/python/part-4.md +765 -765
- package/lib/assets/docs/article/grokkingfp/python/part-5.md +747 -747
- package/lib/assets/docs/article/grokkingfp/python/part-6.md +861 -861
- package/lib/assets/docs/article/grokkingfp/ruby/index.md +330 -330
- package/lib/assets/docs/article/grokkingfp/ruby/part-1.md +755 -755
- package/lib/assets/docs/article/grokkingfp/ruby/part-2.md +938 -938
- package/lib/assets/docs/article/grokkingfp/ruby/part-3.md +946 -946
- package/lib/assets/docs/article/grokkingfp/ruby/part-4.md +921 -921
- package/lib/assets/docs/article/grokkingfp/ruby/part-5.md +908 -908
- package/lib/assets/docs/article/grokkingfp/ruby/part-6.md +1412 -1412
- package/lib/assets/docs/article/grokkingfp/rust/index.md +242 -242
- package/lib/assets/docs/article/grokkingfp/rust/part-1.md +634 -634
- package/lib/assets/docs/article/grokkingfp/rust/part-2.md +1060 -1060
- package/lib/assets/docs/article/grokkingfp/rust/part-3.md +994 -994
- package/lib/assets/docs/article/grokkingfp/rust/part-4.md +573 -573
- package/lib/assets/docs/article/grokkingfp/rust/part-5.md +705 -705
- package/lib/assets/docs/article/grokkingfp/rust/part-6.md +508 -508
- package/lib/assets/docs/article/grokkingfp/scala/index.md +171 -171
- package/lib/assets/docs/article/grokkingfp/scala/part-1.md +543 -543
- package/lib/assets/docs/article/grokkingfp/scala/part-2.md +946 -946
- package/lib/assets/docs/article/grokkingfp/scala/part-3.md +919 -919
- package/lib/assets/docs/article/grokkingfp/scala/part-4.md +742 -742
- package/lib/assets/docs/article/grokkingfp/scala/part-5.md +722 -722
- package/lib/assets/docs/article/grokkingfp/scala/part-6.md +867 -867
- package/lib/assets/docs/article/grokkingfp/typescript/index.md +273 -273
- package/lib/assets/docs/article/grokkingfp/typescript/part-1.md +561 -561
- package/lib/assets/docs/article/grokkingfp/typescript/part-2.md +1129 -1129
- package/lib/assets/docs/article/grokkingfp/typescript/part-3.md +842 -842
- package/lib/assets/docs/article/grokkingfp/typescript/part-4.md +1087 -1087
- package/lib/assets/docs/article/grokkingfp/typescript/part-5.md +717 -717
- package/lib/assets/docs/article/grokkingfp/typescript/part-6.md +982 -982
- package/lib/assets/docs/article/practical-database-design/index.md +121 -121
- package/lib/assets/docs/article/practical-database-design/part1/chapter01.md +288 -288
- package/lib/assets/docs/article/practical-database-design/part1/chapter02.md +518 -518
- package/lib/assets/docs/article/practical-database-design/part1/chapter03.md +557 -557
- package/lib/assets/docs/article/practical-database-design/part2/chapter04.md +924 -924
- package/lib/assets/docs/article/practical-database-design/part2/chapter05.md +1627 -1627
- package/lib/assets/docs/article/practical-database-design/part2/chapter06.md +2716 -2716
- package/lib/assets/docs/article/practical-database-design/part2/chapter07.md +2082 -2082
- package/lib/assets/docs/article/practical-database-design/part2/chapter08.md +2105 -2105
- package/lib/assets/docs/article/practical-database-design/part2/chapter09.md +2031 -2031
- package/lib/assets/docs/article/practical-database-design/part2/chapter10.md +1387 -1387
- package/lib/assets/docs/article/practical-database-design/part2/chapter11.md +1677 -1677
- package/lib/assets/docs/article/practical-database-design/part2/chapter12.md +1417 -1417
- package/lib/assets/docs/article/practical-database-design/part2/chapter13.md +1434 -1434
- package/lib/assets/docs/article/practical-database-design/part3/chapter14.md +667 -667
- package/lib/assets/docs/article/practical-database-design/part3/chapter15.md +1625 -1625
- package/lib/assets/docs/article/practical-database-design/part3/chapter16.md +1915 -1915
- package/lib/assets/docs/article/practical-database-design/part3/chapter17.md +1708 -1708
- package/lib/assets/docs/article/practical-database-design/part3/chapter18.md +2095 -2095
- package/lib/assets/docs/article/practical-database-design/part3/chapter19.md +1123 -1123
- package/lib/assets/docs/article/practical-database-design/part3/chapter20.md +1031 -1031
- package/lib/assets/docs/article/practical-database-design/part3/chapter21.md +1382 -1382
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter14-orm.md +991 -991
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter15-orm.md +1300 -1300
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter16-orm.md +1166 -1166
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter17-orm.md +1584 -1584
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter18-orm.md +1183 -1183
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter19-orm.md +1016 -1016
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter20-orm.md +1753 -1753
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter21-orm.md +1447 -1447
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter22-orm.md +1878 -1878
- package/lib/assets/docs/article/practical-database-design/part4/chapter22.md +965 -965
- package/lib/assets/docs/article/practical-database-design/part4/chapter23.md +2069 -2069
- package/lib/assets/docs/article/practical-database-design/part4/chapter24.md +2439 -2439
- package/lib/assets/docs/article/practical-database-design/part4/chapter25.md +3661 -3661
- package/lib/assets/docs/article/practical-database-design/part4/chapter26.md +2916 -2916
- package/lib/assets/docs/article/practical-database-design/part4/chapter27.md +3105 -3105
- package/lib/assets/docs/article/practical-database-design/part4/chapter28.md +2697 -2697
- package/lib/assets/docs/article/practical-database-design/part4/chapter29.md +2544 -2544
- package/lib/assets/docs/article/practical-database-design/part4/chapter30.md +2180 -2180
- package/lib/assets/docs/article/practical-database-design/part4/chapter31.md +1192 -1192
- package/lib/assets/docs/article/practical-database-design/part4/chapter32.md +2101 -2101
- package/lib/assets/docs/article/practical-database-design/part5/chapter33.md +1032 -1032
- package/lib/assets/docs/article/practical-database-design/part5/chapter34.md +1609 -1609
- package/lib/assets/docs/article/practical-database-design/part5/chapter35.md +1453 -1453
- package/lib/assets/docs/article/practical-database-design/part5/chapter36.md +1292 -1292
- package/lib/assets/docs/article/practical-database-design/part5/chapter37.md +1470 -1470
- package/lib/assets/docs/article/practical-database-design/part5/chapter38.md +1698 -1698
- package/lib/assets/docs/article/practical-database-design/part5/chapter39.md +2334 -2334
- package/lib/assets/docs/article/practical-database-design/study/study2-1.md +1693 -1693
- package/lib/assets/docs/article/practical-database-design/study/study2-2.md +1347 -1347
- package/lib/assets/docs/article/practical-database-design/study/study2-3.md +2044 -2044
- package/lib/assets/docs/article/practical-database-design/study/study2-4.md +2229 -2229
- package/lib/assets/docs/article/practical-database-design/study/study2-5.md +2418 -2418
- package/lib/assets/docs/article/practical-database-design/study/study3-1.md +2205 -2205
- package/lib/assets/docs/article/practical-database-design/study/study3-2.md +2221 -2221
- package/lib/assets/docs/article/practical-database-design/study/study3-3.md +2253 -2253
- package/lib/assets/docs/article/practical-database-design/study/study3-4.md +2106 -2106
- package/lib/assets/docs/article/practical-database-design/study/study3-5.md +2507 -2507
- package/lib/assets/docs/article/practical-database-design/study/study4-1.md +2587 -2587
- package/lib/assets/docs/article/practical-database-design/study/study4-2.md +2075 -2075
- package/lib/assets/docs/article/practical-database-design/study/study4-3.md +1805 -1805
- package/lib/assets/docs/article/practical-database-design/study/study4-4.md +1895 -1895
- package/lib/assets/docs/article/practical-database-design/study/study4-5.md +2878 -2878
- package/lib/assets/docs/assets/css/extra.css +29 -29
- package/lib/assets/docs/assets/js/extra.js +44 -44
- package/lib/assets/docs/development/index.md +39 -39
- package/lib/assets/docs/operation/index.md +11 -11
- package/lib/assets/docs/reference/CodexCLIMCP/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/343/203/225/343/203/255/343/203/274.md +532 -532
- package/lib/assets/docs/reference/CodexCLIMCP/343/202/265/343/203/274/343/203/220/343/203/274/350/250/255/345/256/232/346/211/213/351/240/206.md +341 -341
- package/lib/assets/docs/reference/Java/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +581 -580
- package/lib/assets/docs/reference/SonarQube/343/203/255/343/203/274/343/202/253/343/203/253/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +642 -642
- package/lib/assets/docs/reference/TypeScript/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +465 -465
- package/lib/assets/docs/reference/UI/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +450 -450
- package/lib/assets/docs/reference/images/Ansoff.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandBasicStrategy.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandCategorization.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandRecurutementStrategy.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandValue.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BusinessActivitiy.svg +3 -3
- package/lib/assets/docs/reference/images/HRM.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/MarketingStructure.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/OrganizationElemnts.svg +3 -3
- package/lib/assets/docs/reference/images/PPM.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/PositioningMap.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ProductLayer.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ProductMix.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/SWOT.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/TargetMarket.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ThreeGenericStrategies.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/VRIO.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ValueChain.drawio.svg +3 -3
- package/lib/assets/docs/reference/index.md +52 -52
- package/lib/assets/docs/reference//343/202/210/343/201/204/343/202/275/343/203/225/343/203/210/343/202/246/343/202/247/343/202/242/343/201/250/343/201/257.md +250 -242
- package/lib/assets/docs/reference//343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +2216 -2216
- package/lib/assets/docs/reference//343/202/244/343/203/263/343/203/225/343/203/251/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +1878 -1878
- package/lib/assets/docs/reference//343/202/250/343/202/257/343/202/271/343/203/210/343/203/252/343/203/274/343/203/240/343/203/227/343/203/255/343/202/260/343/203/251/343/203/237/343/203/263/343/202/260.md +550 -544
- package/lib/assets/docs/reference//343/202/263/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/343/201/250/343/203/206/343/202/271/343/203/210/343/202/254/343/202/244/343/203/211.md +705 -705
- package/lib/assets/docs/reference//343/203/206/343/202/271/343/203/210/346/210/246/347/225/245/343/202/254/343/202/244/343/203/211.md +1313 -1313
- package/lib/assets/docs/reference//343/203/207/343/203/274/343/202/277/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +311 -311
- package/lib/assets/docs/reference//343/203/211/343/203/241/343/202/244/343/203/263/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +599 -599
- package/lib/assets/docs/reference//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/345/210/206/346/236/220/343/202/254/343/202/244/343/203/211.md +528 -528
- package/lib/assets/docs/reference//343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +689 -682
- package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/202/254/343/202/244/343/203/211.md +461 -461
- package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/203/273/343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/350/250/210/347/224/273/343/202/254/343/202/244/343/203/211.md +580 -560
- package/lib/assets/docs/reference//343/203/255/343/202/270/343/202/253/343/203/253/343/202/267/343/203/263/343/202/255/343/203/263/343/202/260.md +1367 -1367
- package/lib/assets/docs/reference//344/274/201/346/245/255/347/265/214/345/226/266/350/253/226.md +2637 -2636
- package/lib/assets/docs/reference//347/222/260/345/242/203/345/244/211/346/225/260/347/256/241/347/220/206/343/202/254/343/202/244/343/203/211.md +665 -663
- package/lib/assets/docs/reference//350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1248 -1248
- package/lib/assets/docs/reference//350/250/200/350/252/236/345/210/245/351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +28 -0
- package/lib/assets/docs/reference//351/201/213/345/226/266/347/256/241/347/220/206.md +1482 -1482
- package/lib/assets/docs/reference//351/201/213/347/224/250/343/202/271/343/202/257/343/203/252/343/203/227/343/203/210/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +421 -421
- package/lib/assets/docs/reference//351/201/213/347/224/250/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +392 -392
- package/lib/assets/docs/reference//351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +299 -299
- package/lib/assets/docs/reference//351/235/236/346/251/237/350/203/275/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1236 -1236
- package/lib/assets/docs/review/index.md +5 -5
- package/lib/assets/docs/strategy/index.md +1 -1
- package/lib/assets/docs/template/ADR.md +30 -30
- package/lib/assets/docs/template/AWS/343/202/271/343/203/206/343/203/274/343/202/270/343/203/263/343/202/260/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +1366 -1366
- package/lib/assets/docs/template/AWS/343/203/227/343/203/255/343/203/200/343/202/257/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +634 -634
- package/lib/assets/docs/template/README.md +50 -50
- package/lib/assets/docs/template/index.md +23 -23
- package/lib/assets/docs/template//343/201/276/343/201/232/343/201/223/343/202/214/343/202/222/350/252/255/343/202/202/343/201/206/343/203/252/343/202/271/343/203/210.md +12 -12
- package/lib/assets/docs/template//343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +547 -547
- package/lib/assets/docs/template//343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/345/256/214/344/272/206/345/240/261/345/221/212/346/233/270.md +58 -58
- package/lib/assets/docs/template//343/202/244/343/203/263/343/202/273/343/203/227/343/202/267/343/203/247/343/203/263/343/203/207/343/203/203/343/202/255.md +13 -13
- package/lib/assets/docs/template//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243.md +379 -379
- package/lib/assets/docs/template//344/274/201/346/245/255/345/210/206/346/236/220.md +573 -573
- package/lib/assets/docs/template//345/256/214/345/205/250/345/275/242/345/274/217/343/201/256/343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271.md +69 -68
- package/lib/assets/docs/template//350/246/201/344/273/266/345/256/232/347/276/251.md +669 -669
- package/lib/assets/docs/template//350/250/255/350/250/210.md +173 -173
- package/lib/assets/docs/template//351/226/213/347/231/272/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +688 -688
- package/lib/assets/gulpfile.js +25 -25
- package/lib/assets/mkdocs.yml +136 -135
- package/lib/assets/ops/docker/mkdoc/Dockerfile +19 -19
- package/lib/assets/ops/scripts/journal.js +180 -180
- package/lib/assets/ops/scripts/mkdocs.js +82 -82
- package/lib/assets/ops/scripts/release.js +431 -431
- package/lib/assets/ops/scripts/sonar_local.js +726 -726
- package/lib/assets/ops/scripts/ssh.js +190 -190
- package/lib/assets/ops/scripts/vault.js +299 -299
- package/lib/assets/package-lock.json +1653 -1653
- package/lib/assets/package.json +40 -40
- package/lib/gulpfile.js +37 -37
- package/package.json +41 -41
- package/lib/assets/.claude/agent-memory/xp-programmer/MEMORY.md +0 -6
- package/lib/assets/.claude/agent-memory/xp-programmer/project_cargo_tracker.md +0 -11
- package/lib/assets/.claude/agent-memory/xp-programmer/project_ddd_patterns.md +0 -27
- package/lib/assets/.claude/agent-memory/xp-programmer/project_us07_route_assignment.md +0 -19
|
@@ -1,1753 +1,1753 @@
|
|
|
1
|
-
# 第20章:財務会計データ設計(D社事例)【ORM版】
|
|
2
|
-
|
|
3
|
-
本章では、化粧品製造販売会社D社を題材として、Spring Data JPA を使用した財務会計システムのデータ設計と Seed データ実装を解説します。JPA の CascadeType.ALL によるカスケード保存や、CommandLineRunner による起動時データ投入を活用します。
|
|
4
|
-
|
|
5
|
-
## 20.1 D社の概要
|
|
6
|
-
|
|
7
|
-
### 20.1.1 会社プロファイル
|
|
8
|
-
|
|
9
|
-
D社は化粧品製造販売を主業とする中堅企業です。
|
|
10
|
-
|
|
11
|
-
| 項目 | 内容 |
|
|
12
|
-
|------|------|
|
|
13
|
-
| 業種 | 化粧品製造販売 |
|
|
14
|
-
| 資本金 | 5億円 |
|
|
15
|
-
| 従業員数 | 300名 |
|
|
16
|
-
| 年間売上高 | 80億円 |
|
|
17
|
-
| 決算期 | 3月 |
|
|
18
|
-
| 経理体制 | 経理部10名、財務課3名 |
|
|
19
|
-
|
|
20
|
-
### 20.1.2 企業概要
|
|
21
|
-
|
|
22
|
-
```plantuml
|
|
23
|
-
@startuml
|
|
24
|
-
title D社 企業概要
|
|
25
|
-
|
|
26
|
-
left to right direction
|
|
27
|
-
|
|
28
|
-
rectangle "D社(化粧品製造販売)" as company {
|
|
29
|
-
|
|
30
|
-
card info [
|
|
31
|
-
**基本情報**
|
|
32
|
-
----
|
|
33
|
-
資本金: 5億円
|
|
34
|
-
従業員: 300名
|
|
35
|
-
売上高: 80億円/年
|
|
36
|
-
決算期: 3月
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
card business [
|
|
40
|
-
**事業内容**
|
|
41
|
-
----
|
|
42
|
-
スキンケア製品製造
|
|
43
|
-
メイクアップ製品製造
|
|
44
|
-
OEM/ODM受託製造
|
|
45
|
-
直営店舗運営
|
|
46
|
-
EC販売
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
card feature [
|
|
50
|
-
**特徴**
|
|
51
|
-
----
|
|
52
|
-
原価管理重視
|
|
53
|
-
部門別損益管理
|
|
54
|
-
プロジェクト別収益管理
|
|
55
|
-
消費税複数税率対応
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@enduml
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## 20.2 組織構成
|
|
63
|
-
|
|
64
|
-
### 20.2.1 組織図
|
|
65
|
-
|
|
66
|
-
```plantuml
|
|
67
|
-
@startwbs
|
|
68
|
-
|
|
69
|
-
title D社 組織図
|
|
70
|
-
|
|
71
|
-
* 代表取締役
|
|
72
|
-
** 営業本部
|
|
73
|
-
*** 国内営業部
|
|
74
|
-
**** 東日本営業課
|
|
75
|
-
**** 西日本営業課
|
|
76
|
-
*** 海外営業部
|
|
77
|
-
**** 北米課
|
|
78
|
-
**** アジア課
|
|
79
|
-
*** EC事業部
|
|
80
|
-
**** 自社EC課
|
|
81
|
-
**** モール課
|
|
82
|
-
** 製造本部
|
|
83
|
-
*** 製造部
|
|
84
|
-
**** 第一製造課
|
|
85
|
-
**** 第二製造課
|
|
86
|
-
*** 品質管理部
|
|
87
|
-
**** 品質保証課
|
|
88
|
-
**** 検査課
|
|
89
|
-
*** 研究開発部
|
|
90
|
-
**** 基礎研究課
|
|
91
|
-
**** 応用開発課
|
|
92
|
-
** 管理本部
|
|
93
|
-
*** 経理部
|
|
94
|
-
**** 財務課
|
|
95
|
-
**** 主計課
|
|
96
|
-
**** 税務課
|
|
97
|
-
*** 総務部
|
|
98
|
-
**** 人事課
|
|
99
|
-
**** 庶務課
|
|
100
|
-
*** 情報システム部
|
|
101
|
-
|
|
102
|
-
@endwbs
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### 20.2.2 部門コード体系
|
|
106
|
-
|
|
107
|
-
| 部門コード | 部門名 | 組織階層 | 部門パス |
|
|
108
|
-
|-----------|--------|----------|----------|
|
|
109
|
-
| 10000 | 全社 | 0 | 10000 |
|
|
110
|
-
| 11000 | 営業本部 | 1 | 10000~11000 |
|
|
111
|
-
| 11100 | 国内営業部 | 2 | 10000~11000~11100 |
|
|
112
|
-
| 11110 | 東日本営業課 | 3 | 10000~11000~11100~11110 |
|
|
113
|
-
| 11120 | 西日本営業課 | 3 | 10000~11000~11100~11120 |
|
|
114
|
-
| 12000 | 製造本部 | 1 | 10000~12000 |
|
|
115
|
-
| 12100 | 製造部 | 2 | 10000~12000~12100 |
|
|
116
|
-
| 13000 | 管理本部 | 1 | 10000~13000 |
|
|
117
|
-
| 13100 | 経理部 | 2 | 10000~13000~13100 |
|
|
118
|
-
|
|
119
|
-
### 20.2.3 部門エンティティ(JPA)
|
|
120
|
-
|
|
121
|
-
<details>
|
|
122
|
-
<summary>Department エンティティ</summary>
|
|
123
|
-
|
|
124
|
-
```java
|
|
125
|
-
// src/main/java/com/example/accounting/domain/model/department/Department.java
|
|
126
|
-
package com.example.accounting.domain.model.department;
|
|
127
|
-
|
|
128
|
-
import jakarta.persistence.*;
|
|
129
|
-
import lombok.*;
|
|
130
|
-
|
|
131
|
-
import java.time.LocalDateTime;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* 部門エンティティ
|
|
135
|
-
*/
|
|
136
|
-
@Entity
|
|
137
|
-
@Table(name = "部門マスタ")
|
|
138
|
-
@Data
|
|
139
|
-
@Builder
|
|
140
|
-
@NoArgsConstructor
|
|
141
|
-
@AllArgsConstructor
|
|
142
|
-
public class Department {
|
|
143
|
-
|
|
144
|
-
@Id
|
|
145
|
-
@Column(name = "部門コード", length = 5)
|
|
146
|
-
private String departmentCode;
|
|
147
|
-
|
|
148
|
-
@Column(name = "部門名", length = 40, nullable = false)
|
|
149
|
-
private String departmentName;
|
|
150
|
-
|
|
151
|
-
@Column(name = "組織階層")
|
|
152
|
-
private Integer organizationLevel;
|
|
153
|
-
|
|
154
|
-
@Column(name = "部門パス", length = 100)
|
|
155
|
-
private String departmentPath;
|
|
156
|
-
|
|
157
|
-
@Column(name = "最下層区分")
|
|
158
|
-
private Integer lowestLevelFlag;
|
|
159
|
-
|
|
160
|
-
@Column(name = "作成日時")
|
|
161
|
-
private LocalDateTime createdAt;
|
|
162
|
-
|
|
163
|
-
@Column(name = "更新日時")
|
|
164
|
-
private LocalDateTime updatedAt;
|
|
165
|
-
|
|
166
|
-
@Column(name = "更新者名", length = 20)
|
|
167
|
-
private String updatedBy;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* 最下層(末端)部門かどうか
|
|
171
|
-
*/
|
|
172
|
-
public boolean isLeaf() {
|
|
173
|
-
return lowestLevelFlag != null && lowestLevelFlag == 1;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* 部門パスから親部門コードを取得
|
|
178
|
-
*/
|
|
179
|
-
public String getParentDepartmentCode() {
|
|
180
|
-
if (departmentPath == null || !departmentPath.contains("~")) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
String[] parts = departmentPath.split("~");
|
|
184
|
-
if (parts.length < 2) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
return parts[parts.length - 2];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
@PrePersist
|
|
191
|
-
protected void onCreate() {
|
|
192
|
-
if (createdAt == null) {
|
|
193
|
-
createdAt = LocalDateTime.now();
|
|
194
|
-
}
|
|
195
|
-
if (updatedAt == null) {
|
|
196
|
-
updatedAt = LocalDateTime.now();
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
@PreUpdate
|
|
201
|
-
protected void onUpdate() {
|
|
202
|
-
updatedAt = LocalDateTime.now();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
</details>
|
|
208
|
-
|
|
209
|
-
### 20.2.4 部門リポジトリ(JPA)
|
|
210
|
-
|
|
211
|
-
<details>
|
|
212
|
-
<summary>DepartmentJpaRepository インターフェース</summary>
|
|
213
|
-
|
|
214
|
-
```java
|
|
215
|
-
// src/main/java/com/example/accounting/infrastructure/persistence/repository/DepartmentJpaRepository.java
|
|
216
|
-
package com.example.accounting.infrastructure.persistence.repository;
|
|
217
|
-
|
|
218
|
-
import com.example.accounting.domain.model.department.Department;
|
|
219
|
-
import org.springframework.data.jpa.repository.JpaRepository;
|
|
220
|
-
import org.springframework.data.jpa.repository.Query;
|
|
221
|
-
import org.springframework.data.repository.query.Param;
|
|
222
|
-
import org.springframework.stereotype.Repository;
|
|
223
|
-
|
|
224
|
-
import java.util.List;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* 部門リポジトリ(Spring Data JPA)
|
|
228
|
-
*/
|
|
229
|
-
@Repository
|
|
230
|
-
public interface DepartmentJpaRepository extends JpaRepository<Department, String> {
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* 組織階層で検索する
|
|
234
|
-
*/
|
|
235
|
-
List<Department> findByOrganizationLevel(Integer level);
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* 部門パスで前方一致検索する(配下の部門を取得)
|
|
239
|
-
*/
|
|
240
|
-
@Query("SELECT d FROM Department d WHERE d.departmentPath LIKE CONCAT(:pathPrefix, '%') ORDER BY d.departmentPath")
|
|
241
|
-
List<Department> findByDepartmentPathStartsWith(@Param("pathPrefix") String pathPrefix);
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* 最下層部門のみ検索する
|
|
245
|
-
*/
|
|
246
|
-
List<Department> findByLowestLevelFlag(Integer flag);
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* 最下層部門のみ検索する(便利メソッド)
|
|
250
|
-
*/
|
|
251
|
-
default List<Department> findLeafDepartments() {
|
|
252
|
-
return findByLowestLevelFlag(1);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* 部門コード順で全件取得
|
|
257
|
-
*/
|
|
258
|
-
List<Department> findAllByOrderByDepartmentCodeAsc();
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
</details>
|
|
263
|
-
|
|
264
|
-
### 20.2.5 部門リポジトリのテスト(JPA)
|
|
265
|
-
|
|
266
|
-
<details>
|
|
267
|
-
<summary>DepartmentJpaRepositoryTest</summary>
|
|
268
|
-
|
|
269
|
-
```java
|
|
270
|
-
// src/test/java/com/example/accounting/infrastructure/persistence/repository/DepartmentJpaRepositoryTest.java
|
|
271
|
-
package com.example.accounting.infrastructure.persistence.repository;
|
|
272
|
-
|
|
273
|
-
import com.example.accounting.domain.model.department.Department;
|
|
274
|
-
import org.junit.jupiter.api.*;
|
|
275
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
276
|
-
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
|
277
|
-
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
278
|
-
import org.springframework.test.context.DynamicPropertySource;
|
|
279
|
-
import org.testcontainers.containers.PostgreSQLContainer;
|
|
280
|
-
import org.testcontainers.junit.jupiter.Container;
|
|
281
|
-
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
282
|
-
|
|
283
|
-
import static org.assertj.core.api.Assertions.*;
|
|
284
|
-
|
|
285
|
-
@DataJpaTest
|
|
286
|
-
@Testcontainers
|
|
287
|
-
@DisplayName("部門リポジトリ(JPA)")
|
|
288
|
-
class DepartmentJpaRepositoryTest {
|
|
289
|
-
|
|
290
|
-
@Container
|
|
291
|
-
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16")
|
|
292
|
-
.withDatabaseName("testdb")
|
|
293
|
-
.withUsername("testuser")
|
|
294
|
-
.withPassword("testpass");
|
|
295
|
-
|
|
296
|
-
@DynamicPropertySource
|
|
297
|
-
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
298
|
-
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
299
|
-
registry.add("spring.datasource.username", postgres::getUsername);
|
|
300
|
-
registry.add("spring.datasource.password", postgres::getPassword);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
@Autowired
|
|
304
|
-
private DepartmentJpaRepository departmentRepository;
|
|
305
|
-
|
|
306
|
-
@BeforeEach
|
|
307
|
-
void setUp() {
|
|
308
|
-
departmentRepository.deleteAll();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
@Nested
|
|
312
|
-
@DisplayName("登録")
|
|
313
|
-
class Insert {
|
|
314
|
-
|
|
315
|
-
@Test
|
|
316
|
-
@DisplayName("部門を登録できる")
|
|
317
|
-
void canInsertDepartment() {
|
|
318
|
-
// Arrange
|
|
319
|
-
var department = Department.builder()
|
|
320
|
-
.departmentCode("10000")
|
|
321
|
-
.departmentName("全社")
|
|
322
|
-
.organizationLevel(0)
|
|
323
|
-
.departmentPath("10000")
|
|
324
|
-
.lowestLevelFlag(0)
|
|
325
|
-
.build();
|
|
326
|
-
|
|
327
|
-
// Act
|
|
328
|
-
departmentRepository.save(department);
|
|
329
|
-
|
|
330
|
-
// Assert
|
|
331
|
-
var result = departmentRepository.findById("10000");
|
|
332
|
-
assertThat(result).isPresent();
|
|
333
|
-
assertThat(result.get().getDepartmentName()).isEqualTo("全社");
|
|
334
|
-
assertThat(result.get().getOrganizationLevel()).isEqualTo(0);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
@Test
|
|
338
|
-
@DisplayName("階層構造を持つ部門を登録できる")
|
|
339
|
-
void canInsertHierarchicalDepartments() {
|
|
340
|
-
// Arrange & Act
|
|
341
|
-
departmentRepository.save(Department.builder()
|
|
342
|
-
.departmentCode("10000")
|
|
343
|
-
.departmentName("全社")
|
|
344
|
-
.organizationLevel(0)
|
|
345
|
-
.departmentPath("10000")
|
|
346
|
-
.lowestLevelFlag(0)
|
|
347
|
-
.build());
|
|
348
|
-
|
|
349
|
-
departmentRepository.save(Department.builder()
|
|
350
|
-
.departmentCode("11000")
|
|
351
|
-
.departmentName("営業本部")
|
|
352
|
-
.organizationLevel(1)
|
|
353
|
-
.departmentPath("10000~11000")
|
|
354
|
-
.lowestLevelFlag(0)
|
|
355
|
-
.build());
|
|
356
|
-
|
|
357
|
-
departmentRepository.save(Department.builder()
|
|
358
|
-
.departmentCode("11110")
|
|
359
|
-
.departmentName("東日本営業課")
|
|
360
|
-
.organizationLevel(3)
|
|
361
|
-
.departmentPath("10000~11000~11100~11110")
|
|
362
|
-
.lowestLevelFlag(1)
|
|
363
|
-
.build());
|
|
364
|
-
|
|
365
|
-
// Assert
|
|
366
|
-
var result = departmentRepository.findById("11110");
|
|
367
|
-
assertThat(result).isPresent();
|
|
368
|
-
assertThat(result.get().getDepartmentPath()).isEqualTo("10000~11000~11100~11110");
|
|
369
|
-
assertThat(result.get().isLeaf()).isTrue();
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
@Nested
|
|
374
|
-
@DisplayName("検索")
|
|
375
|
-
class Search {
|
|
376
|
-
|
|
377
|
-
@BeforeEach
|
|
378
|
-
void setUpTestData() {
|
|
379
|
-
departmentRepository.save(Department.builder()
|
|
380
|
-
.departmentCode("10000")
|
|
381
|
-
.departmentName("全社")
|
|
382
|
-
.organizationLevel(0)
|
|
383
|
-
.departmentPath("10000")
|
|
384
|
-
.lowestLevelFlag(0)
|
|
385
|
-
.build());
|
|
386
|
-
|
|
387
|
-
departmentRepository.save(Department.builder()
|
|
388
|
-
.departmentCode("11000")
|
|
389
|
-
.departmentName("営業本部")
|
|
390
|
-
.organizationLevel(1)
|
|
391
|
-
.departmentPath("10000~11000")
|
|
392
|
-
.lowestLevelFlag(0)
|
|
393
|
-
.build());
|
|
394
|
-
|
|
395
|
-
departmentRepository.save(Department.builder()
|
|
396
|
-
.departmentCode("11110")
|
|
397
|
-
.departmentName("東日本営業課")
|
|
398
|
-
.organizationLevel(3)
|
|
399
|
-
.departmentPath("10000~11000~11100~11110")
|
|
400
|
-
.lowestLevelFlag(1)
|
|
401
|
-
.build());
|
|
402
|
-
|
|
403
|
-
departmentRepository.save(Department.builder()
|
|
404
|
-
.departmentCode("12000")
|
|
405
|
-
.departmentName("製造本部")
|
|
406
|
-
.organizationLevel(1)
|
|
407
|
-
.departmentPath("10000~12000")
|
|
408
|
-
.lowestLevelFlag(0)
|
|
409
|
-
.build());
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
@Test
|
|
413
|
-
@DisplayName("組織階層で検索できる")
|
|
414
|
-
void canFindByOrganizationLevel() {
|
|
415
|
-
// Act
|
|
416
|
-
var result = departmentRepository.findByOrganizationLevel(1);
|
|
417
|
-
|
|
418
|
-
// Assert
|
|
419
|
-
assertThat(result).hasSize(2);
|
|
420
|
-
assertThat(result).extracting(Department::getDepartmentCode)
|
|
421
|
-
.containsExactlyInAnyOrder("11000", "12000");
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
@Test
|
|
425
|
-
@DisplayName("部門パスで配下の部門を検索できる")
|
|
426
|
-
void canFindByDepartmentPathStartsWith() {
|
|
427
|
-
// Act
|
|
428
|
-
var result = departmentRepository.findByDepartmentPathStartsWith("10000~11000");
|
|
429
|
-
|
|
430
|
-
// Assert
|
|
431
|
-
assertThat(result).hasSize(2);
|
|
432
|
-
assertThat(result).extracting(Department::getDepartmentCode)
|
|
433
|
-
.containsExactlyInAnyOrder("11000", "11110");
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
@Test
|
|
437
|
-
@DisplayName("最下層部門のみ検索できる")
|
|
438
|
-
void canFindLeafDepartments() {
|
|
439
|
-
// Act
|
|
440
|
-
var result = departmentRepository.findLeafDepartments();
|
|
441
|
-
|
|
442
|
-
// Assert
|
|
443
|
-
assertThat(result).hasSize(1);
|
|
444
|
-
assertThat(result.get(0).getDepartmentCode()).isEqualTo("11110");
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
</details>
|
|
451
|
-
|
|
452
|
-
## 20.3 勘定科目体系
|
|
453
|
-
|
|
454
|
-
### 20.3.1 勘定科目の構成
|
|
455
|
-
|
|
456
|
-
D社の勘定科目は、貸借対照表(BS)科目と損益計算書(PL)科目で構成されています。
|
|
457
|
-
|
|
458
|
-
```plantuml
|
|
459
|
-
@startwbs
|
|
460
|
-
|
|
461
|
-
title D社 貸借対照表科目(抜粋)
|
|
462
|
-
|
|
463
|
-
* 貸借対照表
|
|
464
|
-
** (資産の部)
|
|
465
|
-
*** 流動資産
|
|
466
|
-
**** 現金及び預金
|
|
467
|
-
***** 現金
|
|
468
|
-
***** 当座預金
|
|
469
|
-
***** 普通預金
|
|
470
|
-
**** 売上債権
|
|
471
|
-
***** 売掛金
|
|
472
|
-
***** 受取手形
|
|
473
|
-
**** 棚卸資産
|
|
474
|
-
***** 製品
|
|
475
|
-
***** 仕掛品
|
|
476
|
-
***** 原材料
|
|
477
|
-
***** 貯蔵品
|
|
478
|
-
**** その他流動資産
|
|
479
|
-
***** 前払費用
|
|
480
|
-
***** 仮払消費税
|
|
481
|
-
*** 固定資産
|
|
482
|
-
**** 有形固定資産
|
|
483
|
-
***** 建物
|
|
484
|
-
***** 機械装置
|
|
485
|
-
***** 工具器具備品
|
|
486
|
-
**** 無形固定資産
|
|
487
|
-
***** ソフトウェア
|
|
488
|
-
** (負債の部)
|
|
489
|
-
*** 流動負債
|
|
490
|
-
**** 仕入債務
|
|
491
|
-
***** 買掛金
|
|
492
|
-
***** 支払手形
|
|
493
|
-
**** その他流動負債
|
|
494
|
-
***** 未払金
|
|
495
|
-
***** 未払費用
|
|
496
|
-
***** 仮受消費税
|
|
497
|
-
***** 預り金
|
|
498
|
-
*** 固定負債
|
|
499
|
-
**** 長期借入金
|
|
500
|
-
** (純資産の部)
|
|
501
|
-
*** 資本金
|
|
502
|
-
*** 資本剰余金
|
|
503
|
-
*** 利益剰余金
|
|
504
|
-
|
|
505
|
-
@endwbs
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
### 20.3.2 主要勘定科目一覧
|
|
509
|
-
|
|
510
|
-
**資産(BS借方)**
|
|
511
|
-
|
|
512
|
-
| コード | 科目名 | 補助科目 | 説明 |
|
|
513
|
-
|--------|--------|----------|------|
|
|
514
|
-
| 11110 | 現金 | - | 手元現金 |
|
|
515
|
-
| 11130 | 普通預金 | 必須 | 銀行別管理 |
|
|
516
|
-
| 11210 | 売掛金 | 必須 | 得意先別管理 |
|
|
517
|
-
| 11330 | 原材料 | 必須 | 品目別管理 |
|
|
518
|
-
| 11430 | 仮払消費税 | - | 消費税処理用 |
|
|
519
|
-
|
|
520
|
-
**負債・純資産・収益・費用**
|
|
521
|
-
|
|
522
|
-
| コード | 科目名 | 消費税 | 説明 |
|
|
523
|
-
|--------|--------|--------|------|
|
|
524
|
-
| 21110 | 買掛金 | - | 仕入先別管理 |
|
|
525
|
-
| 21240 | 仮受消費税 | - | 消費税処理用 |
|
|
526
|
-
| 33200 | 繰越利益剰余金 | - | 留保利益 |
|
|
527
|
-
| 41110 | 国内売上高 | 課税10% | 国内向け売上 |
|
|
528
|
-
| 62100 | 旅費交通費 | 課税10% | 出張費等 |
|
|
529
|
-
|
|
530
|
-
### 20.3.3 会計処理のパターン
|
|
531
|
-
|
|
532
|
-
```plantuml
|
|
533
|
-
@startuml
|
|
534
|
-
|
|
535
|
-
title D社 主要な取引と仕訳パターン
|
|
536
|
-
|
|
537
|
-
left to right direction
|
|
538
|
-
|
|
539
|
-
rectangle "販売取引" {
|
|
540
|
-
card sales [
|
|
541
|
-
**売上計上**
|
|
542
|
-
----
|
|
543
|
-
借方: 売掛金
|
|
544
|
-
貸方: 売上高
|
|
545
|
-
貸方: 仮受消費税
|
|
546
|
-
]
|
|
547
|
-
|
|
548
|
-
card receipt [
|
|
549
|
-
**入金**
|
|
550
|
-
----
|
|
551
|
-
借方: 普通預金
|
|
552
|
-
貸方: 売掛金
|
|
553
|
-
]
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
rectangle "製造取引" {
|
|
557
|
-
card material [
|
|
558
|
-
**材料仕入**
|
|
559
|
-
----
|
|
560
|
-
借方: 原材料
|
|
561
|
-
借方: 仮払消費税
|
|
562
|
-
貸方: 買掛金
|
|
563
|
-
]
|
|
564
|
-
|
|
565
|
-
card expense [
|
|
566
|
-
**製造経費**
|
|
567
|
-
----
|
|
568
|
-
借方: 製造間接費
|
|
569
|
-
借方: 仮払消費税
|
|
570
|
-
貸方: 未払金
|
|
571
|
-
]
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
rectangle "一般取引" {
|
|
575
|
-
card exp [
|
|
576
|
-
**経費精算**
|
|
577
|
-
----
|
|
578
|
-
借方: 旅費交通費/消耗品費
|
|
579
|
-
借方: 仮払消費税
|
|
580
|
-
貸方: 現金/未払金
|
|
581
|
-
]
|
|
582
|
-
|
|
583
|
-
card salary [
|
|
584
|
-
**給与支払**
|
|
585
|
-
----
|
|
586
|
-
借方: 給料手当
|
|
587
|
-
貸方: 普通預金
|
|
588
|
-
貸方: 預り金(税・社保)
|
|
589
|
-
]
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
@enduml
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
## 20.4 Seed データ投入サービス(JPA版)
|
|
596
|
-
|
|
597
|
-
### 20.4.1 SeedDataService
|
|
598
|
-
|
|
599
|
-
JPA の CascadeType.ALL を活用し、仕訳と明細を一括保存します。
|
|
600
|
-
|
|
601
|
-
<details>
|
|
602
|
-
<summary>SeedDataService(JPA版)</summary>
|
|
603
|
-
|
|
604
|
-
```java
|
|
605
|
-
// src/main/java/com/example/accounting/infrastructure/seed/SeedDataService.java
|
|
606
|
-
package com.example.accounting.infrastructure.seed;
|
|
607
|
-
|
|
608
|
-
import com.example.accounting.domain.model.account.*;
|
|
609
|
-
import com.example.accounting.domain.model.department.*;
|
|
610
|
-
import com.example.accounting.domain.model.journal.*;
|
|
611
|
-
import com.example.accounting.domain.model.tax.*;
|
|
612
|
-
import com.example.accounting.infrastructure.persistence.repository.*;
|
|
613
|
-
import lombok.RequiredArgsConstructor;
|
|
614
|
-
import lombok.extern.slf4j.Slf4j;
|
|
615
|
-
import org.springframework.stereotype.Service;
|
|
616
|
-
import org.springframework.transaction.annotation.Transactional;
|
|
617
|
-
|
|
618
|
-
import java.math.BigDecimal;
|
|
619
|
-
import java.time.LocalDate;
|
|
620
|
-
import java.util.ArrayList;
|
|
621
|
-
import java.util.List;
|
|
622
|
-
|
|
623
|
-
/**
|
|
624
|
-
* Seed データ投入サービス(JPA 版)
|
|
625
|
-
*/
|
|
626
|
-
@Service
|
|
627
|
-
@RequiredArgsConstructor
|
|
628
|
-
@Slf4j
|
|
629
|
-
public class SeedDataService {
|
|
630
|
-
|
|
631
|
-
private final AccountJpaRepository accountRepository;
|
|
632
|
-
private final AccountStructureJpaRepository accountStructureRepository;
|
|
633
|
-
private final TaxTransactionJpaRepository taxTransactionRepository;
|
|
634
|
-
private final DepartmentJpaRepository departmentRepository;
|
|
635
|
-
private final JournalJpaRepository journalRepository;
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* 全Seedデータを投入
|
|
639
|
-
*/
|
|
640
|
-
@Transactional
|
|
641
|
-
public void seedAll() {
|
|
642
|
-
log.info("Starting seed data insertion...");
|
|
643
|
-
|
|
644
|
-
seedTaxTransactions();
|
|
645
|
-
seedAccountMasters();
|
|
646
|
-
seedAccountStructures();
|
|
647
|
-
seedDepartments();
|
|
648
|
-
seedSampleJournals();
|
|
649
|
-
|
|
650
|
-
log.info("Seed data insertion completed.");
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* 課税取引マスタのSeedデータ
|
|
655
|
-
*/
|
|
656
|
-
@Transactional
|
|
657
|
-
public void seedTaxTransactions() {
|
|
658
|
-
log.info("Seeding tax transactions...");
|
|
659
|
-
|
|
660
|
-
List<TaxTransaction> taxes = List.of(
|
|
661
|
-
TaxTransaction.builder()
|
|
662
|
-
.taxCode("00").taxName("免税").taxRate(BigDecimal.ZERO).build(),
|
|
663
|
-
TaxTransaction.builder()
|
|
664
|
-
.taxCode("08").taxName("軽減税率8%").taxRate(new BigDecimal("0.080")).build(),
|
|
665
|
-
TaxTransaction.builder()
|
|
666
|
-
.taxCode("10").taxName("標準税率10%").taxRate(new BigDecimal("0.100")).build(),
|
|
667
|
-
TaxTransaction.builder()
|
|
668
|
-
.taxCode("80").taxName("非課税").taxRate(BigDecimal.ZERO).build(),
|
|
669
|
-
TaxTransaction.builder()
|
|
670
|
-
.taxCode("99").taxName("対象外").taxRate(BigDecimal.ZERO).build()
|
|
671
|
-
);
|
|
672
|
-
|
|
673
|
-
int insertedCount = 0;
|
|
674
|
-
for (TaxTransaction tax : taxes) {
|
|
675
|
-
if (!taxTransactionRepository.existsById(tax.getTaxCode())) {
|
|
676
|
-
taxTransactionRepository.save(tax);
|
|
677
|
-
insertedCount++;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
log.info("Tax transactions seeded: {} records", insertedCount);
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* 勘定科目マスタのSeedデータ
|
|
686
|
-
*/
|
|
687
|
-
@Transactional
|
|
688
|
-
public void seedAccountMasters() {
|
|
689
|
-
log.info("Seeding account masters...");
|
|
690
|
-
|
|
691
|
-
List<Account> accounts = createAccountMasterSeedData();
|
|
692
|
-
|
|
693
|
-
int insertedCount = 0;
|
|
694
|
-
for (Account account : accounts) {
|
|
695
|
-
if (!accountRepository.existsById(account.getAccountCode())) {
|
|
696
|
-
accountRepository.save(account);
|
|
697
|
-
insertedCount++;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
log.info("Account masters seeded: {} records", insertedCount);
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
/**
|
|
705
|
-
* 勘定科目構成マスタのSeedデータ
|
|
706
|
-
*/
|
|
707
|
-
@Transactional
|
|
708
|
-
public void seedAccountStructures() {
|
|
709
|
-
log.info("Seeding account structures...");
|
|
710
|
-
|
|
711
|
-
List<Account> accounts = accountRepository.findAll();
|
|
712
|
-
|
|
713
|
-
int insertedCount = 0;
|
|
714
|
-
for (Account account : accounts) {
|
|
715
|
-
if (!accountStructureRepository.existsById(account.getAccountCode())) {
|
|
716
|
-
String path = generateAccountPath(account);
|
|
717
|
-
AccountStructure structure = AccountStructure.builder()
|
|
718
|
-
.accountCode(account.getAccountCode())
|
|
719
|
-
.accountPath(path)
|
|
720
|
-
.account(account)
|
|
721
|
-
.build();
|
|
722
|
-
accountStructureRepository.save(structure);
|
|
723
|
-
insertedCount++;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
log.info("Account structures seeded: {} records", insertedCount);
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
* 部門マスタのSeedデータ
|
|
732
|
-
*/
|
|
733
|
-
@Transactional
|
|
734
|
-
public void seedDepartments() {
|
|
735
|
-
log.info("Seeding departments...");
|
|
736
|
-
|
|
737
|
-
List<Department> departments = createDepartmentSeedData();
|
|
738
|
-
|
|
739
|
-
int insertedCount = 0;
|
|
740
|
-
for (Department dept : departments) {
|
|
741
|
-
if (!departmentRepository.existsById(dept.getDepartmentCode())) {
|
|
742
|
-
departmentRepository.save(dept);
|
|
743
|
-
insertedCount++;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
log.info("Departments seeded: {} records", insertedCount);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
/**
|
|
751
|
-
* サンプル仕訳データのSeed
|
|
752
|
-
*/
|
|
753
|
-
@Transactional
|
|
754
|
-
public void seedSampleJournals() {
|
|
755
|
-
log.info("Seeding sample journals...");
|
|
756
|
-
|
|
757
|
-
// 期首仕訳
|
|
758
|
-
createOpeningJournal();
|
|
759
|
-
|
|
760
|
-
// 売上仕訳
|
|
761
|
-
createSalesJournal();
|
|
762
|
-
|
|
763
|
-
// 経費仕訳
|
|
764
|
-
createExpenseJournal();
|
|
765
|
-
|
|
766
|
-
// 材料仕入仕訳
|
|
767
|
-
createMaterialPurchaseJournal();
|
|
768
|
-
|
|
769
|
-
// 給与支払仕訳
|
|
770
|
-
createSalaryJournal();
|
|
771
|
-
|
|
772
|
-
// 入金仕訳
|
|
773
|
-
createReceiptJournal();
|
|
774
|
-
|
|
775
|
-
// 支払仕訳
|
|
776
|
-
createPaymentJournal();
|
|
777
|
-
|
|
778
|
-
log.info("Sample journals seeded.");
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
private void createOpeningJournal() {
|
|
782
|
-
String journalNumber = "J2025040001";
|
|
783
|
-
|
|
784
|
-
if (journalRepository.existsById(journalNumber)) {
|
|
785
|
-
return;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
LocalDate date = LocalDate.of(2025, 4, 1);
|
|
789
|
-
|
|
790
|
-
// 仕訳ヘッダ
|
|
791
|
-
Journal journal = Journal.builder()
|
|
792
|
-
.journalNumber(journalNumber)
|
|
793
|
-
.postingDate(date)
|
|
794
|
-
.inputDate(date)
|
|
795
|
-
.closingJournalFlag(0)
|
|
796
|
-
.singleFlag(0)
|
|
797
|
-
.journalSlipType(JournalSlipType.NORMAL)
|
|
798
|
-
.departmentCode("13100")
|
|
799
|
-
.build();
|
|
800
|
-
|
|
801
|
-
// 仕訳明細
|
|
802
|
-
JournalDetail detail = JournalDetail.builder()
|
|
803
|
-
.lineNumber(1)
|
|
804
|
-
.lineDescription("前期繰越")
|
|
805
|
-
.build();
|
|
806
|
-
detail.setJournal(journal);
|
|
807
|
-
|
|
808
|
-
// 借方:普通預金
|
|
809
|
-
JournalDcDetail debit = JournalDcDetail.builder()
|
|
810
|
-
.dcType(DcType.DEBIT)
|
|
811
|
-
.accountCode("11130")
|
|
812
|
-
.amount(new BigDecimal("50000000"))
|
|
813
|
-
.build();
|
|
814
|
-
debit.setJournalDetail(detail);
|
|
815
|
-
|
|
816
|
-
// 貸方:繰越利益剰余金
|
|
817
|
-
JournalDcDetail credit = JournalDcDetail.builder()
|
|
818
|
-
.dcType(DcType.CREDIT)
|
|
819
|
-
.accountCode("33200")
|
|
820
|
-
.amount(new BigDecimal("50000000"))
|
|
821
|
-
.build();
|
|
822
|
-
credit.setJournalDetail(detail);
|
|
823
|
-
|
|
824
|
-
// 関連付け
|
|
825
|
-
detail.addDcDetail(debit);
|
|
826
|
-
detail.addDcDetail(credit);
|
|
827
|
-
journal.addDetail(detail);
|
|
828
|
-
|
|
829
|
-
// CascadeType.ALL により一括保存
|
|
830
|
-
journalRepository.save(journal);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
private void createSalesJournal() {
|
|
834
|
-
String journalNumber = "J2025040002";
|
|
835
|
-
|
|
836
|
-
if (journalRepository.existsById(journalNumber)) {
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
LocalDate date = LocalDate.of(2025, 4, 5);
|
|
841
|
-
|
|
842
|
-
Journal journal = Journal.builder()
|
|
843
|
-
.journalNumber(journalNumber)
|
|
844
|
-
.postingDate(date)
|
|
845
|
-
.inputDate(date)
|
|
846
|
-
.closingJournalFlag(0)
|
|
847
|
-
.singleFlag(0)
|
|
848
|
-
.journalSlipType(JournalSlipType.AUTO)
|
|
849
|
-
.departmentCode("11110")
|
|
850
|
-
.build();
|
|
851
|
-
|
|
852
|
-
JournalDetail detail = JournalDetail.builder()
|
|
853
|
-
.lineNumber(1)
|
|
854
|
-
.lineDescription("ABC商事 スキンケアセット 100個")
|
|
855
|
-
.build();
|
|
856
|
-
detail.setJournal(journal);
|
|
857
|
-
|
|
858
|
-
// 借方:売掛金
|
|
859
|
-
JournalDcDetail debit = JournalDcDetail.builder()
|
|
860
|
-
.dcType(DcType.DEBIT)
|
|
861
|
-
.accountCode("11210")
|
|
862
|
-
.subAccountCode("ABC001")
|
|
863
|
-
.amount(new BigDecimal("330000"))
|
|
864
|
-
.build();
|
|
865
|
-
debit.setJournalDetail(detail);
|
|
866
|
-
|
|
867
|
-
// 貸方:国内売上高
|
|
868
|
-
JournalDcDetail creditSales = JournalDcDetail.builder()
|
|
869
|
-
.dcType(DcType.CREDIT)
|
|
870
|
-
.accountCode("41110")
|
|
871
|
-
.subAccountCode("ABC001")
|
|
872
|
-
.amount(new BigDecimal("300000"))
|
|
873
|
-
.taxType(TaxType.TAXABLE_SALES)
|
|
874
|
-
.taxRate(10)
|
|
875
|
-
.build();
|
|
876
|
-
creditSales.setJournalDetail(detail);
|
|
877
|
-
|
|
878
|
-
// 貸方:仮受消費税
|
|
879
|
-
JournalDcDetail creditTax = JournalDcDetail.builder()
|
|
880
|
-
.dcType(DcType.CREDIT)
|
|
881
|
-
.accountCode("21240")
|
|
882
|
-
.amount(new BigDecimal("30000"))
|
|
883
|
-
.build();
|
|
884
|
-
creditTax.setJournalDetail(detail);
|
|
885
|
-
|
|
886
|
-
detail.addDcDetail(debit);
|
|
887
|
-
detail.addDcDetail(creditSales);
|
|
888
|
-
detail.addDcDetail(creditTax);
|
|
889
|
-
journal.addDetail(detail);
|
|
890
|
-
|
|
891
|
-
journalRepository.save(journal);
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
private void createExpenseJournal() {
|
|
895
|
-
String journalNumber = "J2025040003";
|
|
896
|
-
|
|
897
|
-
if (journalRepository.existsById(journalNumber)) {
|
|
898
|
-
return;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
LocalDate date = LocalDate.of(2025, 4, 10);
|
|
902
|
-
|
|
903
|
-
Journal journal = Journal.builder()
|
|
904
|
-
.journalNumber(journalNumber)
|
|
905
|
-
.postingDate(date)
|
|
906
|
-
.inputDate(date)
|
|
907
|
-
.closingJournalFlag(0)
|
|
908
|
-
.singleFlag(0)
|
|
909
|
-
.journalSlipType(JournalSlipType.NORMAL)
|
|
910
|
-
.departmentCode("11110")
|
|
911
|
-
.build();
|
|
912
|
-
|
|
913
|
-
JournalDetail detail = JournalDetail.builder()
|
|
914
|
-
.lineNumber(1)
|
|
915
|
-
.lineDescription("出張旅費 東京→大阪")
|
|
916
|
-
.build();
|
|
917
|
-
detail.setJournal(journal);
|
|
918
|
-
|
|
919
|
-
// 借方:旅費交通費
|
|
920
|
-
JournalDcDetail debitExp = JournalDcDetail.builder()
|
|
921
|
-
.dcType(DcType.DEBIT)
|
|
922
|
-
.accountCode("62100")
|
|
923
|
-
.amount(new BigDecimal("27273"))
|
|
924
|
-
.taxType(TaxType.TAXABLE_PURCHASE)
|
|
925
|
-
.taxRate(10)
|
|
926
|
-
.build();
|
|
927
|
-
debitExp.setJournalDetail(detail);
|
|
928
|
-
|
|
929
|
-
// 借方:仮払消費税
|
|
930
|
-
JournalDcDetail debitTax = JournalDcDetail.builder()
|
|
931
|
-
.dcType(DcType.DEBIT)
|
|
932
|
-
.accountCode("11430")
|
|
933
|
-
.amount(new BigDecimal("2727"))
|
|
934
|
-
.build();
|
|
935
|
-
debitTax.setJournalDetail(detail);
|
|
936
|
-
|
|
937
|
-
// 貸方:現金
|
|
938
|
-
JournalDcDetail credit = JournalDcDetail.builder()
|
|
939
|
-
.dcType(DcType.CREDIT)
|
|
940
|
-
.accountCode("11110")
|
|
941
|
-
.amount(new BigDecimal("30000"))
|
|
942
|
-
.build();
|
|
943
|
-
credit.setJournalDetail(detail);
|
|
944
|
-
|
|
945
|
-
detail.addDcDetail(debitExp);
|
|
946
|
-
detail.addDcDetail(debitTax);
|
|
947
|
-
detail.addDcDetail(credit);
|
|
948
|
-
journal.addDetail(detail);
|
|
949
|
-
|
|
950
|
-
journalRepository.save(journal);
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
private void createMaterialPurchaseJournal() {
|
|
954
|
-
String journalNumber = "J2025040004";
|
|
955
|
-
|
|
956
|
-
if (journalRepository.existsById(journalNumber)) {
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
LocalDate date = LocalDate.of(2025, 4, 15);
|
|
961
|
-
|
|
962
|
-
Journal journal = Journal.builder()
|
|
963
|
-
.journalNumber(journalNumber)
|
|
964
|
-
.postingDate(date)
|
|
965
|
-
.inputDate(date)
|
|
966
|
-
.closingJournalFlag(0)
|
|
967
|
-
.singleFlag(0)
|
|
968
|
-
.journalSlipType(JournalSlipType.AUTO)
|
|
969
|
-
.departmentCode("12110")
|
|
970
|
-
.build();
|
|
971
|
-
|
|
972
|
-
JournalDetail detail = JournalDetail.builder()
|
|
973
|
-
.lineNumber(1)
|
|
974
|
-
.lineDescription("XYZ化学 原材料仕入")
|
|
975
|
-
.build();
|
|
976
|
-
detail.setJournal(journal);
|
|
977
|
-
|
|
978
|
-
// 借方:原材料
|
|
979
|
-
JournalDcDetail debitMat = JournalDcDetail.builder()
|
|
980
|
-
.dcType(DcType.DEBIT)
|
|
981
|
-
.accountCode("11330")
|
|
982
|
-
.subAccountCode("MAT001")
|
|
983
|
-
.amount(new BigDecimal("500000"))
|
|
984
|
-
.taxType(TaxType.TAXABLE_PURCHASE)
|
|
985
|
-
.taxRate(10)
|
|
986
|
-
.build();
|
|
987
|
-
debitMat.setJournalDetail(detail);
|
|
988
|
-
|
|
989
|
-
// 借方:仮払消費税
|
|
990
|
-
JournalDcDetail debitTax = JournalDcDetail.builder()
|
|
991
|
-
.dcType(DcType.DEBIT)
|
|
992
|
-
.accountCode("11430")
|
|
993
|
-
.amount(new BigDecimal("50000"))
|
|
994
|
-
.build();
|
|
995
|
-
debitTax.setJournalDetail(detail);
|
|
996
|
-
|
|
997
|
-
// 貸方:買掛金
|
|
998
|
-
JournalDcDetail credit = JournalDcDetail.builder()
|
|
999
|
-
.dcType(DcType.CREDIT)
|
|
1000
|
-
.accountCode("21110")
|
|
1001
|
-
.subAccountCode("XYZ001")
|
|
1002
|
-
.amount(new BigDecimal("550000"))
|
|
1003
|
-
.build();
|
|
1004
|
-
credit.setJournalDetail(detail);
|
|
1005
|
-
|
|
1006
|
-
detail.addDcDetail(debitMat);
|
|
1007
|
-
detail.addDcDetail(debitTax);
|
|
1008
|
-
detail.addDcDetail(credit);
|
|
1009
|
-
journal.addDetail(detail);
|
|
1010
|
-
|
|
1011
|
-
journalRepository.save(journal);
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
private void createSalaryJournal() {
|
|
1015
|
-
String journalNumber = "J2025040005";
|
|
1016
|
-
|
|
1017
|
-
if (journalRepository.existsById(journalNumber)) {
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
LocalDate date = LocalDate.of(2025, 4, 20);
|
|
1022
|
-
|
|
1023
|
-
Journal journal = Journal.builder()
|
|
1024
|
-
.journalNumber(journalNumber)
|
|
1025
|
-
.postingDate(date)
|
|
1026
|
-
.inputDate(date)
|
|
1027
|
-
.closingJournalFlag(0)
|
|
1028
|
-
.singleFlag(0)
|
|
1029
|
-
.journalSlipType(JournalSlipType.NORMAL)
|
|
1030
|
-
.departmentCode("13100")
|
|
1031
|
-
.build();
|
|
1032
|
-
|
|
1033
|
-
JournalDetail detail = JournalDetail.builder()
|
|
1034
|
-
.lineNumber(1)
|
|
1035
|
-
.lineDescription("4月度給与")
|
|
1036
|
-
.build();
|
|
1037
|
-
detail.setJournal(journal);
|
|
1038
|
-
|
|
1039
|
-
// 借方:給料手当
|
|
1040
|
-
JournalDcDetail debit = JournalDcDetail.builder()
|
|
1041
|
-
.dcType(DcType.DEBIT)
|
|
1042
|
-
.accountCode("61200")
|
|
1043
|
-
.amount(new BigDecimal("10000000"))
|
|
1044
|
-
.build();
|
|
1045
|
-
debit.setJournalDetail(detail);
|
|
1046
|
-
|
|
1047
|
-
// 貸方:普通預金
|
|
1048
|
-
JournalDcDetail creditBank = JournalDcDetail.builder()
|
|
1049
|
-
.dcType(DcType.CREDIT)
|
|
1050
|
-
.accountCode("11130")
|
|
1051
|
-
.amount(new BigDecimal("8500000"))
|
|
1052
|
-
.build();
|
|
1053
|
-
creditBank.setJournalDetail(detail);
|
|
1054
|
-
|
|
1055
|
-
// 貸方:預り金
|
|
1056
|
-
JournalDcDetail creditDeposit = JournalDcDetail.builder()
|
|
1057
|
-
.dcType(DcType.CREDIT)
|
|
1058
|
-
.accountCode("21250")
|
|
1059
|
-
.amount(new BigDecimal("1500000"))
|
|
1060
|
-
.build();
|
|
1061
|
-
creditDeposit.setJournalDetail(detail);
|
|
1062
|
-
|
|
1063
|
-
detail.addDcDetail(debit);
|
|
1064
|
-
detail.addDcDetail(creditBank);
|
|
1065
|
-
detail.addDcDetail(creditDeposit);
|
|
1066
|
-
journal.addDetail(detail);
|
|
1067
|
-
|
|
1068
|
-
journalRepository.save(journal);
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
private void createReceiptJournal() {
|
|
1072
|
-
String journalNumber = "J2025040006";
|
|
1073
|
-
|
|
1074
|
-
if (journalRepository.existsById(journalNumber)) {
|
|
1075
|
-
return;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
LocalDate date = LocalDate.of(2025, 4, 25);
|
|
1079
|
-
|
|
1080
|
-
Journal journal = Journal.builder()
|
|
1081
|
-
.journalNumber(journalNumber)
|
|
1082
|
-
.postingDate(date)
|
|
1083
|
-
.inputDate(date)
|
|
1084
|
-
.closingJournalFlag(0)
|
|
1085
|
-
.singleFlag(0)
|
|
1086
|
-
.journalSlipType(JournalSlipType.NORMAL)
|
|
1087
|
-
.departmentCode("13100")
|
|
1088
|
-
.build();
|
|
1089
|
-
|
|
1090
|
-
JournalDetail detail = JournalDetail.builder()
|
|
1091
|
-
.lineNumber(1)
|
|
1092
|
-
.lineDescription("ABC商事 入金")
|
|
1093
|
-
.build();
|
|
1094
|
-
detail.setJournal(journal);
|
|
1095
|
-
|
|
1096
|
-
// 借方:普通預金
|
|
1097
|
-
JournalDcDetail debit = JournalDcDetail.builder()
|
|
1098
|
-
.dcType(DcType.DEBIT)
|
|
1099
|
-
.accountCode("11130")
|
|
1100
|
-
.amount(new BigDecimal("330000"))
|
|
1101
|
-
.build();
|
|
1102
|
-
debit.setJournalDetail(detail);
|
|
1103
|
-
|
|
1104
|
-
// 貸方:売掛金
|
|
1105
|
-
JournalDcDetail credit = JournalDcDetail.builder()
|
|
1106
|
-
.dcType(DcType.CREDIT)
|
|
1107
|
-
.accountCode("11210")
|
|
1108
|
-
.subAccountCode("ABC001")
|
|
1109
|
-
.amount(new BigDecimal("330000"))
|
|
1110
|
-
.build();
|
|
1111
|
-
credit.setJournalDetail(detail);
|
|
1112
|
-
|
|
1113
|
-
detail.addDcDetail(debit);
|
|
1114
|
-
detail.addDcDetail(credit);
|
|
1115
|
-
journal.addDetail(detail);
|
|
1116
|
-
|
|
1117
|
-
journalRepository.save(journal);
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
private void createPaymentJournal() {
|
|
1121
|
-
String journalNumber = "J2025040007";
|
|
1122
|
-
|
|
1123
|
-
if (journalRepository.existsById(journalNumber)) {
|
|
1124
|
-
return;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
LocalDate date = LocalDate.of(2025, 4, 30);
|
|
1128
|
-
|
|
1129
|
-
Journal journal = Journal.builder()
|
|
1130
|
-
.journalNumber(journalNumber)
|
|
1131
|
-
.postingDate(date)
|
|
1132
|
-
.inputDate(date)
|
|
1133
|
-
.closingJournalFlag(0)
|
|
1134
|
-
.singleFlag(0)
|
|
1135
|
-
.journalSlipType(JournalSlipType.NORMAL)
|
|
1136
|
-
.departmentCode("13100")
|
|
1137
|
-
.build();
|
|
1138
|
-
|
|
1139
|
-
JournalDetail detail = JournalDetail.builder()
|
|
1140
|
-
.lineNumber(1)
|
|
1141
|
-
.lineDescription("XYZ化学 支払")
|
|
1142
|
-
.build();
|
|
1143
|
-
detail.setJournal(journal);
|
|
1144
|
-
|
|
1145
|
-
// 借方:買掛金
|
|
1146
|
-
JournalDcDetail debit = JournalDcDetail.builder()
|
|
1147
|
-
.dcType(DcType.DEBIT)
|
|
1148
|
-
.accountCode("21110")
|
|
1149
|
-
.subAccountCode("XYZ001")
|
|
1150
|
-
.amount(new BigDecimal("550000"))
|
|
1151
|
-
.build();
|
|
1152
|
-
debit.setJournalDetail(detail);
|
|
1153
|
-
|
|
1154
|
-
// 貸方:普通預金
|
|
1155
|
-
JournalDcDetail credit = JournalDcDetail.builder()
|
|
1156
|
-
.dcType(DcType.CREDIT)
|
|
1157
|
-
.accountCode("11130")
|
|
1158
|
-
.amount(new BigDecimal("550000"))
|
|
1159
|
-
.build();
|
|
1160
|
-
credit.setJournalDetail(detail);
|
|
1161
|
-
|
|
1162
|
-
detail.addDcDetail(debit);
|
|
1163
|
-
detail.addDcDetail(credit);
|
|
1164
|
-
journal.addDetail(detail);
|
|
1165
|
-
|
|
1166
|
-
journalRepository.save(journal);
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
private List<Account> createAccountMasterSeedData() {
|
|
1170
|
-
List<Account> accounts = new ArrayList<>();
|
|
1171
|
-
|
|
1172
|
-
// 流動資産
|
|
1173
|
-
accounts.add(Account.builder()
|
|
1174
|
-
.accountCode("11110").accountName("現金").accountShortName("現金")
|
|
1175
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1176
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1177
|
-
.build());
|
|
1178
|
-
|
|
1179
|
-
accounts.add(Account.builder()
|
|
1180
|
-
.accountCode("11130").accountName("普通預金").accountShortName("普通")
|
|
1181
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1182
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1183
|
-
.subAccountType(SubAccountType.REQUIRED)
|
|
1184
|
-
.build());
|
|
1185
|
-
|
|
1186
|
-
accounts.add(Account.builder()
|
|
1187
|
-
.accountCode("11210").accountName("売掛金").accountShortName("売掛金")
|
|
1188
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1189
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1190
|
-
.subAccountType(SubAccountType.REQUIRED).dueDateManagementType(DueDateManagementType.REQUIRED)
|
|
1191
|
-
.build());
|
|
1192
|
-
|
|
1193
|
-
// 棚卸資産
|
|
1194
|
-
accounts.add(Account.builder()
|
|
1195
|
-
.accountCode("11330").accountName("原材料").accountShortName("原材料")
|
|
1196
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1197
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.MANUFACTURING)
|
|
1198
|
-
.subAccountType(SubAccountType.REQUIRED)
|
|
1199
|
-
.build());
|
|
1200
|
-
|
|
1201
|
-
// 仮払消費税
|
|
1202
|
-
accounts.add(Account.builder()
|
|
1203
|
-
.accountCode("11430").accountName("仮払消費税").accountShortName("仮払税")
|
|
1204
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1205
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1206
|
-
.build());
|
|
1207
|
-
|
|
1208
|
-
// 負債
|
|
1209
|
-
accounts.add(Account.builder()
|
|
1210
|
-
.accountCode("21110").accountName("買掛金").accountShortName("買掛金")
|
|
1211
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.CREDIT).elementType(ElementType.LIABILITY)
|
|
1212
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1213
|
-
.subAccountType(SubAccountType.REQUIRED).dueDateManagementType(DueDateManagementType.REQUIRED)
|
|
1214
|
-
.build());
|
|
1215
|
-
|
|
1216
|
-
accounts.add(Account.builder()
|
|
1217
|
-
.accountCode("21240").accountName("仮受消費税").accountShortName("仮受税")
|
|
1218
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.CREDIT).elementType(ElementType.LIABILITY)
|
|
1219
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1220
|
-
.build());
|
|
1221
|
-
|
|
1222
|
-
accounts.add(Account.builder()
|
|
1223
|
-
.accountCode("21250").accountName("預り金").accountShortName("預り金")
|
|
1224
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.CREDIT).elementType(ElementType.LIABILITY)
|
|
1225
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1226
|
-
.build());
|
|
1227
|
-
|
|
1228
|
-
// 純資産
|
|
1229
|
-
accounts.add(Account.builder()
|
|
1230
|
-
.accountCode("33200").accountName("繰越利益剰余金").accountShortName("繰越利益")
|
|
1231
|
-
.bsPlType(BsPlType.BS).dcType(AccountDcType.CREDIT).elementType(ElementType.CAPITAL)
|
|
1232
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1233
|
-
.build());
|
|
1234
|
-
|
|
1235
|
-
// 売上
|
|
1236
|
-
accounts.add(Account.builder()
|
|
1237
|
-
.accountCode("41110").accountName("国内売上高").accountShortName("国内売上")
|
|
1238
|
-
.bsPlType(BsPlType.PL).dcType(AccountDcType.CREDIT).elementType(ElementType.REVENUE)
|
|
1239
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1240
|
-
.taxCalculationType(TaxCalculationType.SALES).taxCode("10")
|
|
1241
|
-
.build());
|
|
1242
|
-
|
|
1243
|
-
// 経費
|
|
1244
|
-
accounts.add(Account.builder()
|
|
1245
|
-
.accountCode("61200").accountName("給料手当").accountShortName("給料")
|
|
1246
|
-
.bsPlType(BsPlType.PL).dcType(AccountDcType.DEBIT).elementType(ElementType.EXPENSE)
|
|
1247
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1248
|
-
.expenseType(ExpenseType.EXPENSE)
|
|
1249
|
-
.build());
|
|
1250
|
-
|
|
1251
|
-
accounts.add(Account.builder()
|
|
1252
|
-
.accountCode("62100").accountName("旅費交通費").accountShortName("旅費交通")
|
|
1253
|
-
.bsPlType(BsPlType.PL).dcType(AccountDcType.DEBIT).elementType(ElementType.EXPENSE)
|
|
1254
|
-
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1255
|
-
.expenseType(ExpenseType.EXPENSE)
|
|
1256
|
-
.taxCalculationType(TaxCalculationType.PURCHASE).taxCode("10")
|
|
1257
|
-
.build());
|
|
1258
|
-
|
|
1259
|
-
return accounts;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
private List<Department> createDepartmentSeedData() {
|
|
1263
|
-
return List.of(
|
|
1264
|
-
Department.builder()
|
|
1265
|
-
.departmentCode("10000").departmentName("全社")
|
|
1266
|
-
.organizationLevel(0).departmentPath("10000").lowestLevelFlag(0).build(),
|
|
1267
|
-
Department.builder()
|
|
1268
|
-
.departmentCode("11000").departmentName("営業本部")
|
|
1269
|
-
.organizationLevel(1).departmentPath("10000~11000").lowestLevelFlag(0).build(),
|
|
1270
|
-
Department.builder()
|
|
1271
|
-
.departmentCode("11110").departmentName("東日本営業課")
|
|
1272
|
-
.organizationLevel(3).departmentPath("10000~11000~11100~11110").lowestLevelFlag(1).build(),
|
|
1273
|
-
Department.builder()
|
|
1274
|
-
.departmentCode("12000").departmentName("製造本部")
|
|
1275
|
-
.organizationLevel(1).departmentPath("10000~12000").lowestLevelFlag(0).build(),
|
|
1276
|
-
Department.builder()
|
|
1277
|
-
.departmentCode("12110").departmentName("第一製造課")
|
|
1278
|
-
.organizationLevel(3).departmentPath("10000~12000~12100~12110").lowestLevelFlag(1).build(),
|
|
1279
|
-
Department.builder()
|
|
1280
|
-
.departmentCode("13000").departmentName("管理本部")
|
|
1281
|
-
.organizationLevel(1).departmentPath("10000~13000").lowestLevelFlag(0).build(),
|
|
1282
|
-
Department.builder()
|
|
1283
|
-
.departmentCode("13100").departmentName("経理部")
|
|
1284
|
-
.organizationLevel(2).departmentPath("10000~13000~13100").lowestLevelFlag(0).build()
|
|
1285
|
-
);
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
private String generateAccountPath(Account account) {
|
|
1289
|
-
String code = account.getAccountCode();
|
|
1290
|
-
|
|
1291
|
-
// 簡易的なパス生成(実際はマスタの親子関係から生成)
|
|
1292
|
-
if (code.length() == 2) {
|
|
1293
|
-
return code;
|
|
1294
|
-
} else if (code.length() == 5) {
|
|
1295
|
-
String parent = code.substring(0, 2);
|
|
1296
|
-
return parent + "~" + code;
|
|
1297
|
-
}
|
|
1298
|
-
return code;
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
```
|
|
1302
|
-
|
|
1303
|
-
</details>
|
|
1304
|
-
|
|
1305
|
-
### 20.4.2 CommandLineRunner による起動時データ投入
|
|
1306
|
-
|
|
1307
|
-
<details>
|
|
1308
|
-
<summary>SeedDataRunner(CommandLineRunner)</summary>
|
|
1309
|
-
|
|
1310
|
-
```java
|
|
1311
|
-
// src/main/java/com/example/accounting/infrastructure/seed/SeedDataRunner.java
|
|
1312
|
-
package com.example.accounting.infrastructure.seed;
|
|
1313
|
-
|
|
1314
|
-
import lombok.RequiredArgsConstructor;
|
|
1315
|
-
import lombok.extern.slf4j.Slf4j;
|
|
1316
|
-
import org.springframework.boot.CommandLineRunner;
|
|
1317
|
-
import org.springframework.context.annotation.Profile;
|
|
1318
|
-
import org.springframework.stereotype.Component;
|
|
1319
|
-
|
|
1320
|
-
/**
|
|
1321
|
-
* アプリケーション起動時に Seed データを投入する
|
|
1322
|
-
*
|
|
1323
|
-
* dev, local プロファイル時のみ有効
|
|
1324
|
-
*/
|
|
1325
|
-
@Component
|
|
1326
|
-
@Profile({"dev", "local"})
|
|
1327
|
-
@RequiredArgsConstructor
|
|
1328
|
-
@Slf4j
|
|
1329
|
-
public class SeedDataRunner implements CommandLineRunner {
|
|
1330
|
-
|
|
1331
|
-
private final SeedDataService seedDataService;
|
|
1332
|
-
|
|
1333
|
-
@Override
|
|
1334
|
-
public void run(String... args) {
|
|
1335
|
-
log.info("=== Starting Seed Data Initialization ===");
|
|
1336
|
-
|
|
1337
|
-
try {
|
|
1338
|
-
seedDataService.seedAll();
|
|
1339
|
-
log.info("=== Seed Data Initialization Completed ===");
|
|
1340
|
-
} catch (Exception e) {
|
|
1341
|
-
log.error("=== Seed Data Initialization Failed ===", e);
|
|
1342
|
-
// 起動は継続させる(テストデータが無くても動作は可能)
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
```
|
|
1347
|
-
|
|
1348
|
-
</details>
|
|
1349
|
-
|
|
1350
|
-
### 20.4.3 @PostConstruct を使用した代替実装
|
|
1351
|
-
|
|
1352
|
-
<details>
|
|
1353
|
-
<summary>SeedDataInitializer(@PostConstruct)</summary>
|
|
1354
|
-
|
|
1355
|
-
```java
|
|
1356
|
-
// src/main/java/com/example/accounting/infrastructure/seed/SeedDataInitializer.java
|
|
1357
|
-
package com.example.accounting.infrastructure.seed;
|
|
1358
|
-
|
|
1359
|
-
import jakarta.annotation.PostConstruct;
|
|
1360
|
-
import lombok.RequiredArgsConstructor;
|
|
1361
|
-
import lombok.extern.slf4j.Slf4j;
|
|
1362
|
-
import org.springframework.context.annotation.Profile;
|
|
1363
|
-
import org.springframework.stereotype.Component;
|
|
1364
|
-
|
|
1365
|
-
/**
|
|
1366
|
-
* @PostConstruct を使用した Seed データ投入
|
|
1367
|
-
*
|
|
1368
|
-
* CommandLineRunner より早いタイミングで実行される
|
|
1369
|
-
*/
|
|
1370
|
-
@Component
|
|
1371
|
-
@Profile({"dev", "local"})
|
|
1372
|
-
@RequiredArgsConstructor
|
|
1373
|
-
@Slf4j
|
|
1374
|
-
public class SeedDataInitializer {
|
|
1375
|
-
|
|
1376
|
-
private final SeedDataService seedDataService;
|
|
1377
|
-
|
|
1378
|
-
@PostConstruct
|
|
1379
|
-
public void initialize() {
|
|
1380
|
-
log.info("=== @PostConstruct Seed Data Initialization ===");
|
|
1381
|
-
|
|
1382
|
-
try {
|
|
1383
|
-
seedDataService.seedAll();
|
|
1384
|
-
log.info("=== Seed Data Initialization Completed ===");
|
|
1385
|
-
} catch (Exception e) {
|
|
1386
|
-
log.error("=== Seed Data Initialization Failed ===", e);
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
```
|
|
1391
|
-
|
|
1392
|
-
</details>
|
|
1393
|
-
|
|
1394
|
-
## 20.5 Seed データ投入テスト
|
|
1395
|
-
|
|
1396
|
-
<details>
|
|
1397
|
-
<summary>SeedDataServiceTest(JPA版)</summary>
|
|
1398
|
-
|
|
1399
|
-
```java
|
|
1400
|
-
// src/test/java/com/example/accounting/infrastructure/seed/SeedDataServiceTest.java
|
|
1401
|
-
package com.example.accounting.infrastructure.seed;
|
|
1402
|
-
|
|
1403
|
-
import com.example.accounting.domain.model.account.*;
|
|
1404
|
-
import com.example.accounting.domain.model.journal.*;
|
|
1405
|
-
import com.example.accounting.infrastructure.persistence.repository.*;
|
|
1406
|
-
import org.junit.jupiter.api.*;
|
|
1407
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
1408
|
-
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
|
1409
|
-
import org.springframework.context.annotation.Import;
|
|
1410
|
-
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
1411
|
-
import org.springframework.test.context.DynamicPropertySource;
|
|
1412
|
-
import org.testcontainers.containers.PostgreSQLContainer;
|
|
1413
|
-
import org.testcontainers.junit.jupiter.Container;
|
|
1414
|
-
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
1415
|
-
|
|
1416
|
-
import java.math.BigDecimal;
|
|
1417
|
-
|
|
1418
|
-
import static org.assertj.core.api.Assertions.*;
|
|
1419
|
-
|
|
1420
|
-
@DataJpaTest
|
|
1421
|
-
@Import(SeedDataService.class)
|
|
1422
|
-
@Testcontainers
|
|
1423
|
-
@DisplayName("Seedデータ投入(JPA)")
|
|
1424
|
-
class SeedDataServiceTest {
|
|
1425
|
-
|
|
1426
|
-
@Container
|
|
1427
|
-
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16")
|
|
1428
|
-
.withDatabaseName("testdb")
|
|
1429
|
-
.withUsername("testuser")
|
|
1430
|
-
.withPassword("testpass");
|
|
1431
|
-
|
|
1432
|
-
@DynamicPropertySource
|
|
1433
|
-
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
1434
|
-
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
1435
|
-
registry.add("spring.datasource.username", postgres::getUsername);
|
|
1436
|
-
registry.add("spring.datasource.password", postgres::getPassword);
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
@Autowired
|
|
1440
|
-
private SeedDataService seedDataService;
|
|
1441
|
-
|
|
1442
|
-
@Autowired
|
|
1443
|
-
private AccountJpaRepository accountRepository;
|
|
1444
|
-
|
|
1445
|
-
@Autowired
|
|
1446
|
-
private TaxTransactionJpaRepository taxTransactionRepository;
|
|
1447
|
-
|
|
1448
|
-
@Autowired
|
|
1449
|
-
private DepartmentJpaRepository departmentRepository;
|
|
1450
|
-
|
|
1451
|
-
@Autowired
|
|
1452
|
-
private JournalJpaRepository journalRepository;
|
|
1453
|
-
|
|
1454
|
-
@Nested
|
|
1455
|
-
@DisplayName("課税取引マスタ")
|
|
1456
|
-
class TaxTransactionSeed {
|
|
1457
|
-
|
|
1458
|
-
@Test
|
|
1459
|
-
@DisplayName("課税取引マスタのSeedデータを投入できる")
|
|
1460
|
-
void canSeedTaxTransactions() {
|
|
1461
|
-
// Act
|
|
1462
|
-
seedDataService.seedTaxTransactions();
|
|
1463
|
-
|
|
1464
|
-
// Assert
|
|
1465
|
-
var tax10 = taxTransactionRepository.findById("10");
|
|
1466
|
-
assertThat(tax10).isPresent();
|
|
1467
|
-
assertThat(tax10.get().getTaxName()).isEqualTo("標準税率10%");
|
|
1468
|
-
assertThat(tax10.get().getTaxRate()).isEqualByComparingTo(new BigDecimal("0.100"));
|
|
1469
|
-
|
|
1470
|
-
var tax08 = taxTransactionRepository.findById("08");
|
|
1471
|
-
assertThat(tax08).isPresent();
|
|
1472
|
-
assertThat(tax08.get().getTaxName()).isEqualTo("軽減税率8%");
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
@Nested
|
|
1477
|
-
@DisplayName("勘定科目マスタ")
|
|
1478
|
-
class AccountMasterSeed {
|
|
1479
|
-
|
|
1480
|
-
@BeforeEach
|
|
1481
|
-
void setUp() {
|
|
1482
|
-
seedDataService.seedTaxTransactions();
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
@Test
|
|
1486
|
-
@DisplayName("勘定科目マスタのSeedデータを投入できる")
|
|
1487
|
-
void canSeedAccountMasters() {
|
|
1488
|
-
// Act
|
|
1489
|
-
seedDataService.seedAccountMasters();
|
|
1490
|
-
|
|
1491
|
-
// Assert
|
|
1492
|
-
var cash = accountRepository.findById("11110");
|
|
1493
|
-
assertThat(cash).isPresent();
|
|
1494
|
-
assertThat(cash.get().getAccountName()).isEqualTo("現金");
|
|
1495
|
-
assertThat(cash.get().getBsPlType()).isEqualTo(BsPlType.BS);
|
|
1496
|
-
assertThat(cash.get().getDcType()).isEqualTo(AccountDcType.DEBIT);
|
|
1497
|
-
|
|
1498
|
-
var sales = accountRepository.findById("41110");
|
|
1499
|
-
assertThat(sales).isPresent();
|
|
1500
|
-
assertThat(sales.get().getAccountName()).isEqualTo("国内売上高");
|
|
1501
|
-
assertThat(sales.get().getBsPlType()).isEqualTo(BsPlType.PL);
|
|
1502
|
-
assertThat(sales.get().getDcType()).isEqualTo(AccountDcType.CREDIT);
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
@Test
|
|
1506
|
-
@DisplayName("重複実行しても既存データが上書きされない(冪等性)")
|
|
1507
|
-
void seedIsIdempotent() {
|
|
1508
|
-
// Act
|
|
1509
|
-
seedDataService.seedAccountMasters();
|
|
1510
|
-
seedDataService.seedAccountMasters(); // 2回目
|
|
1511
|
-
|
|
1512
|
-
// Assert
|
|
1513
|
-
var accounts = accountRepository.findAll();
|
|
1514
|
-
long cashCount = accounts.stream()
|
|
1515
|
-
.filter(a -> "11110".equals(a.getAccountCode()))
|
|
1516
|
-
.count();
|
|
1517
|
-
assertThat(cashCount).isEqualTo(1);
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
@Nested
|
|
1522
|
-
@DisplayName("部門マスタ")
|
|
1523
|
-
class DepartmentSeed {
|
|
1524
|
-
|
|
1525
|
-
@Test
|
|
1526
|
-
@DisplayName("部門マスタのSeedデータを投入できる")
|
|
1527
|
-
void canSeedDepartments() {
|
|
1528
|
-
// Act
|
|
1529
|
-
seedDataService.seedDepartments();
|
|
1530
|
-
|
|
1531
|
-
// Assert
|
|
1532
|
-
var company = departmentRepository.findById("10000");
|
|
1533
|
-
assertThat(company).isPresent();
|
|
1534
|
-
assertThat(company.get().getDepartmentName()).isEqualTo("全社");
|
|
1535
|
-
assertThat(company.get().getOrganizationLevel()).isEqualTo(0);
|
|
1536
|
-
|
|
1537
|
-
var sales = departmentRepository.findById("11110");
|
|
1538
|
-
assertThat(sales).isPresent();
|
|
1539
|
-
assertThat(sales.get().getDepartmentName()).isEqualTo("東日本営業課");
|
|
1540
|
-
assertThat(sales.get().getDepartmentPath()).isEqualTo("10000~11000~11100~11110");
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
@Nested
|
|
1545
|
-
@DisplayName("仕訳データ")
|
|
1546
|
-
class JournalSeed {
|
|
1547
|
-
|
|
1548
|
-
@BeforeEach
|
|
1549
|
-
void setUp() {
|
|
1550
|
-
seedDataService.seedTaxTransactions();
|
|
1551
|
-
seedDataService.seedAccountMasters();
|
|
1552
|
-
seedDataService.seedDepartments();
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
@Test
|
|
1556
|
-
@DisplayName("サンプル仕訳データを投入できる")
|
|
1557
|
-
void canSeedSampleJournals() {
|
|
1558
|
-
// Act
|
|
1559
|
-
seedDataService.seedSampleJournals();
|
|
1560
|
-
|
|
1561
|
-
// Assert
|
|
1562
|
-
// 期首仕訳
|
|
1563
|
-
var opening = journalRepository.findById("J2025040001");
|
|
1564
|
-
assertThat(opening).isPresent();
|
|
1565
|
-
assertThat(opening.get().getJournalSlipType()).isEqualTo(JournalSlipType.NORMAL);
|
|
1566
|
-
|
|
1567
|
-
// 売上仕訳
|
|
1568
|
-
var sales = journalRepository.findById("J2025040002");
|
|
1569
|
-
assertThat(sales).isPresent();
|
|
1570
|
-
assertThat(sales.get().getJournalSlipType()).isEqualTo(JournalSlipType.AUTO);
|
|
1571
|
-
|
|
1572
|
-
// CascadeType.ALL により明細も保存されていることを確認
|
|
1573
|
-
var salesWithDetails = journalRepository.findWithDetailsById("J2025040002");
|
|
1574
|
-
assertThat(salesWithDetails).isPresent();
|
|
1575
|
-
assertThat(salesWithDetails.get().getDetails()).hasSize(1);
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
@Test
|
|
1579
|
-
@DisplayName("仕訳の貸借一致を確認できる")
|
|
1580
|
-
void journalBalanceIsCorrect() {
|
|
1581
|
-
// Arrange
|
|
1582
|
-
seedDataService.seedSampleJournals();
|
|
1583
|
-
|
|
1584
|
-
// Act
|
|
1585
|
-
var journal = journalRepository.findWithDetailsById("J2025040002").orElseThrow();
|
|
1586
|
-
|
|
1587
|
-
// Assert
|
|
1588
|
-
var detail = journal.getDetails().get(0);
|
|
1589
|
-
BigDecimal debitSum = detail.getDcDetails().stream()
|
|
1590
|
-
.filter(d -> d.getDcType() == DcType.DEBIT)
|
|
1591
|
-
.map(JournalDcDetail::getAmount)
|
|
1592
|
-
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
1593
|
-
BigDecimal creditSum = detail.getDcDetails().stream()
|
|
1594
|
-
.filter(d -> d.getDcType() == DcType.CREDIT)
|
|
1595
|
-
.map(JournalDcDetail::getAmount)
|
|
1596
|
-
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
1597
|
-
|
|
1598
|
-
assertThat(debitSum).isEqualByComparingTo(creditSum);
|
|
1599
|
-
assertThat(debitSum).isEqualByComparingTo(new BigDecimal("330000"));
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
@Nested
|
|
1604
|
-
@DisplayName("全データ一括投入")
|
|
1605
|
-
class SeedAll {
|
|
1606
|
-
|
|
1607
|
-
@Test
|
|
1608
|
-
@DisplayName("全Seedデータを一括投入できる")
|
|
1609
|
-
void canSeedAll() {
|
|
1610
|
-
// Act
|
|
1611
|
-
seedDataService.seedAll();
|
|
1612
|
-
|
|
1613
|
-
// Assert
|
|
1614
|
-
assertThat(taxTransactionRepository.findById("10")).isPresent();
|
|
1615
|
-
assertThat(accountRepository.findById("11110")).isPresent();
|
|
1616
|
-
assertThat(departmentRepository.findById("10000")).isPresent();
|
|
1617
|
-
assertThat(journalRepository.findById("J2025040001")).isPresent();
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
```
|
|
1622
|
-
|
|
1623
|
-
</details>
|
|
1624
|
-
|
|
1625
|
-
## 20.6 データ投入順序
|
|
1626
|
-
|
|
1627
|
-
外部キー制約を考慮したデータ投入順序:
|
|
1628
|
-
|
|
1629
|
-
```plantuml
|
|
1630
|
-
@startuml
|
|
1631
|
-
|
|
1632
|
-
title Seedデータ投入順序(JPA CascadeType.ALL 活用)
|
|
1633
|
-
|
|
1634
|
-
|マスタデータ|
|
|
1635
|
-
start
|
|
1636
|
-
:課税取引マスタ;
|
|
1637
|
-
note right: 外部キー参照元\nFK制約なし
|
|
1638
|
-
:勘定科目マスタ;
|
|
1639
|
-
note right: 課税取引マスタを参照
|
|
1640
|
-
:勘定科目構成マスタ;
|
|
1641
|
-
note right: 勘定科目マスタを参照\n@OneToOne 関連
|
|
1642
|
-
:部門マスタ;
|
|
1643
|
-
:通貨マスタ;
|
|
1644
|
-
|
|
1645
|
-
|トランザクションデータ|
|
|
1646
|
-
:仕訳データ;
|
|
1647
|
-
note right
|
|
1648
|
-
CascadeType.ALL により
|
|
1649
|
-
明細も一括保存
|
|
1650
|
-
@OneToMany(cascade = ALL)
|
|
1651
|
-
end note
|
|
1652
|
-
|
|
1653
|
-
|残高データ|
|
|
1654
|
-
:日次勘定科目残高;
|
|
1655
|
-
note right: 仕訳から集計
|
|
1656
|
-
:月次勘定科目残高;
|
|
1657
|
-
note right: 日次残高から集計
|
|
1658
|
-
|
|
1659
|
-
stop
|
|
1660
|
-
|
|
1661
|
-
@enduml
|
|
1662
|
-
```
|
|
1663
|
-
|
|
1664
|
-
## まとめ
|
|
1665
|
-
|
|
1666
|
-
### MyBatis 版との違い
|
|
1667
|
-
|
|
1668
|
-
| 観点 | MyBatis 版 | JPA 版 |
|
|
1669
|
-
|------|-----------|--------|
|
|
1670
|
-
| Repository | Mapper インターフェース + XML | JpaRepository インターフェース |
|
|
1671
|
-
| マッピング | resultMap で日本語カラム ↔ 英語プロパティ | @Column で日本語カラム名を指定 |
|
|
1672
|
-
| 関連の保存 | 個別に INSERT | CascadeType.ALL で一括保存 |
|
|
1673
|
-
| テスト | @MybatisTest | @DataJpaTest |
|
|
1674
|
-
| クエリメソッド | XML に SQL を記述 | メソッド名規約 or @Query |
|
|
1675
|
-
| 存在確認 | findByCode() == null | existsById() |
|
|
1676
|
-
|
|
1677
|
-
### JPA 固有のポイント
|
|
1678
|
-
|
|
1679
|
-
1. **CascadeType.ALL によるカスケード保存**
|
|
1680
|
-
```java
|
|
1681
|
-
@OneToMany(mappedBy = "journal", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
1682
|
-
private List<JournalDetail> details = new ArrayList<>();
|
|
1683
|
-
```
|
|
1684
|
-
|
|
1685
|
-
2. **@PrePersist / @PreUpdate による自動タイムスタンプ**
|
|
1686
|
-
```java
|
|
1687
|
-
@PrePersist
|
|
1688
|
-
protected void onCreate() {
|
|
1689
|
-
if (createdAt == null) {
|
|
1690
|
-
createdAt = LocalDateTime.now();
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
```
|
|
1694
|
-
|
|
1695
|
-
3. **existsById() による存在確認**
|
|
1696
|
-
```java
|
|
1697
|
-
if (!accountRepository.existsById(account.getAccountCode())) {
|
|
1698
|
-
accountRepository.save(account);
|
|
1699
|
-
}
|
|
1700
|
-
```
|
|
1701
|
-
|
|
1702
|
-
4. **CommandLineRunner による起動時データ投入**
|
|
1703
|
-
```java
|
|
1704
|
-
@Component
|
|
1705
|
-
@Profile({"dev", "local"})
|
|
1706
|
-
public class SeedDataRunner implements CommandLineRunner {
|
|
1707
|
-
@Override
|
|
1708
|
-
public void run(String... args) {
|
|
1709
|
-
seedDataService.seedAll();
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
```
|
|
1713
|
-
|
|
1714
|
-
### 設計のポイント
|
|
1715
|
-
|
|
1716
|
-
1. **実務に即した勘定科目体系**
|
|
1717
|
-
- 製造業向けの科目構成
|
|
1718
|
-
- 管理会計区分による部門別損益
|
|
1719
|
-
- 消費税複数税率対応
|
|
1720
|
-
|
|
1721
|
-
2. **階層構造の管理**
|
|
1722
|
-
- 勘定科目のチルダ連結パス
|
|
1723
|
-
- 部門マスタの組織階層
|
|
1724
|
-
- 科目集計の効率化
|
|
1725
|
-
|
|
1726
|
-
3. **Seedデータの設計**
|
|
1727
|
-
- 外部キー制約を考慮した投入順序
|
|
1728
|
-
- 冪等性(重複実行時の安全性)
|
|
1729
|
-
- テスト可能な構造
|
|
1730
|
-
|
|
1731
|
-
4. **仕訳パターンの網羅**
|
|
1732
|
-
- 期首繰越仕訳
|
|
1733
|
-
- 売上・売掛金仕訳
|
|
1734
|
-
- 経費・消費税仕訳
|
|
1735
|
-
- 材料仕入仕訳
|
|
1736
|
-
- 給与支払仕訳
|
|
1737
|
-
- 入金・支払仕訳
|
|
1738
|
-
|
|
1739
|
-
### テーブル一覧(Seed対象)
|
|
1740
|
-
|
|
1741
|
-
| テーブル名 | 件数目安 | 説明 |
|
|
1742
|
-
|-----------|---------|------|
|
|
1743
|
-
| 課税取引マスタ | 5件 | 税率マスタ |
|
|
1744
|
-
| 勘定科目マスタ | 100件 | 科目マスタ |
|
|
1745
|
-
| 勘定科目構成マスタ | 100件 | 科目階層 |
|
|
1746
|
-
| 部門マスタ | 30件 | 組織マスタ |
|
|
1747
|
-
| 仕訳 | 10件 | サンプル仕訳 |
|
|
1748
|
-
| 日次勘定科目残高 | 50件 | 日次残高 |
|
|
1749
|
-
| 月次勘定科目残高 | 20件 | 月次残高 |
|
|
1750
|
-
|
|
1751
|
-
---
|
|
1752
|
-
|
|
1753
|
-
[← 第19章:赤黒とログの設計【ORM版】](./chapter19-orm.md) | [第21章:APIサービスの実装【ORM版】 →](./chapter21-orm.md)
|
|
1
|
+
# 第20章:財務会計データ設計(D社事例)【ORM版】
|
|
2
|
+
|
|
3
|
+
本章では、化粧品製造販売会社D社を題材として、Spring Data JPA を使用した財務会計システムのデータ設計と Seed データ実装を解説します。JPA の CascadeType.ALL によるカスケード保存や、CommandLineRunner による起動時データ投入を活用します。
|
|
4
|
+
|
|
5
|
+
## 20.1 D社の概要
|
|
6
|
+
|
|
7
|
+
### 20.1.1 会社プロファイル
|
|
8
|
+
|
|
9
|
+
D社は化粧品製造販売を主業とする中堅企業です。
|
|
10
|
+
|
|
11
|
+
| 項目 | 内容 |
|
|
12
|
+
|------|------|
|
|
13
|
+
| 業種 | 化粧品製造販売 |
|
|
14
|
+
| 資本金 | 5億円 |
|
|
15
|
+
| 従業員数 | 300名 |
|
|
16
|
+
| 年間売上高 | 80億円 |
|
|
17
|
+
| 決算期 | 3月 |
|
|
18
|
+
| 経理体制 | 経理部10名、財務課3名 |
|
|
19
|
+
|
|
20
|
+
### 20.1.2 企業概要
|
|
21
|
+
|
|
22
|
+
```plantuml
|
|
23
|
+
@startuml
|
|
24
|
+
title D社 企業概要
|
|
25
|
+
|
|
26
|
+
left to right direction
|
|
27
|
+
|
|
28
|
+
rectangle "D社(化粧品製造販売)" as company {
|
|
29
|
+
|
|
30
|
+
card info [
|
|
31
|
+
**基本情報**
|
|
32
|
+
----
|
|
33
|
+
資本金: 5億円
|
|
34
|
+
従業員: 300名
|
|
35
|
+
売上高: 80億円/年
|
|
36
|
+
決算期: 3月
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
card business [
|
|
40
|
+
**事業内容**
|
|
41
|
+
----
|
|
42
|
+
スキンケア製品製造
|
|
43
|
+
メイクアップ製品製造
|
|
44
|
+
OEM/ODM受託製造
|
|
45
|
+
直営店舗運営
|
|
46
|
+
EC販売
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
card feature [
|
|
50
|
+
**特徴**
|
|
51
|
+
----
|
|
52
|
+
原価管理重視
|
|
53
|
+
部門別損益管理
|
|
54
|
+
プロジェクト別収益管理
|
|
55
|
+
消費税複数税率対応
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@enduml
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 20.2 組織構成
|
|
63
|
+
|
|
64
|
+
### 20.2.1 組織図
|
|
65
|
+
|
|
66
|
+
```plantuml
|
|
67
|
+
@startwbs
|
|
68
|
+
|
|
69
|
+
title D社 組織図
|
|
70
|
+
|
|
71
|
+
* 代表取締役
|
|
72
|
+
** 営業本部
|
|
73
|
+
*** 国内営業部
|
|
74
|
+
**** 東日本営業課
|
|
75
|
+
**** 西日本営業課
|
|
76
|
+
*** 海外営業部
|
|
77
|
+
**** 北米課
|
|
78
|
+
**** アジア課
|
|
79
|
+
*** EC事業部
|
|
80
|
+
**** 自社EC課
|
|
81
|
+
**** モール課
|
|
82
|
+
** 製造本部
|
|
83
|
+
*** 製造部
|
|
84
|
+
**** 第一製造課
|
|
85
|
+
**** 第二製造課
|
|
86
|
+
*** 品質管理部
|
|
87
|
+
**** 品質保証課
|
|
88
|
+
**** 検査課
|
|
89
|
+
*** 研究開発部
|
|
90
|
+
**** 基礎研究課
|
|
91
|
+
**** 応用開発課
|
|
92
|
+
** 管理本部
|
|
93
|
+
*** 経理部
|
|
94
|
+
**** 財務課
|
|
95
|
+
**** 主計課
|
|
96
|
+
**** 税務課
|
|
97
|
+
*** 総務部
|
|
98
|
+
**** 人事課
|
|
99
|
+
**** 庶務課
|
|
100
|
+
*** 情報システム部
|
|
101
|
+
|
|
102
|
+
@endwbs
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 20.2.2 部門コード体系
|
|
106
|
+
|
|
107
|
+
| 部門コード | 部門名 | 組織階層 | 部門パス |
|
|
108
|
+
|-----------|--------|----------|----------|
|
|
109
|
+
| 10000 | 全社 | 0 | 10000 |
|
|
110
|
+
| 11000 | 営業本部 | 1 | 10000~11000 |
|
|
111
|
+
| 11100 | 国内営業部 | 2 | 10000~11000~11100 |
|
|
112
|
+
| 11110 | 東日本営業課 | 3 | 10000~11000~11100~11110 |
|
|
113
|
+
| 11120 | 西日本営業課 | 3 | 10000~11000~11100~11120 |
|
|
114
|
+
| 12000 | 製造本部 | 1 | 10000~12000 |
|
|
115
|
+
| 12100 | 製造部 | 2 | 10000~12000~12100 |
|
|
116
|
+
| 13000 | 管理本部 | 1 | 10000~13000 |
|
|
117
|
+
| 13100 | 経理部 | 2 | 10000~13000~13100 |
|
|
118
|
+
|
|
119
|
+
### 20.2.3 部門エンティティ(JPA)
|
|
120
|
+
|
|
121
|
+
<details>
|
|
122
|
+
<summary>Department エンティティ</summary>
|
|
123
|
+
|
|
124
|
+
```java
|
|
125
|
+
// src/main/java/com/example/accounting/domain/model/department/Department.java
|
|
126
|
+
package com.example.accounting.domain.model.department;
|
|
127
|
+
|
|
128
|
+
import jakarta.persistence.*;
|
|
129
|
+
import lombok.*;
|
|
130
|
+
|
|
131
|
+
import java.time.LocalDateTime;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 部門エンティティ
|
|
135
|
+
*/
|
|
136
|
+
@Entity
|
|
137
|
+
@Table(name = "部門マスタ")
|
|
138
|
+
@Data
|
|
139
|
+
@Builder
|
|
140
|
+
@NoArgsConstructor
|
|
141
|
+
@AllArgsConstructor
|
|
142
|
+
public class Department {
|
|
143
|
+
|
|
144
|
+
@Id
|
|
145
|
+
@Column(name = "部門コード", length = 5)
|
|
146
|
+
private String departmentCode;
|
|
147
|
+
|
|
148
|
+
@Column(name = "部門名", length = 40, nullable = false)
|
|
149
|
+
private String departmentName;
|
|
150
|
+
|
|
151
|
+
@Column(name = "組織階層")
|
|
152
|
+
private Integer organizationLevel;
|
|
153
|
+
|
|
154
|
+
@Column(name = "部門パス", length = 100)
|
|
155
|
+
private String departmentPath;
|
|
156
|
+
|
|
157
|
+
@Column(name = "最下層区分")
|
|
158
|
+
private Integer lowestLevelFlag;
|
|
159
|
+
|
|
160
|
+
@Column(name = "作成日時")
|
|
161
|
+
private LocalDateTime createdAt;
|
|
162
|
+
|
|
163
|
+
@Column(name = "更新日時")
|
|
164
|
+
private LocalDateTime updatedAt;
|
|
165
|
+
|
|
166
|
+
@Column(name = "更新者名", length = 20)
|
|
167
|
+
private String updatedBy;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 最下層(末端)部門かどうか
|
|
171
|
+
*/
|
|
172
|
+
public boolean isLeaf() {
|
|
173
|
+
return lowestLevelFlag != null && lowestLevelFlag == 1;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 部門パスから親部門コードを取得
|
|
178
|
+
*/
|
|
179
|
+
public String getParentDepartmentCode() {
|
|
180
|
+
if (departmentPath == null || !departmentPath.contains("~")) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
String[] parts = departmentPath.split("~");
|
|
184
|
+
if (parts.length < 2) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return parts[parts.length - 2];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@PrePersist
|
|
191
|
+
protected void onCreate() {
|
|
192
|
+
if (createdAt == null) {
|
|
193
|
+
createdAt = LocalDateTime.now();
|
|
194
|
+
}
|
|
195
|
+
if (updatedAt == null) {
|
|
196
|
+
updatedAt = LocalDateTime.now();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@PreUpdate
|
|
201
|
+
protected void onUpdate() {
|
|
202
|
+
updatedAt = LocalDateTime.now();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
</details>
|
|
208
|
+
|
|
209
|
+
### 20.2.4 部門リポジトリ(JPA)
|
|
210
|
+
|
|
211
|
+
<details>
|
|
212
|
+
<summary>DepartmentJpaRepository インターフェース</summary>
|
|
213
|
+
|
|
214
|
+
```java
|
|
215
|
+
// src/main/java/com/example/accounting/infrastructure/persistence/repository/DepartmentJpaRepository.java
|
|
216
|
+
package com.example.accounting.infrastructure.persistence.repository;
|
|
217
|
+
|
|
218
|
+
import com.example.accounting.domain.model.department.Department;
|
|
219
|
+
import org.springframework.data.jpa.repository.JpaRepository;
|
|
220
|
+
import org.springframework.data.jpa.repository.Query;
|
|
221
|
+
import org.springframework.data.repository.query.Param;
|
|
222
|
+
import org.springframework.stereotype.Repository;
|
|
223
|
+
|
|
224
|
+
import java.util.List;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 部門リポジトリ(Spring Data JPA)
|
|
228
|
+
*/
|
|
229
|
+
@Repository
|
|
230
|
+
public interface DepartmentJpaRepository extends JpaRepository<Department, String> {
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 組織階層で検索する
|
|
234
|
+
*/
|
|
235
|
+
List<Department> findByOrganizationLevel(Integer level);
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 部門パスで前方一致検索する(配下の部門を取得)
|
|
239
|
+
*/
|
|
240
|
+
@Query("SELECT d FROM Department d WHERE d.departmentPath LIKE CONCAT(:pathPrefix, '%') ORDER BY d.departmentPath")
|
|
241
|
+
List<Department> findByDepartmentPathStartsWith(@Param("pathPrefix") String pathPrefix);
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 最下層部門のみ検索する
|
|
245
|
+
*/
|
|
246
|
+
List<Department> findByLowestLevelFlag(Integer flag);
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 最下層部門のみ検索する(便利メソッド)
|
|
250
|
+
*/
|
|
251
|
+
default List<Department> findLeafDepartments() {
|
|
252
|
+
return findByLowestLevelFlag(1);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 部門コード順で全件取得
|
|
257
|
+
*/
|
|
258
|
+
List<Department> findAllByOrderByDepartmentCodeAsc();
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
</details>
|
|
263
|
+
|
|
264
|
+
### 20.2.5 部門リポジトリのテスト(JPA)
|
|
265
|
+
|
|
266
|
+
<details>
|
|
267
|
+
<summary>DepartmentJpaRepositoryTest</summary>
|
|
268
|
+
|
|
269
|
+
```java
|
|
270
|
+
// src/test/java/com/example/accounting/infrastructure/persistence/repository/DepartmentJpaRepositoryTest.java
|
|
271
|
+
package com.example.accounting.infrastructure.persistence.repository;
|
|
272
|
+
|
|
273
|
+
import com.example.accounting.domain.model.department.Department;
|
|
274
|
+
import org.junit.jupiter.api.*;
|
|
275
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
|
276
|
+
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
|
277
|
+
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
278
|
+
import org.springframework.test.context.DynamicPropertySource;
|
|
279
|
+
import org.testcontainers.containers.PostgreSQLContainer;
|
|
280
|
+
import org.testcontainers.junit.jupiter.Container;
|
|
281
|
+
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
282
|
+
|
|
283
|
+
import static org.assertj.core.api.Assertions.*;
|
|
284
|
+
|
|
285
|
+
@DataJpaTest
|
|
286
|
+
@Testcontainers
|
|
287
|
+
@DisplayName("部門リポジトリ(JPA)")
|
|
288
|
+
class DepartmentJpaRepositoryTest {
|
|
289
|
+
|
|
290
|
+
@Container
|
|
291
|
+
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16")
|
|
292
|
+
.withDatabaseName("testdb")
|
|
293
|
+
.withUsername("testuser")
|
|
294
|
+
.withPassword("testpass");
|
|
295
|
+
|
|
296
|
+
@DynamicPropertySource
|
|
297
|
+
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
298
|
+
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
299
|
+
registry.add("spring.datasource.username", postgres::getUsername);
|
|
300
|
+
registry.add("spring.datasource.password", postgres::getPassword);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@Autowired
|
|
304
|
+
private DepartmentJpaRepository departmentRepository;
|
|
305
|
+
|
|
306
|
+
@BeforeEach
|
|
307
|
+
void setUp() {
|
|
308
|
+
departmentRepository.deleteAll();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
@Nested
|
|
312
|
+
@DisplayName("登録")
|
|
313
|
+
class Insert {
|
|
314
|
+
|
|
315
|
+
@Test
|
|
316
|
+
@DisplayName("部門を登録できる")
|
|
317
|
+
void canInsertDepartment() {
|
|
318
|
+
// Arrange
|
|
319
|
+
var department = Department.builder()
|
|
320
|
+
.departmentCode("10000")
|
|
321
|
+
.departmentName("全社")
|
|
322
|
+
.organizationLevel(0)
|
|
323
|
+
.departmentPath("10000")
|
|
324
|
+
.lowestLevelFlag(0)
|
|
325
|
+
.build();
|
|
326
|
+
|
|
327
|
+
// Act
|
|
328
|
+
departmentRepository.save(department);
|
|
329
|
+
|
|
330
|
+
// Assert
|
|
331
|
+
var result = departmentRepository.findById("10000");
|
|
332
|
+
assertThat(result).isPresent();
|
|
333
|
+
assertThat(result.get().getDepartmentName()).isEqualTo("全社");
|
|
334
|
+
assertThat(result.get().getOrganizationLevel()).isEqualTo(0);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
@Test
|
|
338
|
+
@DisplayName("階層構造を持つ部門を登録できる")
|
|
339
|
+
void canInsertHierarchicalDepartments() {
|
|
340
|
+
// Arrange & Act
|
|
341
|
+
departmentRepository.save(Department.builder()
|
|
342
|
+
.departmentCode("10000")
|
|
343
|
+
.departmentName("全社")
|
|
344
|
+
.organizationLevel(0)
|
|
345
|
+
.departmentPath("10000")
|
|
346
|
+
.lowestLevelFlag(0)
|
|
347
|
+
.build());
|
|
348
|
+
|
|
349
|
+
departmentRepository.save(Department.builder()
|
|
350
|
+
.departmentCode("11000")
|
|
351
|
+
.departmentName("営業本部")
|
|
352
|
+
.organizationLevel(1)
|
|
353
|
+
.departmentPath("10000~11000")
|
|
354
|
+
.lowestLevelFlag(0)
|
|
355
|
+
.build());
|
|
356
|
+
|
|
357
|
+
departmentRepository.save(Department.builder()
|
|
358
|
+
.departmentCode("11110")
|
|
359
|
+
.departmentName("東日本営業課")
|
|
360
|
+
.organizationLevel(3)
|
|
361
|
+
.departmentPath("10000~11000~11100~11110")
|
|
362
|
+
.lowestLevelFlag(1)
|
|
363
|
+
.build());
|
|
364
|
+
|
|
365
|
+
// Assert
|
|
366
|
+
var result = departmentRepository.findById("11110");
|
|
367
|
+
assertThat(result).isPresent();
|
|
368
|
+
assertThat(result.get().getDepartmentPath()).isEqualTo("10000~11000~11100~11110");
|
|
369
|
+
assertThat(result.get().isLeaf()).isTrue();
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
@Nested
|
|
374
|
+
@DisplayName("検索")
|
|
375
|
+
class Search {
|
|
376
|
+
|
|
377
|
+
@BeforeEach
|
|
378
|
+
void setUpTestData() {
|
|
379
|
+
departmentRepository.save(Department.builder()
|
|
380
|
+
.departmentCode("10000")
|
|
381
|
+
.departmentName("全社")
|
|
382
|
+
.organizationLevel(0)
|
|
383
|
+
.departmentPath("10000")
|
|
384
|
+
.lowestLevelFlag(0)
|
|
385
|
+
.build());
|
|
386
|
+
|
|
387
|
+
departmentRepository.save(Department.builder()
|
|
388
|
+
.departmentCode("11000")
|
|
389
|
+
.departmentName("営業本部")
|
|
390
|
+
.organizationLevel(1)
|
|
391
|
+
.departmentPath("10000~11000")
|
|
392
|
+
.lowestLevelFlag(0)
|
|
393
|
+
.build());
|
|
394
|
+
|
|
395
|
+
departmentRepository.save(Department.builder()
|
|
396
|
+
.departmentCode("11110")
|
|
397
|
+
.departmentName("東日本営業課")
|
|
398
|
+
.organizationLevel(3)
|
|
399
|
+
.departmentPath("10000~11000~11100~11110")
|
|
400
|
+
.lowestLevelFlag(1)
|
|
401
|
+
.build());
|
|
402
|
+
|
|
403
|
+
departmentRepository.save(Department.builder()
|
|
404
|
+
.departmentCode("12000")
|
|
405
|
+
.departmentName("製造本部")
|
|
406
|
+
.organizationLevel(1)
|
|
407
|
+
.departmentPath("10000~12000")
|
|
408
|
+
.lowestLevelFlag(0)
|
|
409
|
+
.build());
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
@Test
|
|
413
|
+
@DisplayName("組織階層で検索できる")
|
|
414
|
+
void canFindByOrganizationLevel() {
|
|
415
|
+
// Act
|
|
416
|
+
var result = departmentRepository.findByOrganizationLevel(1);
|
|
417
|
+
|
|
418
|
+
// Assert
|
|
419
|
+
assertThat(result).hasSize(2);
|
|
420
|
+
assertThat(result).extracting(Department::getDepartmentCode)
|
|
421
|
+
.containsExactlyInAnyOrder("11000", "12000");
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
@Test
|
|
425
|
+
@DisplayName("部門パスで配下の部門を検索できる")
|
|
426
|
+
void canFindByDepartmentPathStartsWith() {
|
|
427
|
+
// Act
|
|
428
|
+
var result = departmentRepository.findByDepartmentPathStartsWith("10000~11000");
|
|
429
|
+
|
|
430
|
+
// Assert
|
|
431
|
+
assertThat(result).hasSize(2);
|
|
432
|
+
assertThat(result).extracting(Department::getDepartmentCode)
|
|
433
|
+
.containsExactlyInAnyOrder("11000", "11110");
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
@Test
|
|
437
|
+
@DisplayName("最下層部門のみ検索できる")
|
|
438
|
+
void canFindLeafDepartments() {
|
|
439
|
+
// Act
|
|
440
|
+
var result = departmentRepository.findLeafDepartments();
|
|
441
|
+
|
|
442
|
+
// Assert
|
|
443
|
+
assertThat(result).hasSize(1);
|
|
444
|
+
assertThat(result.get(0).getDepartmentCode()).isEqualTo("11110");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
</details>
|
|
451
|
+
|
|
452
|
+
## 20.3 勘定科目体系
|
|
453
|
+
|
|
454
|
+
### 20.3.1 勘定科目の構成
|
|
455
|
+
|
|
456
|
+
D社の勘定科目は、貸借対照表(BS)科目と損益計算書(PL)科目で構成されています。
|
|
457
|
+
|
|
458
|
+
```plantuml
|
|
459
|
+
@startwbs
|
|
460
|
+
|
|
461
|
+
title D社 貸借対照表科目(抜粋)
|
|
462
|
+
|
|
463
|
+
* 貸借対照表
|
|
464
|
+
** (資産の部)
|
|
465
|
+
*** 流動資産
|
|
466
|
+
**** 現金及び預金
|
|
467
|
+
***** 現金
|
|
468
|
+
***** 当座預金
|
|
469
|
+
***** 普通預金
|
|
470
|
+
**** 売上債権
|
|
471
|
+
***** 売掛金
|
|
472
|
+
***** 受取手形
|
|
473
|
+
**** 棚卸資産
|
|
474
|
+
***** 製品
|
|
475
|
+
***** 仕掛品
|
|
476
|
+
***** 原材料
|
|
477
|
+
***** 貯蔵品
|
|
478
|
+
**** その他流動資産
|
|
479
|
+
***** 前払費用
|
|
480
|
+
***** 仮払消費税
|
|
481
|
+
*** 固定資産
|
|
482
|
+
**** 有形固定資産
|
|
483
|
+
***** 建物
|
|
484
|
+
***** 機械装置
|
|
485
|
+
***** 工具器具備品
|
|
486
|
+
**** 無形固定資産
|
|
487
|
+
***** ソフトウェア
|
|
488
|
+
** (負債の部)
|
|
489
|
+
*** 流動負債
|
|
490
|
+
**** 仕入債務
|
|
491
|
+
***** 買掛金
|
|
492
|
+
***** 支払手形
|
|
493
|
+
**** その他流動負債
|
|
494
|
+
***** 未払金
|
|
495
|
+
***** 未払費用
|
|
496
|
+
***** 仮受消費税
|
|
497
|
+
***** 預り金
|
|
498
|
+
*** 固定負債
|
|
499
|
+
**** 長期借入金
|
|
500
|
+
** (純資産の部)
|
|
501
|
+
*** 資本金
|
|
502
|
+
*** 資本剰余金
|
|
503
|
+
*** 利益剰余金
|
|
504
|
+
|
|
505
|
+
@endwbs
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### 20.3.2 主要勘定科目一覧
|
|
509
|
+
|
|
510
|
+
**資産(BS借方)**
|
|
511
|
+
|
|
512
|
+
| コード | 科目名 | 補助科目 | 説明 |
|
|
513
|
+
|--------|--------|----------|------|
|
|
514
|
+
| 11110 | 現金 | - | 手元現金 |
|
|
515
|
+
| 11130 | 普通預金 | 必須 | 銀行別管理 |
|
|
516
|
+
| 11210 | 売掛金 | 必須 | 得意先別管理 |
|
|
517
|
+
| 11330 | 原材料 | 必須 | 品目別管理 |
|
|
518
|
+
| 11430 | 仮払消費税 | - | 消費税処理用 |
|
|
519
|
+
|
|
520
|
+
**負債・純資産・収益・費用**
|
|
521
|
+
|
|
522
|
+
| コード | 科目名 | 消費税 | 説明 |
|
|
523
|
+
|--------|--------|--------|------|
|
|
524
|
+
| 21110 | 買掛金 | - | 仕入先別管理 |
|
|
525
|
+
| 21240 | 仮受消費税 | - | 消費税処理用 |
|
|
526
|
+
| 33200 | 繰越利益剰余金 | - | 留保利益 |
|
|
527
|
+
| 41110 | 国内売上高 | 課税10% | 国内向け売上 |
|
|
528
|
+
| 62100 | 旅費交通費 | 課税10% | 出張費等 |
|
|
529
|
+
|
|
530
|
+
### 20.3.3 会計処理のパターン
|
|
531
|
+
|
|
532
|
+
```plantuml
|
|
533
|
+
@startuml
|
|
534
|
+
|
|
535
|
+
title D社 主要な取引と仕訳パターン
|
|
536
|
+
|
|
537
|
+
left to right direction
|
|
538
|
+
|
|
539
|
+
rectangle "販売取引" {
|
|
540
|
+
card sales [
|
|
541
|
+
**売上計上**
|
|
542
|
+
----
|
|
543
|
+
借方: 売掛金
|
|
544
|
+
貸方: 売上高
|
|
545
|
+
貸方: 仮受消費税
|
|
546
|
+
]
|
|
547
|
+
|
|
548
|
+
card receipt [
|
|
549
|
+
**入金**
|
|
550
|
+
----
|
|
551
|
+
借方: 普通預金
|
|
552
|
+
貸方: 売掛金
|
|
553
|
+
]
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
rectangle "製造取引" {
|
|
557
|
+
card material [
|
|
558
|
+
**材料仕入**
|
|
559
|
+
----
|
|
560
|
+
借方: 原材料
|
|
561
|
+
借方: 仮払消費税
|
|
562
|
+
貸方: 買掛金
|
|
563
|
+
]
|
|
564
|
+
|
|
565
|
+
card expense [
|
|
566
|
+
**製造経費**
|
|
567
|
+
----
|
|
568
|
+
借方: 製造間接費
|
|
569
|
+
借方: 仮払消費税
|
|
570
|
+
貸方: 未払金
|
|
571
|
+
]
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
rectangle "一般取引" {
|
|
575
|
+
card exp [
|
|
576
|
+
**経費精算**
|
|
577
|
+
----
|
|
578
|
+
借方: 旅費交通費/消耗品費
|
|
579
|
+
借方: 仮払消費税
|
|
580
|
+
貸方: 現金/未払金
|
|
581
|
+
]
|
|
582
|
+
|
|
583
|
+
card salary [
|
|
584
|
+
**給与支払**
|
|
585
|
+
----
|
|
586
|
+
借方: 給料手当
|
|
587
|
+
貸方: 普通預金
|
|
588
|
+
貸方: 預り金(税・社保)
|
|
589
|
+
]
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
@enduml
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
## 20.4 Seed データ投入サービス(JPA版)
|
|
596
|
+
|
|
597
|
+
### 20.4.1 SeedDataService
|
|
598
|
+
|
|
599
|
+
JPA の CascadeType.ALL を活用し、仕訳と明細を一括保存します。
|
|
600
|
+
|
|
601
|
+
<details>
|
|
602
|
+
<summary>SeedDataService(JPA版)</summary>
|
|
603
|
+
|
|
604
|
+
```java
|
|
605
|
+
// src/main/java/com/example/accounting/infrastructure/seed/SeedDataService.java
|
|
606
|
+
package com.example.accounting.infrastructure.seed;
|
|
607
|
+
|
|
608
|
+
import com.example.accounting.domain.model.account.*;
|
|
609
|
+
import com.example.accounting.domain.model.department.*;
|
|
610
|
+
import com.example.accounting.domain.model.journal.*;
|
|
611
|
+
import com.example.accounting.domain.model.tax.*;
|
|
612
|
+
import com.example.accounting.infrastructure.persistence.repository.*;
|
|
613
|
+
import lombok.RequiredArgsConstructor;
|
|
614
|
+
import lombok.extern.slf4j.Slf4j;
|
|
615
|
+
import org.springframework.stereotype.Service;
|
|
616
|
+
import org.springframework.transaction.annotation.Transactional;
|
|
617
|
+
|
|
618
|
+
import java.math.BigDecimal;
|
|
619
|
+
import java.time.LocalDate;
|
|
620
|
+
import java.util.ArrayList;
|
|
621
|
+
import java.util.List;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Seed データ投入サービス(JPA 版)
|
|
625
|
+
*/
|
|
626
|
+
@Service
|
|
627
|
+
@RequiredArgsConstructor
|
|
628
|
+
@Slf4j
|
|
629
|
+
public class SeedDataService {
|
|
630
|
+
|
|
631
|
+
private final AccountJpaRepository accountRepository;
|
|
632
|
+
private final AccountStructureJpaRepository accountStructureRepository;
|
|
633
|
+
private final TaxTransactionJpaRepository taxTransactionRepository;
|
|
634
|
+
private final DepartmentJpaRepository departmentRepository;
|
|
635
|
+
private final JournalJpaRepository journalRepository;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* 全Seedデータを投入
|
|
639
|
+
*/
|
|
640
|
+
@Transactional
|
|
641
|
+
public void seedAll() {
|
|
642
|
+
log.info("Starting seed data insertion...");
|
|
643
|
+
|
|
644
|
+
seedTaxTransactions();
|
|
645
|
+
seedAccountMasters();
|
|
646
|
+
seedAccountStructures();
|
|
647
|
+
seedDepartments();
|
|
648
|
+
seedSampleJournals();
|
|
649
|
+
|
|
650
|
+
log.info("Seed data insertion completed.");
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* 課税取引マスタのSeedデータ
|
|
655
|
+
*/
|
|
656
|
+
@Transactional
|
|
657
|
+
public void seedTaxTransactions() {
|
|
658
|
+
log.info("Seeding tax transactions...");
|
|
659
|
+
|
|
660
|
+
List<TaxTransaction> taxes = List.of(
|
|
661
|
+
TaxTransaction.builder()
|
|
662
|
+
.taxCode("00").taxName("免税").taxRate(BigDecimal.ZERO).build(),
|
|
663
|
+
TaxTransaction.builder()
|
|
664
|
+
.taxCode("08").taxName("軽減税率8%").taxRate(new BigDecimal("0.080")).build(),
|
|
665
|
+
TaxTransaction.builder()
|
|
666
|
+
.taxCode("10").taxName("標準税率10%").taxRate(new BigDecimal("0.100")).build(),
|
|
667
|
+
TaxTransaction.builder()
|
|
668
|
+
.taxCode("80").taxName("非課税").taxRate(BigDecimal.ZERO).build(),
|
|
669
|
+
TaxTransaction.builder()
|
|
670
|
+
.taxCode("99").taxName("対象外").taxRate(BigDecimal.ZERO).build()
|
|
671
|
+
);
|
|
672
|
+
|
|
673
|
+
int insertedCount = 0;
|
|
674
|
+
for (TaxTransaction tax : taxes) {
|
|
675
|
+
if (!taxTransactionRepository.existsById(tax.getTaxCode())) {
|
|
676
|
+
taxTransactionRepository.save(tax);
|
|
677
|
+
insertedCount++;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
log.info("Tax transactions seeded: {} records", insertedCount);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* 勘定科目マスタのSeedデータ
|
|
686
|
+
*/
|
|
687
|
+
@Transactional
|
|
688
|
+
public void seedAccountMasters() {
|
|
689
|
+
log.info("Seeding account masters...");
|
|
690
|
+
|
|
691
|
+
List<Account> accounts = createAccountMasterSeedData();
|
|
692
|
+
|
|
693
|
+
int insertedCount = 0;
|
|
694
|
+
for (Account account : accounts) {
|
|
695
|
+
if (!accountRepository.existsById(account.getAccountCode())) {
|
|
696
|
+
accountRepository.save(account);
|
|
697
|
+
insertedCount++;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
log.info("Account masters seeded: {} records", insertedCount);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* 勘定科目構成マスタのSeedデータ
|
|
706
|
+
*/
|
|
707
|
+
@Transactional
|
|
708
|
+
public void seedAccountStructures() {
|
|
709
|
+
log.info("Seeding account structures...");
|
|
710
|
+
|
|
711
|
+
List<Account> accounts = accountRepository.findAll();
|
|
712
|
+
|
|
713
|
+
int insertedCount = 0;
|
|
714
|
+
for (Account account : accounts) {
|
|
715
|
+
if (!accountStructureRepository.existsById(account.getAccountCode())) {
|
|
716
|
+
String path = generateAccountPath(account);
|
|
717
|
+
AccountStructure structure = AccountStructure.builder()
|
|
718
|
+
.accountCode(account.getAccountCode())
|
|
719
|
+
.accountPath(path)
|
|
720
|
+
.account(account)
|
|
721
|
+
.build();
|
|
722
|
+
accountStructureRepository.save(structure);
|
|
723
|
+
insertedCount++;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
log.info("Account structures seeded: {} records", insertedCount);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* 部門マスタのSeedデータ
|
|
732
|
+
*/
|
|
733
|
+
@Transactional
|
|
734
|
+
public void seedDepartments() {
|
|
735
|
+
log.info("Seeding departments...");
|
|
736
|
+
|
|
737
|
+
List<Department> departments = createDepartmentSeedData();
|
|
738
|
+
|
|
739
|
+
int insertedCount = 0;
|
|
740
|
+
for (Department dept : departments) {
|
|
741
|
+
if (!departmentRepository.existsById(dept.getDepartmentCode())) {
|
|
742
|
+
departmentRepository.save(dept);
|
|
743
|
+
insertedCount++;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
log.info("Departments seeded: {} records", insertedCount);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* サンプル仕訳データのSeed
|
|
752
|
+
*/
|
|
753
|
+
@Transactional
|
|
754
|
+
public void seedSampleJournals() {
|
|
755
|
+
log.info("Seeding sample journals...");
|
|
756
|
+
|
|
757
|
+
// 期首仕訳
|
|
758
|
+
createOpeningJournal();
|
|
759
|
+
|
|
760
|
+
// 売上仕訳
|
|
761
|
+
createSalesJournal();
|
|
762
|
+
|
|
763
|
+
// 経費仕訳
|
|
764
|
+
createExpenseJournal();
|
|
765
|
+
|
|
766
|
+
// 材料仕入仕訳
|
|
767
|
+
createMaterialPurchaseJournal();
|
|
768
|
+
|
|
769
|
+
// 給与支払仕訳
|
|
770
|
+
createSalaryJournal();
|
|
771
|
+
|
|
772
|
+
// 入金仕訳
|
|
773
|
+
createReceiptJournal();
|
|
774
|
+
|
|
775
|
+
// 支払仕訳
|
|
776
|
+
createPaymentJournal();
|
|
777
|
+
|
|
778
|
+
log.info("Sample journals seeded.");
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
private void createOpeningJournal() {
|
|
782
|
+
String journalNumber = "J2025040001";
|
|
783
|
+
|
|
784
|
+
if (journalRepository.existsById(journalNumber)) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
LocalDate date = LocalDate.of(2025, 4, 1);
|
|
789
|
+
|
|
790
|
+
// 仕訳ヘッダ
|
|
791
|
+
Journal journal = Journal.builder()
|
|
792
|
+
.journalNumber(journalNumber)
|
|
793
|
+
.postingDate(date)
|
|
794
|
+
.inputDate(date)
|
|
795
|
+
.closingJournalFlag(0)
|
|
796
|
+
.singleFlag(0)
|
|
797
|
+
.journalSlipType(JournalSlipType.NORMAL)
|
|
798
|
+
.departmentCode("13100")
|
|
799
|
+
.build();
|
|
800
|
+
|
|
801
|
+
// 仕訳明細
|
|
802
|
+
JournalDetail detail = JournalDetail.builder()
|
|
803
|
+
.lineNumber(1)
|
|
804
|
+
.lineDescription("前期繰越")
|
|
805
|
+
.build();
|
|
806
|
+
detail.setJournal(journal);
|
|
807
|
+
|
|
808
|
+
// 借方:普通預金
|
|
809
|
+
JournalDcDetail debit = JournalDcDetail.builder()
|
|
810
|
+
.dcType(DcType.DEBIT)
|
|
811
|
+
.accountCode("11130")
|
|
812
|
+
.amount(new BigDecimal("50000000"))
|
|
813
|
+
.build();
|
|
814
|
+
debit.setJournalDetail(detail);
|
|
815
|
+
|
|
816
|
+
// 貸方:繰越利益剰余金
|
|
817
|
+
JournalDcDetail credit = JournalDcDetail.builder()
|
|
818
|
+
.dcType(DcType.CREDIT)
|
|
819
|
+
.accountCode("33200")
|
|
820
|
+
.amount(new BigDecimal("50000000"))
|
|
821
|
+
.build();
|
|
822
|
+
credit.setJournalDetail(detail);
|
|
823
|
+
|
|
824
|
+
// 関連付け
|
|
825
|
+
detail.addDcDetail(debit);
|
|
826
|
+
detail.addDcDetail(credit);
|
|
827
|
+
journal.addDetail(detail);
|
|
828
|
+
|
|
829
|
+
// CascadeType.ALL により一括保存
|
|
830
|
+
journalRepository.save(journal);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
private void createSalesJournal() {
|
|
834
|
+
String journalNumber = "J2025040002";
|
|
835
|
+
|
|
836
|
+
if (journalRepository.existsById(journalNumber)) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
LocalDate date = LocalDate.of(2025, 4, 5);
|
|
841
|
+
|
|
842
|
+
Journal journal = Journal.builder()
|
|
843
|
+
.journalNumber(journalNumber)
|
|
844
|
+
.postingDate(date)
|
|
845
|
+
.inputDate(date)
|
|
846
|
+
.closingJournalFlag(0)
|
|
847
|
+
.singleFlag(0)
|
|
848
|
+
.journalSlipType(JournalSlipType.AUTO)
|
|
849
|
+
.departmentCode("11110")
|
|
850
|
+
.build();
|
|
851
|
+
|
|
852
|
+
JournalDetail detail = JournalDetail.builder()
|
|
853
|
+
.lineNumber(1)
|
|
854
|
+
.lineDescription("ABC商事 スキンケアセット 100個")
|
|
855
|
+
.build();
|
|
856
|
+
detail.setJournal(journal);
|
|
857
|
+
|
|
858
|
+
// 借方:売掛金
|
|
859
|
+
JournalDcDetail debit = JournalDcDetail.builder()
|
|
860
|
+
.dcType(DcType.DEBIT)
|
|
861
|
+
.accountCode("11210")
|
|
862
|
+
.subAccountCode("ABC001")
|
|
863
|
+
.amount(new BigDecimal("330000"))
|
|
864
|
+
.build();
|
|
865
|
+
debit.setJournalDetail(detail);
|
|
866
|
+
|
|
867
|
+
// 貸方:国内売上高
|
|
868
|
+
JournalDcDetail creditSales = JournalDcDetail.builder()
|
|
869
|
+
.dcType(DcType.CREDIT)
|
|
870
|
+
.accountCode("41110")
|
|
871
|
+
.subAccountCode("ABC001")
|
|
872
|
+
.amount(new BigDecimal("300000"))
|
|
873
|
+
.taxType(TaxType.TAXABLE_SALES)
|
|
874
|
+
.taxRate(10)
|
|
875
|
+
.build();
|
|
876
|
+
creditSales.setJournalDetail(detail);
|
|
877
|
+
|
|
878
|
+
// 貸方:仮受消費税
|
|
879
|
+
JournalDcDetail creditTax = JournalDcDetail.builder()
|
|
880
|
+
.dcType(DcType.CREDIT)
|
|
881
|
+
.accountCode("21240")
|
|
882
|
+
.amount(new BigDecimal("30000"))
|
|
883
|
+
.build();
|
|
884
|
+
creditTax.setJournalDetail(detail);
|
|
885
|
+
|
|
886
|
+
detail.addDcDetail(debit);
|
|
887
|
+
detail.addDcDetail(creditSales);
|
|
888
|
+
detail.addDcDetail(creditTax);
|
|
889
|
+
journal.addDetail(detail);
|
|
890
|
+
|
|
891
|
+
journalRepository.save(journal);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
private void createExpenseJournal() {
|
|
895
|
+
String journalNumber = "J2025040003";
|
|
896
|
+
|
|
897
|
+
if (journalRepository.existsById(journalNumber)) {
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
LocalDate date = LocalDate.of(2025, 4, 10);
|
|
902
|
+
|
|
903
|
+
Journal journal = Journal.builder()
|
|
904
|
+
.journalNumber(journalNumber)
|
|
905
|
+
.postingDate(date)
|
|
906
|
+
.inputDate(date)
|
|
907
|
+
.closingJournalFlag(0)
|
|
908
|
+
.singleFlag(0)
|
|
909
|
+
.journalSlipType(JournalSlipType.NORMAL)
|
|
910
|
+
.departmentCode("11110")
|
|
911
|
+
.build();
|
|
912
|
+
|
|
913
|
+
JournalDetail detail = JournalDetail.builder()
|
|
914
|
+
.lineNumber(1)
|
|
915
|
+
.lineDescription("出張旅費 東京→大阪")
|
|
916
|
+
.build();
|
|
917
|
+
detail.setJournal(journal);
|
|
918
|
+
|
|
919
|
+
// 借方:旅費交通費
|
|
920
|
+
JournalDcDetail debitExp = JournalDcDetail.builder()
|
|
921
|
+
.dcType(DcType.DEBIT)
|
|
922
|
+
.accountCode("62100")
|
|
923
|
+
.amount(new BigDecimal("27273"))
|
|
924
|
+
.taxType(TaxType.TAXABLE_PURCHASE)
|
|
925
|
+
.taxRate(10)
|
|
926
|
+
.build();
|
|
927
|
+
debitExp.setJournalDetail(detail);
|
|
928
|
+
|
|
929
|
+
// 借方:仮払消費税
|
|
930
|
+
JournalDcDetail debitTax = JournalDcDetail.builder()
|
|
931
|
+
.dcType(DcType.DEBIT)
|
|
932
|
+
.accountCode("11430")
|
|
933
|
+
.amount(new BigDecimal("2727"))
|
|
934
|
+
.build();
|
|
935
|
+
debitTax.setJournalDetail(detail);
|
|
936
|
+
|
|
937
|
+
// 貸方:現金
|
|
938
|
+
JournalDcDetail credit = JournalDcDetail.builder()
|
|
939
|
+
.dcType(DcType.CREDIT)
|
|
940
|
+
.accountCode("11110")
|
|
941
|
+
.amount(new BigDecimal("30000"))
|
|
942
|
+
.build();
|
|
943
|
+
credit.setJournalDetail(detail);
|
|
944
|
+
|
|
945
|
+
detail.addDcDetail(debitExp);
|
|
946
|
+
detail.addDcDetail(debitTax);
|
|
947
|
+
detail.addDcDetail(credit);
|
|
948
|
+
journal.addDetail(detail);
|
|
949
|
+
|
|
950
|
+
journalRepository.save(journal);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
private void createMaterialPurchaseJournal() {
|
|
954
|
+
String journalNumber = "J2025040004";
|
|
955
|
+
|
|
956
|
+
if (journalRepository.existsById(journalNumber)) {
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
LocalDate date = LocalDate.of(2025, 4, 15);
|
|
961
|
+
|
|
962
|
+
Journal journal = Journal.builder()
|
|
963
|
+
.journalNumber(journalNumber)
|
|
964
|
+
.postingDate(date)
|
|
965
|
+
.inputDate(date)
|
|
966
|
+
.closingJournalFlag(0)
|
|
967
|
+
.singleFlag(0)
|
|
968
|
+
.journalSlipType(JournalSlipType.AUTO)
|
|
969
|
+
.departmentCode("12110")
|
|
970
|
+
.build();
|
|
971
|
+
|
|
972
|
+
JournalDetail detail = JournalDetail.builder()
|
|
973
|
+
.lineNumber(1)
|
|
974
|
+
.lineDescription("XYZ化学 原材料仕入")
|
|
975
|
+
.build();
|
|
976
|
+
detail.setJournal(journal);
|
|
977
|
+
|
|
978
|
+
// 借方:原材料
|
|
979
|
+
JournalDcDetail debitMat = JournalDcDetail.builder()
|
|
980
|
+
.dcType(DcType.DEBIT)
|
|
981
|
+
.accountCode("11330")
|
|
982
|
+
.subAccountCode("MAT001")
|
|
983
|
+
.amount(new BigDecimal("500000"))
|
|
984
|
+
.taxType(TaxType.TAXABLE_PURCHASE)
|
|
985
|
+
.taxRate(10)
|
|
986
|
+
.build();
|
|
987
|
+
debitMat.setJournalDetail(detail);
|
|
988
|
+
|
|
989
|
+
// 借方:仮払消費税
|
|
990
|
+
JournalDcDetail debitTax = JournalDcDetail.builder()
|
|
991
|
+
.dcType(DcType.DEBIT)
|
|
992
|
+
.accountCode("11430")
|
|
993
|
+
.amount(new BigDecimal("50000"))
|
|
994
|
+
.build();
|
|
995
|
+
debitTax.setJournalDetail(detail);
|
|
996
|
+
|
|
997
|
+
// 貸方:買掛金
|
|
998
|
+
JournalDcDetail credit = JournalDcDetail.builder()
|
|
999
|
+
.dcType(DcType.CREDIT)
|
|
1000
|
+
.accountCode("21110")
|
|
1001
|
+
.subAccountCode("XYZ001")
|
|
1002
|
+
.amount(new BigDecimal("550000"))
|
|
1003
|
+
.build();
|
|
1004
|
+
credit.setJournalDetail(detail);
|
|
1005
|
+
|
|
1006
|
+
detail.addDcDetail(debitMat);
|
|
1007
|
+
detail.addDcDetail(debitTax);
|
|
1008
|
+
detail.addDcDetail(credit);
|
|
1009
|
+
journal.addDetail(detail);
|
|
1010
|
+
|
|
1011
|
+
journalRepository.save(journal);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
private void createSalaryJournal() {
|
|
1015
|
+
String journalNumber = "J2025040005";
|
|
1016
|
+
|
|
1017
|
+
if (journalRepository.existsById(journalNumber)) {
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
LocalDate date = LocalDate.of(2025, 4, 20);
|
|
1022
|
+
|
|
1023
|
+
Journal journal = Journal.builder()
|
|
1024
|
+
.journalNumber(journalNumber)
|
|
1025
|
+
.postingDate(date)
|
|
1026
|
+
.inputDate(date)
|
|
1027
|
+
.closingJournalFlag(0)
|
|
1028
|
+
.singleFlag(0)
|
|
1029
|
+
.journalSlipType(JournalSlipType.NORMAL)
|
|
1030
|
+
.departmentCode("13100")
|
|
1031
|
+
.build();
|
|
1032
|
+
|
|
1033
|
+
JournalDetail detail = JournalDetail.builder()
|
|
1034
|
+
.lineNumber(1)
|
|
1035
|
+
.lineDescription("4月度給与")
|
|
1036
|
+
.build();
|
|
1037
|
+
detail.setJournal(journal);
|
|
1038
|
+
|
|
1039
|
+
// 借方:給料手当
|
|
1040
|
+
JournalDcDetail debit = JournalDcDetail.builder()
|
|
1041
|
+
.dcType(DcType.DEBIT)
|
|
1042
|
+
.accountCode("61200")
|
|
1043
|
+
.amount(new BigDecimal("10000000"))
|
|
1044
|
+
.build();
|
|
1045
|
+
debit.setJournalDetail(detail);
|
|
1046
|
+
|
|
1047
|
+
// 貸方:普通預金
|
|
1048
|
+
JournalDcDetail creditBank = JournalDcDetail.builder()
|
|
1049
|
+
.dcType(DcType.CREDIT)
|
|
1050
|
+
.accountCode("11130")
|
|
1051
|
+
.amount(new BigDecimal("8500000"))
|
|
1052
|
+
.build();
|
|
1053
|
+
creditBank.setJournalDetail(detail);
|
|
1054
|
+
|
|
1055
|
+
// 貸方:預り金
|
|
1056
|
+
JournalDcDetail creditDeposit = JournalDcDetail.builder()
|
|
1057
|
+
.dcType(DcType.CREDIT)
|
|
1058
|
+
.accountCode("21250")
|
|
1059
|
+
.amount(new BigDecimal("1500000"))
|
|
1060
|
+
.build();
|
|
1061
|
+
creditDeposit.setJournalDetail(detail);
|
|
1062
|
+
|
|
1063
|
+
detail.addDcDetail(debit);
|
|
1064
|
+
detail.addDcDetail(creditBank);
|
|
1065
|
+
detail.addDcDetail(creditDeposit);
|
|
1066
|
+
journal.addDetail(detail);
|
|
1067
|
+
|
|
1068
|
+
journalRepository.save(journal);
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
private void createReceiptJournal() {
|
|
1072
|
+
String journalNumber = "J2025040006";
|
|
1073
|
+
|
|
1074
|
+
if (journalRepository.existsById(journalNumber)) {
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
LocalDate date = LocalDate.of(2025, 4, 25);
|
|
1079
|
+
|
|
1080
|
+
Journal journal = Journal.builder()
|
|
1081
|
+
.journalNumber(journalNumber)
|
|
1082
|
+
.postingDate(date)
|
|
1083
|
+
.inputDate(date)
|
|
1084
|
+
.closingJournalFlag(0)
|
|
1085
|
+
.singleFlag(0)
|
|
1086
|
+
.journalSlipType(JournalSlipType.NORMAL)
|
|
1087
|
+
.departmentCode("13100")
|
|
1088
|
+
.build();
|
|
1089
|
+
|
|
1090
|
+
JournalDetail detail = JournalDetail.builder()
|
|
1091
|
+
.lineNumber(1)
|
|
1092
|
+
.lineDescription("ABC商事 入金")
|
|
1093
|
+
.build();
|
|
1094
|
+
detail.setJournal(journal);
|
|
1095
|
+
|
|
1096
|
+
// 借方:普通預金
|
|
1097
|
+
JournalDcDetail debit = JournalDcDetail.builder()
|
|
1098
|
+
.dcType(DcType.DEBIT)
|
|
1099
|
+
.accountCode("11130")
|
|
1100
|
+
.amount(new BigDecimal("330000"))
|
|
1101
|
+
.build();
|
|
1102
|
+
debit.setJournalDetail(detail);
|
|
1103
|
+
|
|
1104
|
+
// 貸方:売掛金
|
|
1105
|
+
JournalDcDetail credit = JournalDcDetail.builder()
|
|
1106
|
+
.dcType(DcType.CREDIT)
|
|
1107
|
+
.accountCode("11210")
|
|
1108
|
+
.subAccountCode("ABC001")
|
|
1109
|
+
.amount(new BigDecimal("330000"))
|
|
1110
|
+
.build();
|
|
1111
|
+
credit.setJournalDetail(detail);
|
|
1112
|
+
|
|
1113
|
+
detail.addDcDetail(debit);
|
|
1114
|
+
detail.addDcDetail(credit);
|
|
1115
|
+
journal.addDetail(detail);
|
|
1116
|
+
|
|
1117
|
+
journalRepository.save(journal);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
private void createPaymentJournal() {
|
|
1121
|
+
String journalNumber = "J2025040007";
|
|
1122
|
+
|
|
1123
|
+
if (journalRepository.existsById(journalNumber)) {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
LocalDate date = LocalDate.of(2025, 4, 30);
|
|
1128
|
+
|
|
1129
|
+
Journal journal = Journal.builder()
|
|
1130
|
+
.journalNumber(journalNumber)
|
|
1131
|
+
.postingDate(date)
|
|
1132
|
+
.inputDate(date)
|
|
1133
|
+
.closingJournalFlag(0)
|
|
1134
|
+
.singleFlag(0)
|
|
1135
|
+
.journalSlipType(JournalSlipType.NORMAL)
|
|
1136
|
+
.departmentCode("13100")
|
|
1137
|
+
.build();
|
|
1138
|
+
|
|
1139
|
+
JournalDetail detail = JournalDetail.builder()
|
|
1140
|
+
.lineNumber(1)
|
|
1141
|
+
.lineDescription("XYZ化学 支払")
|
|
1142
|
+
.build();
|
|
1143
|
+
detail.setJournal(journal);
|
|
1144
|
+
|
|
1145
|
+
// 借方:買掛金
|
|
1146
|
+
JournalDcDetail debit = JournalDcDetail.builder()
|
|
1147
|
+
.dcType(DcType.DEBIT)
|
|
1148
|
+
.accountCode("21110")
|
|
1149
|
+
.subAccountCode("XYZ001")
|
|
1150
|
+
.amount(new BigDecimal("550000"))
|
|
1151
|
+
.build();
|
|
1152
|
+
debit.setJournalDetail(detail);
|
|
1153
|
+
|
|
1154
|
+
// 貸方:普通預金
|
|
1155
|
+
JournalDcDetail credit = JournalDcDetail.builder()
|
|
1156
|
+
.dcType(DcType.CREDIT)
|
|
1157
|
+
.accountCode("11130")
|
|
1158
|
+
.amount(new BigDecimal("550000"))
|
|
1159
|
+
.build();
|
|
1160
|
+
credit.setJournalDetail(detail);
|
|
1161
|
+
|
|
1162
|
+
detail.addDcDetail(debit);
|
|
1163
|
+
detail.addDcDetail(credit);
|
|
1164
|
+
journal.addDetail(detail);
|
|
1165
|
+
|
|
1166
|
+
journalRepository.save(journal);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
private List<Account> createAccountMasterSeedData() {
|
|
1170
|
+
List<Account> accounts = new ArrayList<>();
|
|
1171
|
+
|
|
1172
|
+
// 流動資産
|
|
1173
|
+
accounts.add(Account.builder()
|
|
1174
|
+
.accountCode("11110").accountName("現金").accountShortName("現金")
|
|
1175
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1176
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1177
|
+
.build());
|
|
1178
|
+
|
|
1179
|
+
accounts.add(Account.builder()
|
|
1180
|
+
.accountCode("11130").accountName("普通預金").accountShortName("普通")
|
|
1181
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1182
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1183
|
+
.subAccountType(SubAccountType.REQUIRED)
|
|
1184
|
+
.build());
|
|
1185
|
+
|
|
1186
|
+
accounts.add(Account.builder()
|
|
1187
|
+
.accountCode("11210").accountName("売掛金").accountShortName("売掛金")
|
|
1188
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1189
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1190
|
+
.subAccountType(SubAccountType.REQUIRED).dueDateManagementType(DueDateManagementType.REQUIRED)
|
|
1191
|
+
.build());
|
|
1192
|
+
|
|
1193
|
+
// 棚卸資産
|
|
1194
|
+
accounts.add(Account.builder()
|
|
1195
|
+
.accountCode("11330").accountName("原材料").accountShortName("原材料")
|
|
1196
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1197
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.MANUFACTURING)
|
|
1198
|
+
.subAccountType(SubAccountType.REQUIRED)
|
|
1199
|
+
.build());
|
|
1200
|
+
|
|
1201
|
+
// 仮払消費税
|
|
1202
|
+
accounts.add(Account.builder()
|
|
1203
|
+
.accountCode("11430").accountName("仮払消費税").accountShortName("仮払税")
|
|
1204
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.DEBIT).elementType(ElementType.ASSET)
|
|
1205
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1206
|
+
.build());
|
|
1207
|
+
|
|
1208
|
+
// 負債
|
|
1209
|
+
accounts.add(Account.builder()
|
|
1210
|
+
.accountCode("21110").accountName("買掛金").accountShortName("買掛金")
|
|
1211
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.CREDIT).elementType(ElementType.LIABILITY)
|
|
1212
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1213
|
+
.subAccountType(SubAccountType.REQUIRED).dueDateManagementType(DueDateManagementType.REQUIRED)
|
|
1214
|
+
.build());
|
|
1215
|
+
|
|
1216
|
+
accounts.add(Account.builder()
|
|
1217
|
+
.accountCode("21240").accountName("仮受消費税").accountShortName("仮受税")
|
|
1218
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.CREDIT).elementType(ElementType.LIABILITY)
|
|
1219
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1220
|
+
.build());
|
|
1221
|
+
|
|
1222
|
+
accounts.add(Account.builder()
|
|
1223
|
+
.accountCode("21250").accountName("預り金").accountShortName("預り金")
|
|
1224
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.CREDIT).elementType(ElementType.LIABILITY)
|
|
1225
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1226
|
+
.build());
|
|
1227
|
+
|
|
1228
|
+
// 純資産
|
|
1229
|
+
accounts.add(Account.builder()
|
|
1230
|
+
.accountCode("33200").accountName("繰越利益剰余金").accountShortName("繰越利益")
|
|
1231
|
+
.bsPlType(BsPlType.BS).dcType(AccountDcType.CREDIT).elementType(ElementType.CAPITAL)
|
|
1232
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1233
|
+
.build());
|
|
1234
|
+
|
|
1235
|
+
// 売上
|
|
1236
|
+
accounts.add(Account.builder()
|
|
1237
|
+
.accountCode("41110").accountName("国内売上高").accountShortName("国内売上")
|
|
1238
|
+
.bsPlType(BsPlType.PL).dcType(AccountDcType.CREDIT).elementType(ElementType.REVENUE)
|
|
1239
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1240
|
+
.taxCalculationType(TaxCalculationType.SALES).taxCode("10")
|
|
1241
|
+
.build());
|
|
1242
|
+
|
|
1243
|
+
// 経費
|
|
1244
|
+
accounts.add(Account.builder()
|
|
1245
|
+
.accountCode("61200").accountName("給料手当").accountShortName("給料")
|
|
1246
|
+
.bsPlType(BsPlType.PL).dcType(AccountDcType.DEBIT).elementType(ElementType.EXPENSE)
|
|
1247
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1248
|
+
.expenseType(ExpenseType.EXPENSE)
|
|
1249
|
+
.build());
|
|
1250
|
+
|
|
1251
|
+
accounts.add(Account.builder()
|
|
1252
|
+
.accountCode("62100").accountName("旅費交通費").accountShortName("旅費交通")
|
|
1253
|
+
.bsPlType(BsPlType.PL).dcType(AccountDcType.DEBIT).elementType(ElementType.EXPENSE)
|
|
1254
|
+
.summaryType(SummaryType.POSTING).managementType(ManagementType.COMMON)
|
|
1255
|
+
.expenseType(ExpenseType.EXPENSE)
|
|
1256
|
+
.taxCalculationType(TaxCalculationType.PURCHASE).taxCode("10")
|
|
1257
|
+
.build());
|
|
1258
|
+
|
|
1259
|
+
return accounts;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
private List<Department> createDepartmentSeedData() {
|
|
1263
|
+
return List.of(
|
|
1264
|
+
Department.builder()
|
|
1265
|
+
.departmentCode("10000").departmentName("全社")
|
|
1266
|
+
.organizationLevel(0).departmentPath("10000").lowestLevelFlag(0).build(),
|
|
1267
|
+
Department.builder()
|
|
1268
|
+
.departmentCode("11000").departmentName("営業本部")
|
|
1269
|
+
.organizationLevel(1).departmentPath("10000~11000").lowestLevelFlag(0).build(),
|
|
1270
|
+
Department.builder()
|
|
1271
|
+
.departmentCode("11110").departmentName("東日本営業課")
|
|
1272
|
+
.organizationLevel(3).departmentPath("10000~11000~11100~11110").lowestLevelFlag(1).build(),
|
|
1273
|
+
Department.builder()
|
|
1274
|
+
.departmentCode("12000").departmentName("製造本部")
|
|
1275
|
+
.organizationLevel(1).departmentPath("10000~12000").lowestLevelFlag(0).build(),
|
|
1276
|
+
Department.builder()
|
|
1277
|
+
.departmentCode("12110").departmentName("第一製造課")
|
|
1278
|
+
.organizationLevel(3).departmentPath("10000~12000~12100~12110").lowestLevelFlag(1).build(),
|
|
1279
|
+
Department.builder()
|
|
1280
|
+
.departmentCode("13000").departmentName("管理本部")
|
|
1281
|
+
.organizationLevel(1).departmentPath("10000~13000").lowestLevelFlag(0).build(),
|
|
1282
|
+
Department.builder()
|
|
1283
|
+
.departmentCode("13100").departmentName("経理部")
|
|
1284
|
+
.organizationLevel(2).departmentPath("10000~13000~13100").lowestLevelFlag(0).build()
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
private String generateAccountPath(Account account) {
|
|
1289
|
+
String code = account.getAccountCode();
|
|
1290
|
+
|
|
1291
|
+
// 簡易的なパス生成(実際はマスタの親子関係から生成)
|
|
1292
|
+
if (code.length() == 2) {
|
|
1293
|
+
return code;
|
|
1294
|
+
} else if (code.length() == 5) {
|
|
1295
|
+
String parent = code.substring(0, 2);
|
|
1296
|
+
return parent + "~" + code;
|
|
1297
|
+
}
|
|
1298
|
+
return code;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
</details>
|
|
1304
|
+
|
|
1305
|
+
### 20.4.2 CommandLineRunner による起動時データ投入
|
|
1306
|
+
|
|
1307
|
+
<details>
|
|
1308
|
+
<summary>SeedDataRunner(CommandLineRunner)</summary>
|
|
1309
|
+
|
|
1310
|
+
```java
|
|
1311
|
+
// src/main/java/com/example/accounting/infrastructure/seed/SeedDataRunner.java
|
|
1312
|
+
package com.example.accounting.infrastructure.seed;
|
|
1313
|
+
|
|
1314
|
+
import lombok.RequiredArgsConstructor;
|
|
1315
|
+
import lombok.extern.slf4j.Slf4j;
|
|
1316
|
+
import org.springframework.boot.CommandLineRunner;
|
|
1317
|
+
import org.springframework.context.annotation.Profile;
|
|
1318
|
+
import org.springframework.stereotype.Component;
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* アプリケーション起動時に Seed データを投入する
|
|
1322
|
+
*
|
|
1323
|
+
* dev, local プロファイル時のみ有効
|
|
1324
|
+
*/
|
|
1325
|
+
@Component
|
|
1326
|
+
@Profile({"dev", "local"})
|
|
1327
|
+
@RequiredArgsConstructor
|
|
1328
|
+
@Slf4j
|
|
1329
|
+
public class SeedDataRunner implements CommandLineRunner {
|
|
1330
|
+
|
|
1331
|
+
private final SeedDataService seedDataService;
|
|
1332
|
+
|
|
1333
|
+
@Override
|
|
1334
|
+
public void run(String... args) {
|
|
1335
|
+
log.info("=== Starting Seed Data Initialization ===");
|
|
1336
|
+
|
|
1337
|
+
try {
|
|
1338
|
+
seedDataService.seedAll();
|
|
1339
|
+
log.info("=== Seed Data Initialization Completed ===");
|
|
1340
|
+
} catch (Exception e) {
|
|
1341
|
+
log.error("=== Seed Data Initialization Failed ===", e);
|
|
1342
|
+
// 起動は継続させる(テストデータが無くても動作は可能)
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
</details>
|
|
1349
|
+
|
|
1350
|
+
### 20.4.3 @PostConstruct を使用した代替実装
|
|
1351
|
+
|
|
1352
|
+
<details>
|
|
1353
|
+
<summary>SeedDataInitializer(@PostConstruct)</summary>
|
|
1354
|
+
|
|
1355
|
+
```java
|
|
1356
|
+
// src/main/java/com/example/accounting/infrastructure/seed/SeedDataInitializer.java
|
|
1357
|
+
package com.example.accounting.infrastructure.seed;
|
|
1358
|
+
|
|
1359
|
+
import jakarta.annotation.PostConstruct;
|
|
1360
|
+
import lombok.RequiredArgsConstructor;
|
|
1361
|
+
import lombok.extern.slf4j.Slf4j;
|
|
1362
|
+
import org.springframework.context.annotation.Profile;
|
|
1363
|
+
import org.springframework.stereotype.Component;
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* @PostConstruct を使用した Seed データ投入
|
|
1367
|
+
*
|
|
1368
|
+
* CommandLineRunner より早いタイミングで実行される
|
|
1369
|
+
*/
|
|
1370
|
+
@Component
|
|
1371
|
+
@Profile({"dev", "local"})
|
|
1372
|
+
@RequiredArgsConstructor
|
|
1373
|
+
@Slf4j
|
|
1374
|
+
public class SeedDataInitializer {
|
|
1375
|
+
|
|
1376
|
+
private final SeedDataService seedDataService;
|
|
1377
|
+
|
|
1378
|
+
@PostConstruct
|
|
1379
|
+
public void initialize() {
|
|
1380
|
+
log.info("=== @PostConstruct Seed Data Initialization ===");
|
|
1381
|
+
|
|
1382
|
+
try {
|
|
1383
|
+
seedDataService.seedAll();
|
|
1384
|
+
log.info("=== Seed Data Initialization Completed ===");
|
|
1385
|
+
} catch (Exception e) {
|
|
1386
|
+
log.error("=== Seed Data Initialization Failed ===", e);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
```
|
|
1391
|
+
|
|
1392
|
+
</details>
|
|
1393
|
+
|
|
1394
|
+
## 20.5 Seed データ投入テスト
|
|
1395
|
+
|
|
1396
|
+
<details>
|
|
1397
|
+
<summary>SeedDataServiceTest(JPA版)</summary>
|
|
1398
|
+
|
|
1399
|
+
```java
|
|
1400
|
+
// src/test/java/com/example/accounting/infrastructure/seed/SeedDataServiceTest.java
|
|
1401
|
+
package com.example.accounting.infrastructure.seed;
|
|
1402
|
+
|
|
1403
|
+
import com.example.accounting.domain.model.account.*;
|
|
1404
|
+
import com.example.accounting.domain.model.journal.*;
|
|
1405
|
+
import com.example.accounting.infrastructure.persistence.repository.*;
|
|
1406
|
+
import org.junit.jupiter.api.*;
|
|
1407
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
|
1408
|
+
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
|
1409
|
+
import org.springframework.context.annotation.Import;
|
|
1410
|
+
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
1411
|
+
import org.springframework.test.context.DynamicPropertySource;
|
|
1412
|
+
import org.testcontainers.containers.PostgreSQLContainer;
|
|
1413
|
+
import org.testcontainers.junit.jupiter.Container;
|
|
1414
|
+
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
1415
|
+
|
|
1416
|
+
import java.math.BigDecimal;
|
|
1417
|
+
|
|
1418
|
+
import static org.assertj.core.api.Assertions.*;
|
|
1419
|
+
|
|
1420
|
+
@DataJpaTest
|
|
1421
|
+
@Import(SeedDataService.class)
|
|
1422
|
+
@Testcontainers
|
|
1423
|
+
@DisplayName("Seedデータ投入(JPA)")
|
|
1424
|
+
class SeedDataServiceTest {
|
|
1425
|
+
|
|
1426
|
+
@Container
|
|
1427
|
+
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16")
|
|
1428
|
+
.withDatabaseName("testdb")
|
|
1429
|
+
.withUsername("testuser")
|
|
1430
|
+
.withPassword("testpass");
|
|
1431
|
+
|
|
1432
|
+
@DynamicPropertySource
|
|
1433
|
+
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
1434
|
+
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
1435
|
+
registry.add("spring.datasource.username", postgres::getUsername);
|
|
1436
|
+
registry.add("spring.datasource.password", postgres::getPassword);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
@Autowired
|
|
1440
|
+
private SeedDataService seedDataService;
|
|
1441
|
+
|
|
1442
|
+
@Autowired
|
|
1443
|
+
private AccountJpaRepository accountRepository;
|
|
1444
|
+
|
|
1445
|
+
@Autowired
|
|
1446
|
+
private TaxTransactionJpaRepository taxTransactionRepository;
|
|
1447
|
+
|
|
1448
|
+
@Autowired
|
|
1449
|
+
private DepartmentJpaRepository departmentRepository;
|
|
1450
|
+
|
|
1451
|
+
@Autowired
|
|
1452
|
+
private JournalJpaRepository journalRepository;
|
|
1453
|
+
|
|
1454
|
+
@Nested
|
|
1455
|
+
@DisplayName("課税取引マスタ")
|
|
1456
|
+
class TaxTransactionSeed {
|
|
1457
|
+
|
|
1458
|
+
@Test
|
|
1459
|
+
@DisplayName("課税取引マスタのSeedデータを投入できる")
|
|
1460
|
+
void canSeedTaxTransactions() {
|
|
1461
|
+
// Act
|
|
1462
|
+
seedDataService.seedTaxTransactions();
|
|
1463
|
+
|
|
1464
|
+
// Assert
|
|
1465
|
+
var tax10 = taxTransactionRepository.findById("10");
|
|
1466
|
+
assertThat(tax10).isPresent();
|
|
1467
|
+
assertThat(tax10.get().getTaxName()).isEqualTo("標準税率10%");
|
|
1468
|
+
assertThat(tax10.get().getTaxRate()).isEqualByComparingTo(new BigDecimal("0.100"));
|
|
1469
|
+
|
|
1470
|
+
var tax08 = taxTransactionRepository.findById("08");
|
|
1471
|
+
assertThat(tax08).isPresent();
|
|
1472
|
+
assertThat(tax08.get().getTaxName()).isEqualTo("軽減税率8%");
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
@Nested
|
|
1477
|
+
@DisplayName("勘定科目マスタ")
|
|
1478
|
+
class AccountMasterSeed {
|
|
1479
|
+
|
|
1480
|
+
@BeforeEach
|
|
1481
|
+
void setUp() {
|
|
1482
|
+
seedDataService.seedTaxTransactions();
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
@Test
|
|
1486
|
+
@DisplayName("勘定科目マスタのSeedデータを投入できる")
|
|
1487
|
+
void canSeedAccountMasters() {
|
|
1488
|
+
// Act
|
|
1489
|
+
seedDataService.seedAccountMasters();
|
|
1490
|
+
|
|
1491
|
+
// Assert
|
|
1492
|
+
var cash = accountRepository.findById("11110");
|
|
1493
|
+
assertThat(cash).isPresent();
|
|
1494
|
+
assertThat(cash.get().getAccountName()).isEqualTo("現金");
|
|
1495
|
+
assertThat(cash.get().getBsPlType()).isEqualTo(BsPlType.BS);
|
|
1496
|
+
assertThat(cash.get().getDcType()).isEqualTo(AccountDcType.DEBIT);
|
|
1497
|
+
|
|
1498
|
+
var sales = accountRepository.findById("41110");
|
|
1499
|
+
assertThat(sales).isPresent();
|
|
1500
|
+
assertThat(sales.get().getAccountName()).isEqualTo("国内売上高");
|
|
1501
|
+
assertThat(sales.get().getBsPlType()).isEqualTo(BsPlType.PL);
|
|
1502
|
+
assertThat(sales.get().getDcType()).isEqualTo(AccountDcType.CREDIT);
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
@Test
|
|
1506
|
+
@DisplayName("重複実行しても既存データが上書きされない(冪等性)")
|
|
1507
|
+
void seedIsIdempotent() {
|
|
1508
|
+
// Act
|
|
1509
|
+
seedDataService.seedAccountMasters();
|
|
1510
|
+
seedDataService.seedAccountMasters(); // 2回目
|
|
1511
|
+
|
|
1512
|
+
// Assert
|
|
1513
|
+
var accounts = accountRepository.findAll();
|
|
1514
|
+
long cashCount = accounts.stream()
|
|
1515
|
+
.filter(a -> "11110".equals(a.getAccountCode()))
|
|
1516
|
+
.count();
|
|
1517
|
+
assertThat(cashCount).isEqualTo(1);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
@Nested
|
|
1522
|
+
@DisplayName("部門マスタ")
|
|
1523
|
+
class DepartmentSeed {
|
|
1524
|
+
|
|
1525
|
+
@Test
|
|
1526
|
+
@DisplayName("部門マスタのSeedデータを投入できる")
|
|
1527
|
+
void canSeedDepartments() {
|
|
1528
|
+
// Act
|
|
1529
|
+
seedDataService.seedDepartments();
|
|
1530
|
+
|
|
1531
|
+
// Assert
|
|
1532
|
+
var company = departmentRepository.findById("10000");
|
|
1533
|
+
assertThat(company).isPresent();
|
|
1534
|
+
assertThat(company.get().getDepartmentName()).isEqualTo("全社");
|
|
1535
|
+
assertThat(company.get().getOrganizationLevel()).isEqualTo(0);
|
|
1536
|
+
|
|
1537
|
+
var sales = departmentRepository.findById("11110");
|
|
1538
|
+
assertThat(sales).isPresent();
|
|
1539
|
+
assertThat(sales.get().getDepartmentName()).isEqualTo("東日本営業課");
|
|
1540
|
+
assertThat(sales.get().getDepartmentPath()).isEqualTo("10000~11000~11100~11110");
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
@Nested
|
|
1545
|
+
@DisplayName("仕訳データ")
|
|
1546
|
+
class JournalSeed {
|
|
1547
|
+
|
|
1548
|
+
@BeforeEach
|
|
1549
|
+
void setUp() {
|
|
1550
|
+
seedDataService.seedTaxTransactions();
|
|
1551
|
+
seedDataService.seedAccountMasters();
|
|
1552
|
+
seedDataService.seedDepartments();
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
@Test
|
|
1556
|
+
@DisplayName("サンプル仕訳データを投入できる")
|
|
1557
|
+
void canSeedSampleJournals() {
|
|
1558
|
+
// Act
|
|
1559
|
+
seedDataService.seedSampleJournals();
|
|
1560
|
+
|
|
1561
|
+
// Assert
|
|
1562
|
+
// 期首仕訳
|
|
1563
|
+
var opening = journalRepository.findById("J2025040001");
|
|
1564
|
+
assertThat(opening).isPresent();
|
|
1565
|
+
assertThat(opening.get().getJournalSlipType()).isEqualTo(JournalSlipType.NORMAL);
|
|
1566
|
+
|
|
1567
|
+
// 売上仕訳
|
|
1568
|
+
var sales = journalRepository.findById("J2025040002");
|
|
1569
|
+
assertThat(sales).isPresent();
|
|
1570
|
+
assertThat(sales.get().getJournalSlipType()).isEqualTo(JournalSlipType.AUTO);
|
|
1571
|
+
|
|
1572
|
+
// CascadeType.ALL により明細も保存されていることを確認
|
|
1573
|
+
var salesWithDetails = journalRepository.findWithDetailsById("J2025040002");
|
|
1574
|
+
assertThat(salesWithDetails).isPresent();
|
|
1575
|
+
assertThat(salesWithDetails.get().getDetails()).hasSize(1);
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
@Test
|
|
1579
|
+
@DisplayName("仕訳の貸借一致を確認できる")
|
|
1580
|
+
void journalBalanceIsCorrect() {
|
|
1581
|
+
// Arrange
|
|
1582
|
+
seedDataService.seedSampleJournals();
|
|
1583
|
+
|
|
1584
|
+
// Act
|
|
1585
|
+
var journal = journalRepository.findWithDetailsById("J2025040002").orElseThrow();
|
|
1586
|
+
|
|
1587
|
+
// Assert
|
|
1588
|
+
var detail = journal.getDetails().get(0);
|
|
1589
|
+
BigDecimal debitSum = detail.getDcDetails().stream()
|
|
1590
|
+
.filter(d -> d.getDcType() == DcType.DEBIT)
|
|
1591
|
+
.map(JournalDcDetail::getAmount)
|
|
1592
|
+
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
1593
|
+
BigDecimal creditSum = detail.getDcDetails().stream()
|
|
1594
|
+
.filter(d -> d.getDcType() == DcType.CREDIT)
|
|
1595
|
+
.map(JournalDcDetail::getAmount)
|
|
1596
|
+
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
1597
|
+
|
|
1598
|
+
assertThat(debitSum).isEqualByComparingTo(creditSum);
|
|
1599
|
+
assertThat(debitSum).isEqualByComparingTo(new BigDecimal("330000"));
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
@Nested
|
|
1604
|
+
@DisplayName("全データ一括投入")
|
|
1605
|
+
class SeedAll {
|
|
1606
|
+
|
|
1607
|
+
@Test
|
|
1608
|
+
@DisplayName("全Seedデータを一括投入できる")
|
|
1609
|
+
void canSeedAll() {
|
|
1610
|
+
// Act
|
|
1611
|
+
seedDataService.seedAll();
|
|
1612
|
+
|
|
1613
|
+
// Assert
|
|
1614
|
+
assertThat(taxTransactionRepository.findById("10")).isPresent();
|
|
1615
|
+
assertThat(accountRepository.findById("11110")).isPresent();
|
|
1616
|
+
assertThat(departmentRepository.findById("10000")).isPresent();
|
|
1617
|
+
assertThat(journalRepository.findById("J2025040001")).isPresent();
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
```
|
|
1622
|
+
|
|
1623
|
+
</details>
|
|
1624
|
+
|
|
1625
|
+
## 20.6 データ投入順序
|
|
1626
|
+
|
|
1627
|
+
外部キー制約を考慮したデータ投入順序:
|
|
1628
|
+
|
|
1629
|
+
```plantuml
|
|
1630
|
+
@startuml
|
|
1631
|
+
|
|
1632
|
+
title Seedデータ投入順序(JPA CascadeType.ALL 活用)
|
|
1633
|
+
|
|
1634
|
+
|マスタデータ|
|
|
1635
|
+
start
|
|
1636
|
+
:課税取引マスタ;
|
|
1637
|
+
note right: 外部キー参照元\nFK制約なし
|
|
1638
|
+
:勘定科目マスタ;
|
|
1639
|
+
note right: 課税取引マスタを参照
|
|
1640
|
+
:勘定科目構成マスタ;
|
|
1641
|
+
note right: 勘定科目マスタを参照\n@OneToOne 関連
|
|
1642
|
+
:部門マスタ;
|
|
1643
|
+
:通貨マスタ;
|
|
1644
|
+
|
|
1645
|
+
|トランザクションデータ|
|
|
1646
|
+
:仕訳データ;
|
|
1647
|
+
note right
|
|
1648
|
+
CascadeType.ALL により
|
|
1649
|
+
明細も一括保存
|
|
1650
|
+
@OneToMany(cascade = ALL)
|
|
1651
|
+
end note
|
|
1652
|
+
|
|
1653
|
+
|残高データ|
|
|
1654
|
+
:日次勘定科目残高;
|
|
1655
|
+
note right: 仕訳から集計
|
|
1656
|
+
:月次勘定科目残高;
|
|
1657
|
+
note right: 日次残高から集計
|
|
1658
|
+
|
|
1659
|
+
stop
|
|
1660
|
+
|
|
1661
|
+
@enduml
|
|
1662
|
+
```
|
|
1663
|
+
|
|
1664
|
+
## まとめ
|
|
1665
|
+
|
|
1666
|
+
### MyBatis 版との違い
|
|
1667
|
+
|
|
1668
|
+
| 観点 | MyBatis 版 | JPA 版 |
|
|
1669
|
+
|------|-----------|--------|
|
|
1670
|
+
| Repository | Mapper インターフェース + XML | JpaRepository インターフェース |
|
|
1671
|
+
| マッピング | resultMap で日本語カラム ↔ 英語プロパティ | @Column で日本語カラム名を指定 |
|
|
1672
|
+
| 関連の保存 | 個別に INSERT | CascadeType.ALL で一括保存 |
|
|
1673
|
+
| テスト | @MybatisTest | @DataJpaTest |
|
|
1674
|
+
| クエリメソッド | XML に SQL を記述 | メソッド名規約 or @Query |
|
|
1675
|
+
| 存在確認 | findByCode() == null | existsById() |
|
|
1676
|
+
|
|
1677
|
+
### JPA 固有のポイント
|
|
1678
|
+
|
|
1679
|
+
1. **CascadeType.ALL によるカスケード保存**
|
|
1680
|
+
```java
|
|
1681
|
+
@OneToMany(mappedBy = "journal", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
1682
|
+
private List<JournalDetail> details = new ArrayList<>();
|
|
1683
|
+
```
|
|
1684
|
+
|
|
1685
|
+
2. **@PrePersist / @PreUpdate による自動タイムスタンプ**
|
|
1686
|
+
```java
|
|
1687
|
+
@PrePersist
|
|
1688
|
+
protected void onCreate() {
|
|
1689
|
+
if (createdAt == null) {
|
|
1690
|
+
createdAt = LocalDateTime.now();
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
```
|
|
1694
|
+
|
|
1695
|
+
3. **existsById() による存在確認**
|
|
1696
|
+
```java
|
|
1697
|
+
if (!accountRepository.existsById(account.getAccountCode())) {
|
|
1698
|
+
accountRepository.save(account);
|
|
1699
|
+
}
|
|
1700
|
+
```
|
|
1701
|
+
|
|
1702
|
+
4. **CommandLineRunner による起動時データ投入**
|
|
1703
|
+
```java
|
|
1704
|
+
@Component
|
|
1705
|
+
@Profile({"dev", "local"})
|
|
1706
|
+
public class SeedDataRunner implements CommandLineRunner {
|
|
1707
|
+
@Override
|
|
1708
|
+
public void run(String... args) {
|
|
1709
|
+
seedDataService.seedAll();
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
```
|
|
1713
|
+
|
|
1714
|
+
### 設計のポイント
|
|
1715
|
+
|
|
1716
|
+
1. **実務に即した勘定科目体系**
|
|
1717
|
+
- 製造業向けの科目構成
|
|
1718
|
+
- 管理会計区分による部門別損益
|
|
1719
|
+
- 消費税複数税率対応
|
|
1720
|
+
|
|
1721
|
+
2. **階層構造の管理**
|
|
1722
|
+
- 勘定科目のチルダ連結パス
|
|
1723
|
+
- 部門マスタの組織階層
|
|
1724
|
+
- 科目集計の効率化
|
|
1725
|
+
|
|
1726
|
+
3. **Seedデータの設計**
|
|
1727
|
+
- 外部キー制約を考慮した投入順序
|
|
1728
|
+
- 冪等性(重複実行時の安全性)
|
|
1729
|
+
- テスト可能な構造
|
|
1730
|
+
|
|
1731
|
+
4. **仕訳パターンの網羅**
|
|
1732
|
+
- 期首繰越仕訳
|
|
1733
|
+
- 売上・売掛金仕訳
|
|
1734
|
+
- 経費・消費税仕訳
|
|
1735
|
+
- 材料仕入仕訳
|
|
1736
|
+
- 給与支払仕訳
|
|
1737
|
+
- 入金・支払仕訳
|
|
1738
|
+
|
|
1739
|
+
### テーブル一覧(Seed対象)
|
|
1740
|
+
|
|
1741
|
+
| テーブル名 | 件数目安 | 説明 |
|
|
1742
|
+
|-----------|---------|------|
|
|
1743
|
+
| 課税取引マスタ | 5件 | 税率マスタ |
|
|
1744
|
+
| 勘定科目マスタ | 100件 | 科目マスタ |
|
|
1745
|
+
| 勘定科目構成マスタ | 100件 | 科目階層 |
|
|
1746
|
+
| 部門マスタ | 30件 | 組織マスタ |
|
|
1747
|
+
| 仕訳 | 10件 | サンプル仕訳 |
|
|
1748
|
+
| 日次勘定科目残高 | 50件 | 日次残高 |
|
|
1749
|
+
| 月次勘定科目残高 | 20件 | 月次残高 |
|
|
1750
|
+
|
|
1751
|
+
---
|
|
1752
|
+
|
|
1753
|
+
[← 第19章:赤黒とログの設計【ORM版】](./chapter19-orm.md) | [第21章:APIサービスの実装【ORM版】 →](./chapter21-orm.md)
|