This commit is contained in:
2025-07-25 14:08:44 +02:00
parent 6877de4626
commit ab5430ddc7
5 changed files with 54 additions and 87 deletions

View File

@@ -6,14 +6,21 @@ import freeflowuniverse.herolib.core.playbook
import freeflowuniverse.herolib.core.playcmds import freeflowuniverse.herolib.core.playcmds
import os import os
// TODO: need to fix wrong location // heroscript := os.join_path(os.dir(@FILE), 'examples/full')
const playbook_path = os.dir(@FILE) + '/playbook' // // Execute the script and print results
const build_path = os.join_path(os.dir(@FILE), '/docusaurus') // bizmodel.play(heroscript_path:heroscript)!
heroscript := os.join_path(os.dir(@FILE), 'examples/complete.heroscript')
// Execute the script and print results
bizmodel.play(heroscript_path:heroscript)!
mut bm := bizmodel.get("threefold")!
bm.sheet.pprint(nr_columns: 25)!
buildpath := '${os.home_dir()}/hero/var/mdbuild/bizmodel' buildpath := '${os.home_dir()}/hero/var/mdbuild/bizmodel'
println("buildpath: ${buildpath}")
mut model := bizmodel.getset('example')!
model.workdir = build_path
model.play(mut playbook.new(path: playbook_path)!)! model.play(mut playbook.new(path: playbook_path)!)!
println(model.sheet) println(model.sheet)

View File

@@ -40,6 +40,24 @@
// This is a simplified representation // This is a simplified representation
// Actual implementation would need precise month:amount pairs // Actual implementation would need precise month:amount pairs
!!bizmodel.costcenter_define bizname:'test' name:'marketing_cc'
descr:'Marketing Cost Center'
department:'marketing'
!!bizmodel.cost_define bizname:'test' name:'office_rent'
descr:'Office Rent'
cost:'8000USD'
indexation:'3%'
costcenter:'marketing_cc'
cost_percent_revenue:'0.5%'
!!bizmodel.cost_define bizname:'test' name:'triptomoon'
descr:'Office Rent'
cost:'10:500000USD' extrapolate:0 //this means we do a one off cost in this case month 11
costcenter:'marketing_cc'
// Define travel cost at 3% of revenue // Define travel cost at 3% of revenue
!!bizmodel.cost_define bizname:'threefold' name:'travel_cost' !!bizmodel.cost_define bizname:'threefold' name:'travel_cost'
descr:'Travel Expenses' descr:'Travel Expenses'

View File

@@ -84,7 +84,12 @@ pub fn (mut m BizModel) export_overview_action(action Action) !Action {
} }
fn (mut m BizModel) new_report_action(action Action) !Action { fn (mut m BizModel) new_report_action(action Action) !Action {
m.new_report(action.params.decode[Report]()!)! mut p:=action.params
path := p.get_default('path', '')!
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)!
return action return action
} }

View File

@@ -5,39 +5,27 @@ import os
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
pub struct Report { @[params]
pub: pub struct ExportArgs {
pub mut:
name string name string
title string title string
description string description string
path string path string
sections []ReportSection
} }
pub enum ReportSection { pub fn (b BizModel) export_all(args ExportArgs) ! {
revenue_model name := if args.name != '' { args.name } else { texttools.snake_case(args.title) }
cost_structure
human_resources
}
pub fn (b BizModel) new_report(report Report) !Report {
name := if report.name != '' { report.name } else { texttools.snake_case(report.title) }
path := pathlib.get_dir( path := pathlib.get_dir(
path: os.join_path(os.home_dir(), '/hero/var/bizmodel/reports/${name}') path: os.join_path(os.home_dir(), '/hero/var/bizmodel/exports/${name}')
create: true create: true
empty: true empty: true
)! )!
b.write_introduction(path.path)! b.write_introduction(args)!
b.write_operational_plan(path.path)! // b.write_operational_plan(args)!
b.write_revenue_model(path.path)! // b.write_revenue_model(args)!
b.write_cost_structure(path.path)! // b.write_cost_structure(args)!
return Report{
...report
name: name
path: path.path
}
// b.export_summary() // b.export_summary()
// b.export_business_description() // b.export_business_description()
// b.export_market_analysis() // b.export_market_analysis()
@@ -48,66 +36,15 @@ pub fn (b BizModel) new_report(report Report) !Report {
// b.export_fundraising(export) // b.export_fundraising(export)
} }
pub struct Export {
pub:
path string
overwrite bool
format ExportFormat
}
pub enum ExportFormat { pub fn (model BizModel) write_introduction(args ExportArgs) ! {
docusaurus mut index_page := pathlib.get_file(path: '${args.path}/introduction.md')!
mdbook
}
pub fn (r Report) export(export Export) ! {
// match export.format {
// .docusaurus {
// mut dir := pathlib.get_dir(path: r.path)!
// dir.copy(dest: '${export.path}/docs', delete: true)!
// mut factory := docusaurus.new()!
// mut site := factory.get(
// name: r.name
// path: export.path
// publish_path: export.path
// init: true
// config: docusaurus.Configuration{
// navbar: docusaurus.Navbar{
// title: 'Business Model'
// items: [
// docusaurus.NavbarItem{
// href: 'https://threefold.info/kristof/'
// label: 'ThreeFold Technology'
// position: 'right'
// },
// docusaurus.NavbarItem{
// href: 'https://threefold.io'
// label: 'Operational Plan'
// position: 'left'
// },
// ]
// }
// main: docusaurus.Main{
// url_home: 'docs/introduction'
// }
// } // TODO: is this needed
// )!
// site.generate()!
// }
// .mdbook {
// panic('MDBook export not fully implemented')
// }
// }
}
pub fn (model BizModel) write_introduction(path string) ! {
mut index_page := pathlib.get_file(path: '${path}/introduction.md')!
// mut tmpl_index := $tmpl('templates/index.md') // mut tmpl_index := $tmpl('templates/index.md')
index_page.template_write($tmpl('templates/introduction.md'), true)! index_page.template_write($tmpl('templates/introduction.md'), true)!
} }
pub fn (model BizModel) write_operational_plan(path string) ! { pub fn (model BizModel) write_operational_plan(args ExportArgs) ! {
mut dir := pathlib.get_dir(path: '${path}/operational_plan')! mut dir := pathlib.get_dir(path: '${args.path}/operational_plan')!
mut ops_page := pathlib.get_file(path: '${dir.path}/operational_plan.md')! mut ops_page := pathlib.get_file(path: '${dir.path}/operational_plan.md')!
ops_page.write('# Operational Plan')! ops_page.write('# Operational Plan')!
@@ -137,8 +74,8 @@ pub fn (model BizModel) write_operational_plan(path string) ! {
} }
} }
pub fn (model BizModel) write_revenue_model(path string) ! { pub fn (model BizModel) write_revenue_model(args ExportArgs) ! {
mut dir := pathlib.get_dir(path: '${path}/revenue_model')! mut dir := pathlib.get_dir(path: '${args.path}/revenue_model')!
mut rm_page := pathlib.get_file(path: '${dir.path}/revenue_model.md')! mut rm_page := pathlib.get_file(path: '${dir.path}/revenue_model.md')!
rm_page.write('# Revenue Model')! rm_page.write('# Revenue Model')!
@@ -155,8 +92,8 @@ pub fn (model BizModel) write_revenue_model(path string) ! {
} }
} }
pub fn (model BizModel) write_cost_structure(path string) ! { pub fn (model BizModel) write_cost_structure(args ExportArgs) ! {
mut dir := pathlib.get_dir(path: '${path}/cost_structure')! mut dir := pathlib.get_dir(path: '${args.path}/cost_structure')!
mut cs_page := pathlib.get_file(path: '${dir.path}/cost_structure.md')! mut cs_page := pathlib.get_file(path: '${dir.path}/cost_structure.md')!
cs_page.write('# Cost Structure')! cs_page.write('# Cost Structure')!
} }