...
This commit is contained in:
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
@@ -15,13 +15,22 @@ mut model := bizmodel.getset("example")!
|
||||
model.workdir = build_path
|
||||
model.play(mut playbook.new(path: playbook_path)!)!
|
||||
|
||||
report := model.new_report(
|
||||
name: 'example_report'
|
||||
title: 'Example Business Model'
|
||||
)!
|
||||
println(model.sheet)
|
||||
println(model.sheet.export()!)
|
||||
|
||||
report.export(
|
||||
path: build_path
|
||||
overwrite: true
|
||||
format: .docusaurus
|
||||
)!
|
||||
model.sheet.export(path:"~/Downloads/test.csv")!
|
||||
model.sheet.export(path:"~/code/github/freeflowuniverse/starlight_template/src/content/test.csv")!
|
||||
|
||||
|
||||
|
||||
|
||||
// report := model.new_report(
|
||||
// name: 'example_report'
|
||||
// title: 'Example Business Model'
|
||||
// )!
|
||||
|
||||
// report.export(
|
||||
// path: build_path
|
||||
// overwrite: true
|
||||
// format: .docusaurus
|
||||
// )!
|
||||
@@ -4,11 +4,29 @@
|
||||
|
||||
This company is a cloud company ...
|
||||
|
||||
- name, e.g. for a specific project
|
||||
- descr, description of the revenue line item
|
||||
- revenue_setup, revenue for 1 item '1000usd'
|
||||
- revenue_setup_delay
|
||||
- revenue_monthly, revenue per month for 1 item
|
||||
- revenue_monthly_delay, how many months before monthly revenue starts
|
||||
- maintenance_month_perc, how much percent of revenue_setup will come back over months
|
||||
- cogs_setup, cost of good for 1 item at setup
|
||||
- cogs_setup_delay, how many months before setup cogs starts, after sales
|
||||
- cogs_setup_perc: what is percentage of the cogs (can change over time) for setup e.g. 0:50%
|
||||
|
||||
- cogs_monthly, cost of goods for the monthly per 1 item
|
||||
- cogs_monthly_delay, how many months before monthly cogs starts, after sales
|
||||
- cogs_monthly_perc: what is percentage of the cogs (can change over time) for monthly e.g. 0:5%,12:10%
|
||||
|
||||
- nr_sold: how many do we sell per month (is in growth format e.g. 10:100,20:200, default is 1)
|
||||
- nr_months_recurring: how many months is recurring, if 0 then no recurring
|
||||
|
||||
```js
|
||||
!!bizmodel.revenue_define bizname:'test'
|
||||
descr:'OEM Deals'
|
||||
revenue_time:'10:1000000EUR,15:3333,20:1200000'
|
||||
cogs_perc: '1:5%,20:10%'
|
||||
revenue_setup:'10:1000000EUR,15:3333,20:1200000'
|
||||
cogs_setup_perc: '1:5%,20:10%'
|
||||
|
||||
!!bizmodel.revenue_define bizname:'test'
|
||||
descr:'License Deals'
|
||||
@@ -23,6 +41,7 @@ This company is a cloud company ...
|
||||
revenue_nr:'10:1000,24:2000,60:40000'
|
||||
cogs_perc: '10%'
|
||||
rev_delay_month: 1
|
||||
|
||||
```
|
||||
|
||||
## Revenue Items Recurring
|
||||
@@ -13,12 +13,10 @@ import freeflowuniverse.herolib.core.texttools
|
||||
// - cogs_setup, cost of good for 1 item at setup
|
||||
// - cogs_setup_delay, how many months before setup cogs starts, after sales
|
||||
// - cogs_setup_perc: what is percentage of the cogs (can change over time) for setup e.g. 0:50%
|
||||
|
||||
// - cogs_monthly, cost of goods for the monthly per 1 item
|
||||
// - cogs_monthly_delay, how many months before monthly cogs starts, after sales
|
||||
// - cogs_monthly_perc: what is percentage of the cogs (can change over time) for monthly e.g. 0:5%,12:10%
|
||||
|
||||
// - nr_sold: how many do we sell per month (is in growth format e.g. 10:100,20:200)
|
||||
// - nr_sold: how many do we sell per month (is in growth format e.g. 10:100,20:200, default is 1)
|
||||
// - nr_months_recurring: how many months is recurring, if 0 then no recurring
|
||||
//
|
||||
fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
@@ -62,6 +60,10 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
extrapolate: false
|
||||
)!
|
||||
|
||||
println(action)
|
||||
println(revenue)
|
||||
exit(0)
|
||||
|
||||
mut revenue_setup := m.sheet.row_new(
|
||||
name: '${name}_revenue_setup'
|
||||
growth: action.params.get_default('revenue_setup', '0:0')!
|
||||
@@ -139,11 +141,6 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
aggregatetype: .avg
|
||||
)!
|
||||
|
||||
// if true{
|
||||
// println(cogs_setup_perc)
|
||||
// println(cogs_monthly_perc)
|
||||
// panic("sdsd")
|
||||
// }
|
||||
|
||||
mut nr_sold := m.sheet.row_new(
|
||||
name: '${name}_nr_sold'
|
||||
@@ -211,10 +208,6 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
nrmonths: nr_months_recurring
|
||||
aggregatetype: .max
|
||||
)!
|
||||
// if true{
|
||||
// println(nr_sold_recurring)
|
||||
// panic('sd')
|
||||
// }
|
||||
}
|
||||
|
||||
// cogs as percentage of revenue
|
||||
@@ -229,16 +222,17 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
name: '${name}_cogs_monthly_from_perc'
|
||||
)!
|
||||
|
||||
// if true{
|
||||
// println(revenue_setup_total)
|
||||
// println(cogs_setup_perc)
|
||||
// println(cogs_setup_from_perc)
|
||||
// println("montlhy")
|
||||
// println(revenue_monthly_total)
|
||||
// println(cogs_monthly_perc)
|
||||
// println(cogs_monthly_from_perc)
|
||||
// panic("sdsd")
|
||||
// }
|
||||
println(action)
|
||||
println(nr_sold)
|
||||
println(revenue)
|
||||
println(revenue_setup_total)
|
||||
println(revenue_monthly_total)
|
||||
println(cogs_setup_perc)
|
||||
println(cogs_setup_from_perc)
|
||||
println(cogs_monthly_perc)
|
||||
println(cogs_monthly_from_perc)
|
||||
exit(0)
|
||||
|
||||
|
||||
// mut cogs_from_perc:=cogs_perc.action(action:.multiply,rows:[revenue],name:"cogs_from_perc")!
|
||||
|
||||
|
||||
49
lib/biz/spreadsheet/sheet_export.v
Normal file
49
lib/biz/spreadsheet/sheet_export.v
Normal file
@@ -0,0 +1,49 @@
|
||||
module spreadsheet
|
||||
import os
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
|
||||
@[params]
|
||||
pub struct ExportArgs{
|
||||
pub mut:
|
||||
path string
|
||||
}
|
||||
|
||||
fn format_number(val f64) string {
|
||||
if val < 0.001 && val > -0.001 {
|
||||
return '0'
|
||||
}
|
||||
if val >= 1000.0 || val <= -1000.0 {
|
||||
return int(val).str()
|
||||
}
|
||||
// Format small numbers with 3 decimal places to handle floating point precision
|
||||
return '${val:.3f}'
|
||||
}
|
||||
|
||||
pub fn (mut s Sheet) export(args ExportArgs) !string {
|
||||
mut result := []string{}
|
||||
|
||||
// Add headers
|
||||
mut header_row := ['Name', 'Description', 'AggregateType', 'Tags', 'Subgroup']
|
||||
header_row << s.header()!
|
||||
result << header_row.join('|')
|
||||
|
||||
// Add rows
|
||||
for _, row in s.rows {
|
||||
mut row_data := [row.name, row.description, row.aggregatetype.str(), row.tags, row.subgroup]
|
||||
for cell in row.cells {
|
||||
if cell.empty {
|
||||
row_data << '-'
|
||||
} else {
|
||||
row_data << format_number(cell.val)
|
||||
}
|
||||
}
|
||||
result << row_data.join('|')
|
||||
}
|
||||
|
||||
if args.path.len>0{
|
||||
mut p:=pathlib.get_file(path:args.path.replace("~",os.home_dir()), create:true, delete:true)!
|
||||
p.write(result.join('\n'))!
|
||||
}
|
||||
|
||||
return result.join('\n')
|
||||
}
|
||||
Reference in New Issue
Block a user