全部文档
文档中心财务模型deepcubedeepcube语法完整脚本示例

完整脚本示例

一个deepcube计算语句的实例如下:

Copy
from deepcube.cube.cube import deepcube


def main():
    # 实例一个deepcube对象,传参为cube元素名和path,如果cube元素名在应用中唯一,可以不传path
    cube1 = deepcube('cube1')

    # 为了后续计算写法简单,在这里将cube的维度赋值给同名变量(注意这里cube1.year中的year是字段名)

    year = cube1.year
    period = cube1.period
    scenario = cube1.scenario
    version = cube1.version
    product = cube1.product
    account = cube1.account

    # 从系统的财务模型中加载数据。
    cube1.init_data([year["2021"],
                     scenario["Actual"],
                     version["Working"]])

    # 确定一个背景scope范围
    cube1.scope(year["2021"],
                scenario["Actual"],
                version["Working"],
                period["YearTotal"].Base(),
                product["TotalProduct"].Base()
                )

    # 计算
    cube1.loc[account["Total_Sales"]] = cube1.loc[account['Volume']
                                        ] * cube1.loc[account['Price'], period['NoPeriod']]

    # 将计算结果写入系统的财务模型中
    cube1.submit_calc()

以上的计算语句,会用2021年每个月份的所有产品的销售量,乘以各产品设定在NoPeriod期间成员上的单价,得到各个产品的销售额。

回到顶部

咨询热线

400-821-9199

我们使用 ChatGPT,基于文档中心的内容以及对话上下文回答您的问题。

ctrl+Enter to send