feat: init cash flow

This commit is contained in:
Julien Calixte
2026-01-03 20:49:10 +01:00
parent df83fb5a29
commit efc6655afd
3 changed files with 40 additions and 7 deletions

View File

@@ -1,2 +1,3 @@
export const NUMBER_OF_DAYS = 3
export const NUMBER_OF_HOURS_PER_DAY = 4
export const INITIAL_CASH_FLOW = 20

View File

@@ -1,4 +1,5 @@
import {
INITIAL_CASH_FLOW,
NUMBER_OF_DAYS,
NUMBER_OF_HOURS_PER_DAY
} from '@/modules/heijkunka/heijunka-config'
@@ -20,7 +21,6 @@ type Inventory = {
}
type HeijunkaState = {
money: number
inventory: Inventory
orders: Order[]
meta: {
@@ -52,7 +52,6 @@ const initialInventory: Inventory = {
export const useHeijunkaStore = defineStore('heijunka', {
state: (): HeijunkaState => ({
money: 100,
inventory: { ...initialInventory },
orders: [],
meta: {
@@ -141,6 +140,10 @@ export const useHeijunkaStore = defineStore('heijunka', {
getters: {
currentDay: (state) =>
Math.ceil(state.meta.currentHour / NUMBER_OF_HOURS_PER_DAY),
cashFlow: (state) =>
INITIAL_CASH_FLOW -
state.meta.currentHour * 3 +
state.orders.filter((o) => o.status === 'received').length * 4,
remainingInventory: (state): Inventory => ({
shirt: Math.max(
state.inventory.shirt -