...
This commit is contained in:
@@ -6,14 +6,21 @@ import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.core.playcmds
|
||||
import os
|
||||
|
||||
// TODO: need to fix wrong location
|
||||
const playbook_path = os.dir(@FILE) + '/playbook'
|
||||
const build_path = os.join_path(os.dir(@FILE), '/docusaurus')
|
||||
// heroscript := os.join_path(os.dir(@FILE), 'examples/full')
|
||||
// // Execute the script and print results
|
||||
// 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'
|
||||
println("buildpath: ${buildpath}")
|
||||
|
||||
mut model := bizmodel.getset('example')!
|
||||
model.workdir = build_path
|
||||
model.play(mut playbook.new(path: playbook_path)!)!
|
||||
|
||||
println(model.sheet)
|
||||
@@ -40,6 +40,24 @@
|
||||
// This is a simplified representation
|
||||
// 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
|
||||
!!bizmodel.cost_define bizname:'threefold' name:'travel_cost'
|
||||
descr:'Travel Expenses'
|
||||
|
||||
@@ -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 {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -5,39 +5,27 @@ import os
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
|
||||
pub struct Report {
|
||||
pub:
|
||||
@[params]
|
||||
pub struct ExportArgs {
|
||||
pub mut:
|
||||
name string
|
||||
title string
|
||||
description string
|
||||
path string
|
||||
sections []ReportSection
|
||||
}
|
||||
|
||||
pub enum ReportSection {
|
||||
revenue_model
|
||||
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) }
|
||||
pub fn (b BizModel) export_all(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/reports/${name}')
|
||||
path: os.join_path(os.home_dir(), '/hero/var/bizmodel/exports/${name}')
|
||||
create: true
|
||||
empty: true
|
||||
)!
|
||||
|
||||
b.write_introduction(path.path)!
|
||||
b.write_operational_plan(path.path)!
|
||||
b.write_revenue_model(path.path)!
|
||||
b.write_cost_structure(path.path)!
|
||||
|
||||
return Report{
|
||||
...report
|
||||
name: name
|
||||
path: path.path
|
||||
}
|
||||
b.write_introduction(args)!
|
||||
// b.write_operational_plan(args)!
|
||||
// b.write_revenue_model(args)!
|
||||
// b.write_cost_structure(args)!
|
||||
// b.export_summary()
|
||||
// b.export_business_description()
|
||||
// b.export_market_analysis()
|
||||
@@ -48,66 +36,15 @@ pub fn (b BizModel) new_report(report Report) !Report {
|
||||
// b.export_fundraising(export)
|
||||
}
|
||||
|
||||
pub struct Export {
|
||||
pub:
|
||||
path string
|
||||
overwrite bool
|
||||
format ExportFormat
|
||||
}
|
||||
|
||||
pub enum ExportFormat {
|
||||
docusaurus
|
||||
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')!
|
||||
pub fn (model BizModel) write_introduction(args ExportArgs) ! {
|
||||
mut index_page := pathlib.get_file(path: '${args.path}/introduction.md')!
|
||||
// mut tmpl_index := $tmpl('templates/index.md')
|
||||
index_page.template_write($tmpl('templates/introduction.md'), true)!
|
||||
}
|
||||
|
||||
pub fn (model BizModel) write_operational_plan(path string) ! {
|
||||
mut dir := pathlib.get_dir(path: '${path}/operational_plan')!
|
||||
pub fn (model BizModel) write_operational_plan(args ExportArgs) ! {
|
||||
mut dir := pathlib.get_dir(path: '${args.path}/operational_plan')!
|
||||
mut ops_page := pathlib.get_file(path: '${dir.path}/operational_plan.md')!
|
||||
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) ! {
|
||||
mut dir := pathlib.get_dir(path: '${path}/revenue_model')!
|
||||
pub fn (model BizModel) write_revenue_model(args ExportArgs) ! {
|
||||
mut dir := pathlib.get_dir(path: '${args.path}/revenue_model')!
|
||||
mut rm_page := pathlib.get_file(path: '${dir.path}/revenue_model.md')!
|
||||
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) ! {
|
||||
mut dir := pathlib.get_dir(path: '${path}/cost_structure')!
|
||||
pub fn (model BizModel) write_cost_structure(args ExportArgs) ! {
|
||||
mut dir := pathlib.get_dir(path: '${args.path}/cost_structure')!
|
||||
mut cs_page := pathlib.get_file(path: '${dir.path}/cost_structure.md')!
|
||||
cs_page.write('# Cost Structure')!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user