From b8759d29fb5fe290f9291fd9a9eb41dd0d4cfc17 Mon Sep 17 00:00:00 2001 From: despiegk Date: Mon, 21 Jul 2025 09:56:01 +0200 Subject: [PATCH] ... --- aiprompts/bizmodel/bizmodel_cost.md | 51 ++++++++++++++ aiprompts/bizmodel/bizmodel_funding.md | 35 ++++++++++ aiprompts/bizmodel/bizmodel_hr.md | 69 +++++++++++++++++++ aiprompts/bizmodel/bizmodel_revenue.md | 92 ++++++++++++++++++++++++++ aiprompts/bizmodel/costs.heroscript | 38 +++++++++++ examples/biztools/costs.vsh | 26 +++++--- lib/biz/bizmodel/docu/cost.md | 2 +- lib/biz/bizmodel/docu/funding.md | 35 ++++++++++ lib/biz/bizmodel/docu/revenue.md | 3 +- lib/biz/bizmodel/play.v | 4 +- lib/biz/bizmodel/play_cost.v | 46 +++++-------- lib/biz/bizmodel/play_funding.v | 5 +- lib/biz/bizmodel/play_hr.v | 2 - 13 files changed, 359 insertions(+), 49 deletions(-) create mode 100644 aiprompts/bizmodel/bizmodel_cost.md create mode 100644 aiprompts/bizmodel/bizmodel_funding.md create mode 100644 aiprompts/bizmodel/bizmodel_hr.md create mode 100644 aiprompts/bizmodel/bizmodel_revenue.md create mode 100644 aiprompts/bizmodel/costs.heroscript create mode 100644 lib/biz/bizmodel/docu/funding.md diff --git a/aiprompts/bizmodel/bizmodel_cost.md b/aiprompts/bizmodel/bizmodel_cost.md new file mode 100644 index 00000000..23154969 --- /dev/null +++ b/aiprompts/bizmodel/bizmodel_cost.md @@ -0,0 +1,51 @@ +# Cost Module Documentation + +This module provides functionalities related to managing various costs within the business model. + +## Actions + +### `!!bizmodel.cost_define` + +Defines a cost item and its associated properties. + +**Parameters:** + +* `bizname` (string, required): The name of the business model instance to which this cost belongs. +* `descr` (string, required): Description of the cost item. If `name` is not provided, it will be derived from this. +* `name` (string, optional): Unique name for the cost item. If not provided, it will be generated from `descr`. +* `cost` (string, required): The cost value. Can be a fixed value (e.g., '1000USD') or a growth rate (e.g., '0:1000,59:2000'). If `indexation` is used, this should not contain a colon. This value is extrapolated. +* `indexation` (percentage, optional, default: '0%'): Annual indexation rate for the cost. Applied over 6 years if specified. +* `costcenter` (string, optional): The costcenter associated with this cost. +* `cost_percent_revenue` (percentage, optional, default: '0%'): Ensures the cost is at least this percentage of the total revenue. +* `extrapolate`: If you want to extrapolate revenue or cogs do extrapolate:1, default is 0. + +### `!!bizmodel.costcenter_define` + +Defines a cost center. + +**Parameters:** + +* `bizname` (string, required): The name of the business model instance to which this cost belongs. +* `descr` (string, required): Description of the cost center. If `name` is not provided, it will be derived from this. +* `name` (string, optional): Unique name for the cost center. If not provided, it will be generated from `descr`. +* `department` (string, optional): The department associated with this cost center. + + +## **Example:** + +```js +!!bizmodel.costcenter_define bizname:'test' + descr:'Marketing Cost Center' + name:'marketing_cc' + department:'marketing' + + +!!bizmodel.cost_define bizname:'test' + descr:'Office Rent' + cost:'5000USD' + indexation:'3%' + costcenter:'marketing_cc' + cost_percent_revenue:'1%' + +``` + diff --git a/aiprompts/bizmodel/bizmodel_funding.md b/aiprompts/bizmodel/bizmodel_funding.md new file mode 100644 index 00000000..7b131ded --- /dev/null +++ b/aiprompts/bizmodel/bizmodel_funding.md @@ -0,0 +1,35 @@ +# Funding Module Documentation + +This module provides functionalities related to managing various funding sources within the business model. + +## Actions + +### `!!bizmodel.funding_define` + +Defines a funding entity and its associated properties. + +**Parameters:** + +* `bizname` (string, required): The name of the business model instance to which this funding belongs. +* `name` (string, required): Identifier for the funding entity. +* `descr` (string, optional): Human-readable description. If not provided, it will be derived from `description`. +* `investment` (string, required): Format `month:amount`, e.g., '0:10000,12:5000'. This value is extrapolated. +* `type` (string, optional, default: 'capital'): The type of funding. Allowed values: 'loan' or 'capital'. +* `extrapolate`: If you want to extrapolate revenue or cogs do extrapolate:1, default is 0. + +### `funding_total` + +Calculates the total funding. + +## **Example:** + +```js +!!bizmodel.funding_define bizname:'test' name:'seed_capital' + descr:'Initial Seed Capital Investment' + investment:'0:500000,12:200000' + type:'capital' + +!!bizmodel.funding_define bizname:'test' name:'bank_loan' + descr:'Bank Loan for Expansion' + investment:'6:100000,18:50000' + type:'loan' \ No newline at end of file diff --git a/aiprompts/bizmodel/bizmodel_hr.md b/aiprompts/bizmodel/bizmodel_hr.md new file mode 100644 index 00000000..6ee10818 --- /dev/null +++ b/aiprompts/bizmodel/bizmodel_hr.md @@ -0,0 +1,69 @@ +# HR Module Documentation + +This module provides functionalities related to Human Resources within the business model. + +## Actions + +All actions in the `bizmodel` module accept a `bizname` parameter (string, required) which specifies the business model instance to which the action applies. + +### `bizmodel.employee_define` + +Defines an employee and their associated costs within the business model. + +**Parameters:** + +* `bizname` (string, required): The name of the business model instance to which this cost belongs. +* `descr` (string, required): Description of the employee (e.g., 'Junior Engineer'). If `name` is not provided, it will be derived from this. +* `name` (string, optional): Unique name for the employee. If not provided, it will be generated from `descr`. +* `cost` (string, required): The cost associated with the employee. Can be a fixed value (e.g., '4000USD') or a growth rate (e.g., '1:5,60:30'). If `indexation` is used, this should not contain a colon. +* `nrpeople` (string, optional, default: '1'): The number of people for this employee definition. Can be a fixed number or a growth rate (e.g., '1:5,60:30'). +* `indexation` (percentage, optional, default: '0%'): Annual indexation rate for the cost. Applied over 6 years if specified. +* `department` (string, optional): The department the employee belongs to. +* `cost_percent_revenue` (percentage, optional, default: '0%'): Ensures the employee cost is at least this percentage of the total revenue. +* `costcenter` (string, optional, default: 'default_costcenter'): The cost center for the employee. +* `page` (string, optional): A reference to a page or document related to this employee. +* `fulltime` (percentage, optional, default: '100%'): The full-time percentage of the employee. + + +### `bizmodel.department_define` + +Defines a department within the business model. + +**Parameters:** + +* `bizname` (string, required): The name of the business model instance to which this cost belongs. +* `name` (string, required): Unique name for the department. +* `descr` (string, optional): Description of the department. If not provided, `description` will be used. +* `description` (string, optional): Description of the department. Used if `descr` is not provided. +* `title` (string, optional): A title for the department. +* `page` (string, optional): A reference to a page or document related to this department. + +## **Example:** + +```js + +!!bizmodel.department_define bizname:'test' + name:'engineering' + descr:'Software Development Department' + title:'Engineering Division' + //optional, if set overrules the hr_params + //avg_monthly_cost:'6000USD' avg_indexation:'5%' + +!!bizmodel.employee_define bizname:'test' + name:'ourclo' + descr:'CLO' + cost:'10000EUR' + indexation:'5%' + +!!bizmodel.employee_define bizname:'test' + name:'junior_engineer' + descr:'Junior Engineer' + nrpeople:'1:5,60:30' + cost:'4000USD' + indexation:'5%' + department:'engineering' + cost_percent_revenue:'4%' + + +``` + diff --git a/aiprompts/bizmodel/bizmodel_revenue.md b/aiprompts/bizmodel/bizmodel_revenue.md new file mode 100644 index 00000000..dbc37557 --- /dev/null +++ b/aiprompts/bizmodel/bizmodel_revenue.md @@ -0,0 +1,92 @@ +# Revenue + +``` +!!bizmodel.revenue_define bizname:'test' name:'oem1' ... +``` + +## Params + +- bizname, is the name of the biz model we are populating +- name, name of product, project +- descr, description of the revenue line item +- nr_months_recurring: e.g. 60 is 5 years + +## discrete revenue/cogs (not per item) + +cogs stands for cost of goods + +- revenue: one of revenue, can be extrapolated if specified +- cogs: cost of goods, this is the cost of the revenue, can be extrapolated if specified +- cogs_percent: percent of revenue +- cogs_delay: delay in months between cogs and revenue +- extrapolate: if you want to extrapolate revenue or cogs do extrapolate:1, default is 0 + +### results in + +follow rows in sheets + +- {name}_ + all the arg names as mentioned above... +- {name}_revenue_total +- {name}_cogs_total + +## grouped per items sold + +- nr_sold: how many do we sell per month (is in growth format e.g. 10:100,20:200, default is 1) +- revenue_item_setup, revenue for 1 item '1000usd' +- revenue_item_setup_delay, delay between sell and recognition of sale in months e.g. 1 +- revenue_item_monthly, revenue per month for 1 item +- revenue_item_monthly_delay, how many months before monthly revenue starts +- revenue_item_monthly_perc, how much percent of revenue_item_setup will come back over months e.g. 20% +- cogs_item_setup, cost of good for 1 item at setup +- cogs_item_setup_rev_perc: what is percentage of the revenue which is cogs, e.g. 2% +- cogs_item_monthly, cost of goods for the monthly per 1 item +- cogs_item_monthly_rev_perc: what is percentage of the monthly revenue which is cogs, e.g. 10% +- cogs_item_delay, how many months before cogs starts after sales + + + +### results in + +follow rows in sheets + +- {name}_ + all the arg names as mentioned above... +- {name}_revenue_item_setup_total +- {name}_revenue_item_monthly_total +- {name}_revenue_item_total + +- {name}_cogs_item_total + +## to use + +### basic example + +```v + +import freeflowuniverse.herolib.biz.bizmodel +import os + +heroscript:=" + +Next will define an OEM product in month 10, 1 Million EUR, ... cogs is a percent which is 20% at start but goes to 10% after 20 months. + +!!bizmodel.revenue_define bizname:'test' name:'oem1' + descr:'OEM Deals' + revenue:'10:1000000EUR,15:3333,20:1200000' + cogs_percent: '1:20%,20:10%' + + +This time we have the cogs defined in fixed manner, the default currency is USD doesn't have to be mentioned. + +!!bizmodel.revenue_define bizname:'test' name:'oem2' + descr:'OEM Deals' + revenue:'10:1000000EUR,15:3333,20:1200000' + cogs: '10:100000,15:1000,20:120000' +" + +bizmodel.play(heroscript:heroscript)! + +mut bm:=bizmodel.get("test")! + +bm.sheet.pprint()! + +``` \ No newline at end of file diff --git a/aiprompts/bizmodel/costs.heroscript b/aiprompts/bizmodel/costs.heroscript new file mode 100644 index 00000000..2aef602a --- /dev/null +++ b/aiprompts/bizmodel/costs.heroscript @@ -0,0 +1,38 @@ + +//need to define some revenue because otherwise can't see how HR relates to it +!!bizmodel.revenue_define bizname:'test' name:'oem1' extrapolate:1 + descr:'OEM Deals' revenue:'0:1000000,60:10000000' + cogs_percent: '0:20%' + +!!bizmodel.department_define bizname:'test' name:'marketing' + descr:'Marketing Department' + +!!bizmodel.department_define bizname:'test' name:'engineering' + descr:'Engineering Department' + +!!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:'travel' + descr:'Office Rent' + cost:'2:5000USD' //start month 3 + costcenter:'marketing_cc' + +!!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' + + +// !!bizmodel.cost_define bizname:'test' name:'software_licenses' +// descr:'Annual Software Licenses' +// cost:'0:10000 10:EUR:20kCHF,12:5000USD' +// department:'engineering' diff --git a/examples/biztools/costs.vsh b/examples/biztools/costs.vsh index dcd16a6d..7e2e847d 100755 --- a/examples/biztools/costs.vsh +++ b/examples/biztools/costs.vsh @@ -10,8 +10,6 @@ heroscript := " descr:'OEM Deals' revenue:'0:1000000,60:10000000' cogs_percent: '0:20%' -!!bizmodel.employee_define bizn - !!bizmodel.department_define bizname:'test' name:'marketing' descr:'Marketing Department' @@ -24,16 +22,26 @@ heroscript := " !!bizmodel.cost_define bizname:'test' name:'office_rent' descr:'Office Rent' - cost:'5000USD' + cost:'8000USD' indexation:'3%' costcenter:'marketing_cc' - cost_percent_revenue:'1%' + cost_percent_revenue:'0.5%' -!!bizmodel.cost_define bizname:'test' name:'software_licenses' - descr:'Annual Software Licenses' - cost:'0:10000 10:EUR:20kCHF,12:5000USD' - cost_one:'true' // Example of a one-time cost - department:'engineering' +!!bizmodel.cost_define bizname:'test' name:'travel' + descr:'Office Rent' + cost:'2:5000USD' //start month 3 + costcenter:'marketing_cc' + +!!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' + + +// !!bizmodel.cost_define bizname:'test' name:'software_licenses' +// descr:'Annual Software Licenses' +// cost:'0:10000 10:EUR:20kCHF,12:5000USD' +// department:'engineering' " diff --git a/lib/biz/bizmodel/docu/cost.md b/lib/biz/bizmodel/docu/cost.md index 21377540..23154969 100644 --- a/lib/biz/bizmodel/docu/cost.md +++ b/lib/biz/bizmodel/docu/cost.md @@ -14,10 +14,10 @@ Defines a cost item and its associated properties. * `descr` (string, required): Description of the cost item. If `name` is not provided, it will be derived from this. * `name` (string, optional): Unique name for the cost item. If not provided, it will be generated from `descr`. * `cost` (string, required): The cost value. Can be a fixed value (e.g., '1000USD') or a growth rate (e.g., '0:1000,59:2000'). If `indexation` is used, this should not contain a colon. This value is extrapolated. -* `cost_one` (string, optional): A single cost value. If provided, `cost` will be ignored and extrapolation will be set to false. * `indexation` (percentage, optional, default: '0%'): Annual indexation rate for the cost. Applied over 6 years if specified. * `costcenter` (string, optional): The costcenter associated with this cost. * `cost_percent_revenue` (percentage, optional, default: '0%'): Ensures the cost is at least this percentage of the total revenue. +* `extrapolate`: If you want to extrapolate revenue or cogs do extrapolate:1, default is 0. ### `!!bizmodel.costcenter_define` diff --git a/lib/biz/bizmodel/docu/funding.md b/lib/biz/bizmodel/docu/funding.md new file mode 100644 index 00000000..7b131ded --- /dev/null +++ b/lib/biz/bizmodel/docu/funding.md @@ -0,0 +1,35 @@ +# Funding Module Documentation + +This module provides functionalities related to managing various funding sources within the business model. + +## Actions + +### `!!bizmodel.funding_define` + +Defines a funding entity and its associated properties. + +**Parameters:** + +* `bizname` (string, required): The name of the business model instance to which this funding belongs. +* `name` (string, required): Identifier for the funding entity. +* `descr` (string, optional): Human-readable description. If not provided, it will be derived from `description`. +* `investment` (string, required): Format `month:amount`, e.g., '0:10000,12:5000'. This value is extrapolated. +* `type` (string, optional, default: 'capital'): The type of funding. Allowed values: 'loan' or 'capital'. +* `extrapolate`: If you want to extrapolate revenue or cogs do extrapolate:1, default is 0. + +### `funding_total` + +Calculates the total funding. + +## **Example:** + +```js +!!bizmodel.funding_define bizname:'test' name:'seed_capital' + descr:'Initial Seed Capital Investment' + investment:'0:500000,12:200000' + type:'capital' + +!!bizmodel.funding_define bizname:'test' name:'bank_loan' + descr:'Bank Loan for Expansion' + investment:'6:100000,18:50000' + type:'loan' \ No newline at end of file diff --git a/lib/biz/bizmodel/docu/revenue.md b/lib/biz/bizmodel/docu/revenue.md index 69f78190..dbc37557 100644 --- a/lib/biz/bizmodel/docu/revenue.md +++ b/lib/biz/bizmodel/docu/revenue.md @@ -19,8 +19,7 @@ cogs stands for cost of goods - cogs: cost of goods, this is the cost of the revenue, can be extrapolated if specified - cogs_percent: percent of revenue - cogs_delay: delay in months between cogs and revenue - -if you want to extrapolate cogs or revenue do extrapolate:1 +- extrapolate: if you want to extrapolate revenue or cogs do extrapolate:1, default is 0 ### results in diff --git a/lib/biz/bizmodel/play.v b/lib/biz/bizmodel/play.v index 30f6031c..59b86fe5 100644 --- a/lib/biz/bizmodel/play.v +++ b/lib/biz/bizmodel/play.v @@ -6,8 +6,8 @@ import freeflowuniverse.herolib.ui.console const action_priorities = { 0: ['department_define', 'costcenter_define'] - 1: ['revenue_define', 'funding_define', 'cost_define'] - 2: ['employee_define'] + 1: ['revenue_define', 'funding_define'] + 2: ['cost_define','employee_define'] 3: ['sheet_wiki', 'graph_bar_row', 'graph_pie_row', 'graph_line_row', 'row_overview'] } diff --git a/lib/biz/bizmodel/play_cost.v b/lib/biz/bizmodel/play_cost.v index befe24dc..3d220521 100644 --- a/lib/biz/bizmodel/play_cost.v +++ b/lib/biz/bizmodel/play_cost.v @@ -1,7 +1,6 @@ module bizmodel import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.data.currency import math @@ -22,7 +21,6 @@ fn (mut m BizModel) cost_define_action(action Action) !Action { descr = action.params.get_default('description', '')! } mut cost := action.params.get_default('cost', '0.0')! // is extrapolated - mut cost_one := action.params.get_default('cost_one', '')! department := action.params.get_default('department', 'default')! if department != 'default' && department !in m.departments { @@ -34,8 +32,7 @@ fn (mut m BizModel) cost_define_action(action Action) !Action { return error('Costcenter `${costcenter}` not found. Please define it first.') } - cost_percent_revenue := action.params.get_percentage_default('cost_percent_revenue', - '0%')! + cost_percent_revenue := action.params.get_percentage_default('cost_percent_revenue','0%')! indexation := action.params.get_percentage_default('indexation', '0%')! @@ -49,38 +46,29 @@ fn (mut m BizModel) cost_define_action(action Action) !Action { cost = '0:${cost_amount.usd()},59:${cost_amount_val_result}' } - mut extrap := false - if cost_one != '' { - extrap = false - cost = cost_one - } else { - extrap = true - } - mut cost_row := m.sheet.row_new( name: 'cost_${name}' growth: cost - tags: 'department:${department} ocost' - descr: 'cost overhead for department ${department}' - extrapolate: extrap + tags: 'department:${department} cost' + descr: descr + extrapolate: action.params.get_default_true('extrapolate') )! - cost_row.action(action: .reverse)! + cost_row = cost_row.action(action: .reverse)! + if cost_percent_revenue > 0 { + // println(cost_row) mut revtotal := m.sheet.row_get('revenue_total')! - mut cost_min := revtotal.action( - action: .multiply - val: cost_percent_revenue - name: 'tmp3' - aggregatetype: .avg - )! - cost_min.action(action: .forwardavg)! // avg out forward looking for 12 months - cost_min.action(action: .reverse)! - cost_row.action( - action: .min - rows: [cost_min] - )! - m.sheet.row_delete('tmp3') + + for x in 0 .. cost_row.cells.len { + mut curcost := -cost_row.cells[x].val + mut currev := revtotal.cells[x].val + // println("currev: ${currev}, curcost: ${curcost}, costpercent_revenue: ${currev*cost_percent_revenue}") + if currev * cost_percent_revenue > curcost { + cost_row.cells[x].val = -currev * cost_percent_revenue + } + } + // println(cost_row) } return action } diff --git a/lib/biz/bizmodel/play_funding.v b/lib/biz/bizmodel/play_funding.v index b529808d..2c61b99b 100644 --- a/lib/biz/bizmodel/play_funding.v +++ b/lib/biz/bizmodel/play_funding.v @@ -16,9 +16,6 @@ fn (mut m BizModel) funding_define_action(action Action) !Action { if descr.len == 0 { descr = action.params.get_default('description', '')! } - // if descr.len == 0 { - // descr = 'Funding definition for ${name}' - // } mut investment := action.params.get_default('investment', '')! if investment.len == 0 { @@ -35,7 +32,7 @@ fn (mut m BizModel) funding_define_action(action Action) !Action { growth: investment tags: 'funding type:${fundingtype}' descr: descr - extrapolate: false + extrapolate: action.params.get_default_false('extrapolate') )! return action diff --git a/lib/biz/bizmodel/play_hr.v b/lib/biz/bizmodel/play_hr.v index 58e29653..dd6b4555 100644 --- a/lib/biz/bizmodel/play_hr.v +++ b/lib/biz/bizmodel/play_hr.v @@ -1,8 +1,6 @@ module bizmodel import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.core.texttools -import freeflowuniverse.herolib.data.paramsparser import freeflowuniverse.herolib.data.currency import math