This commit is contained in:
2025-07-28 10:20:13 +02:00
parent ab5430ddc7
commit 5b48304fac
14 changed files with 60 additions and 87 deletions

View File

@@ -18,24 +18,19 @@ bizmodel.play(heroscript_path:heroscript)!
mut bm := bizmodel.get("threefold")!
bm.sheet.pprint(nr_columns: 25)!
buildpath := '${os.home_dir()}/hero/var/mdbuild/bizmodel'
println("buildpath: ${buildpath}")
// buildpath := '${os.home_dir()}/hero/var/mdbuild/bizmodel'
// println("buildpath: ${buildpath}")
model.play(mut playbook.new(path: playbook_path)!)!
// model.play(mut playbook.new(path: playbook_path)!)!
println(model.sheet)
println(model.sheet.export()!)
// println(model.sheet)
// println(model.sheet.export()!)
// model.sheet.export(path:"~/Downloads/test.csv")!
// model.sheet.export(path:"~/code/github/freeflowuniverse/starlight_template/src/content/test.csv")!
report := model.new_report(
bm.export(
name: 'example_report'
title: 'Example Business Model'
)!
report.export(
path: build_path
overwrite: true
format: .docusaurus
path: '/tmp/bizmodel_export'
)!

View File

@@ -3,6 +3,7 @@
!!bizmodel.department_define bizname:'threefold' name:'operations' descr:'Operations Department'
!!bizmodel.department_define bizname:'threefold' name:'sales' descr:'Sales Department'
!!bizmodel.department_define bizname:'threefold' name:'admin' descr:'Administrative Department'
!!bizmodel.department_define bizname:'threefold' name:'marketing' descr:'Marketing Department'
// Define engineering team with 10 people growing 10%/year (max 20)
!!bizmodel.employee_define bizname:'threefold' name:'engineering_team' descr:'Engineering Team'
@@ -53,7 +54,7 @@
cost_percent_revenue:'0.5%'
!!bizmodel.cost_define bizname:'test' name:'triptomoon'
descr:'Office Rent'
descr:'Planet Rental We are crazy'
cost:'10:500000USD' extrapolate:0 //this means we do a one off cost in this case month 11
costcenter:'marketing_cc'

View File

@@ -1,39 +0,0 @@
!!bizmodel.revenue_define bizname:'threefold' name:'cloud_services' extrapolate:1
descr:'Cloud Services Revenue'
revenue:'10:10000USD,46:1000000USD'
cogs_percent:'0%'
!!bizmodel.funding_define bizname:'threefold' name:'initial_investment'
descr:'Seed Capital'
investment:'0:5000000USD'
type:'capital'
!!bizmodel.department_define bizname:'threefold' name:'engineering' descr:'Engineering Department'
!!bizmodel.department_define bizname:'threefold' name:'operations' descr:'Operations Department'
!!bizmodel.department_define bizname:'threefold' name:'sales' descr:'Sales Department'
!!bizmodel.department_define bizname:'threefold' name:'admin' descr:'Admin Department'
!!bizmodel.employee_define bizname:'threefold' name:'engineer'
descr:'Engineer'
cost:'7000USD'
indexation:'5%'
nrpeople:'0:5,12:6,24:7,36:9,48:10,60:11,72:12,84:14,96:16,108:18,120:20'
department:'engineering'
!!bizmodel.employee_define bizname:'threefold' name:'operations_staff'
descr:'Operations Staff'
cost:'5000USD'
indexation:'5%'
nrpeople:'2'
department:'operations'
cost_percent_revenue:'4%'
!!bizmodel.cost_define bizname:'threefold' name:'travel'
descr:'Travel Costs'
cost:'0USD'
cost_percent_revenue:'3%'
!!bizmodel.cost_define bizname:'threefold' name:'office_rent'
descr:'Offices Rent (3 locations)'
cost:'24000USD'
indexation:'3%'

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.biz.bizmodel
import os
bizmodel.play(heroscript_path: '${os.dir(@FILE)}/bizmodel.heroscript')!
mut m := bizmodel.get("threefold")!
m.sheet.pprint(nr_columns: 5)!

View File

@@ -89,7 +89,7 @@ fn (mut m BizModel) new_report_action(action Action) !Action {
name := p.get_default('name', '')!
title := p.get_default('title', '')!
description := p.get_default('description', '')!
m.export_all(path:path,name:name,title:title,description:description)!
m.export(path:path,name:name,title:title,description:description)!
return action
}

View File

@@ -14,7 +14,7 @@ pub mut:
path string
}
pub fn (b BizModel) export_all(args ExportArgs) ! {
pub fn (b BizModel) export(args ExportArgs) ! {
name := if args.name != '' { args.name } else { texttools.snake_case(args.title) }
path := pathlib.get_dir(
path: os.join_path(os.home_dir(), '/hero/var/bizmodel/exports/${name}')

View File

@@ -48,13 +48,17 @@ pub fn (mut m BizModel) play(mut plbook PlayBook) ! {
m.act(*action)!
}
m.cost_total()!
m.revenue_total()!
m.funding_total()!
for action in actions.filter(it.name in action_priorities[2]) {
m.act(*action)!
}
m.hrcost_total()!
m.funding_total()!
m.cost_total()!
for action in actions.filter(it.name in action_priorities[3]) {
m.act(*action)!
}

View File

@@ -49,7 +49,7 @@ fn (mut m BizModel) cost_define_action(action Action) !Action {
mut cost_row := m.sheet.row_new(
name: 'cost_${name}'
growth: cost
tags: 'department:${department} cost'
tags: 'department:${department} ocost'
descr: descr
extrapolate: action.params.get_default_true('extrapolate')
)!
@@ -73,11 +73,14 @@ fn (mut m BizModel) cost_define_action(action Action) !Action {
return action
}
fn (mut sim BizModel) cost_total() ! {
sim.sheet.group2row(
name: 'hr_cost_total'
include: ['hrcost']
name: 'cost_total'
include: ['ocost']
tags: 'pl'
descr: 'total cost for hr'
descr: 'Operational Costs Total.'
)!
}

View File

@@ -43,6 +43,6 @@ fn (mut sim BizModel) funding_total() ! {
name: 'funding_total'
include: ['funding']
tags: 'pl'
descr: 'Total funding'
descr: 'Funding Total'
)!
}

View File

@@ -50,7 +50,7 @@ fn (mut m BizModel) employee_define_action(action Action) !Action {
name: 'hr_cost_${name}'
growth: cost
tags: 'department:${department} hrcost'
descr: 'Department ${department} Cost For Person ${name}'
descr: '${descr} Cost'
subgroup: 'HR cost per department.'
)!
@@ -61,7 +61,7 @@ fn (mut m BizModel) employee_define_action(action Action) !Action {
name: 'hr_nrpeople_${name}'
growth: nrpeople
tags: 'hrnr'
descr: '# people for ${descr}'
descr: '${descr} Nr of People'
aggregatetype: .avg
)!
costpeople_row = costpeople_row.action(action: .multiply, rows: [nrpeople_row])!
@@ -101,3 +101,13 @@ fn (mut m BizModel) employee_define_action(action Action) !Action {
}
return action
}
fn (mut sim BizModel) hrcost_total() ! {
sim.sheet.group2row(
name: 'hr_cost_total'
include: ['hrcost']
tags: 'pl'
descr: 'Human Resources Costs Total'
)!
}

View File

@@ -43,7 +43,7 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
name: '${r.name}_cogs_param'
growth: action.params.get_default('cogs', '0:0')!
tags: 'name:${r.name}'
descr: 'COGS for ${r.name}'
descr: 'COGS Param for ${r.name}'
extrapolate: action.params.get_default_false('extrapolate')
)!
@@ -70,6 +70,7 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
rows: [cogs_percent_temp]
name: '${r.name}_cogs'
tags: 'cogs name:${r.name}'
descr: 'COGS for ${r.name}'
)!
if revenue.max() > 0 {

View File

@@ -9,19 +9,24 @@ fn (mut sim BizModel) revenue_total() ! {
mut revenue_total := sheet.group2row(
name: 'revenue_total'
include: ['rev']
tags: 'total'
descr: 'total revenue.'
tags: 'total revtotal pl'
descr: 'Revenue Total'
)!
mut cogs_total := sheet.group2row(
name: 'cogs_total'
include: ['cogs']
tags: 'total'
descr: 'total cogs.'
tags: 'total cogstotal pl'
descr: 'Cost of Goods Total.'
)!
mut margin_total := sheet.group2row(
name: 'margin_total'
include: ['margin']
tags: 'total'
tags: 'total margintotal'
descr: 'total margin.'
)!
// println(revenue_total)
// println(cogs_total)
// println(margin_total)
}

View File

@@ -10,23 +10,28 @@
@{model.sheet.wiki(includefilter:['rev']) or {panic(err)}}
#### Revenue Lines
#### Revenue
@{model.sheet.wiki(title:'Revenue Total', includefilter:['revtotal']) or {panic(err)}}
#### COGS Lines
#### Cost of Goods
@{model.sheet.wiki(title:'COGS', includefilter:['cogstotal']) or {panic(err)}}
#### Margin
@{model.sheet.wiki(title:'COGS', includefilter:['margintotal']) or {panic(err)}}
## HR
@{model.sheet.wiki(title:'HR Teams', includefilter:['hrnr']) or {panic(err)}}
@{model.sheet.wiki(title:'#### HR Teams', includefilter:['hrnr']) or {panic(err)}}
@{model.sheet.wiki(title:'HR Costs', includefilter:['hrcost']) or {panic(err)}}
@{model.sheet.wiki(title:'#### HR Costs', includefilter:['hrcost']) or {panic(err)}}
## Operational Costs
@{model.sheet.wiki(title:'COSTS', includefilter:['ocost']) or {panic(err)}}
@{model.sheet.wiki( includefilter:['ocost']) or {panic(err)}}
## P&L Overview
@@ -34,7 +39,7 @@
@{model.sheet.wiki(title:'P&L Overview', includefilter:['pl']) or {panic(err)}}
@{model.sheet.bar_chart(rowname:'revenue_total', unit: .million, title:'A Title', title_sub:'Sub') or {panic(err)}.mdx()}
@{model.sheet.bar_chart(rowname:'revenue_total', unit: .million, title:'Total Revenue', title_sub:'Sub') or {panic(err)}.mdx()}
Unit is in Million USD.

View File

@@ -18,9 +18,6 @@ pub fn (s Sheet) wiki(args_ RowGetArgs) !string {
mut sheet := s.filter(args)! // this will do the filtering and if needed make smaller
mut out := ''
if args.title.len > 0 {
out = '## ${args.title}\n\n'
}
if args.title != '' {
out += args.title + '\n\n'
}