Skip to content

Updates to scripting and reports for CPA macro functionality - #2121

Merged
sjanzou merged 4 commits into
developfrom
reports_and_script_updates
Oct 5, 2025
Merged

sjanzou merged 4 commits into
developfrom
reports_and_script_updates

Conversation

@sjanzou

@sjanzou sjanzou commented Oct 2, 2025 •

Copy link
Copy Markdown
Collaborator

Changes

casewin - add ExportCasflowExcel
reports - fix multiple table header lines
script - add fcall_export_cashflow_excel
macro - include invoke.h
results - move Export from private to public

Easiest way to test is to

  1. copy the deploy/runtime/macros/Community Solar/Community Power Accelerator.lk macro over to this branch (but do not commit)
  2. copy the deploy/runtime/quickstart/CPA-CommunitySolar.samreport report template (but do not commit)
  3. create a PVWatts/Community solar case
  4. run the Community Power Accelerator macro
  5. Check that the cash flow exports and the pdf report has a 2-line column header

casewin - add ExportCasflowExcel
reports - fix multiple table header lines
script - add fcall_export_cashflow_excel
macro - include invoke.h
results - move Export from private to public
@sjanzou sjanzou self-assigned this Oct 2, 2025

@cpaulgilman cpaulgilman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For LK function export_cashflow_excel():

  1. Function returns Null instead of boolean:
image image
  1. For PVWatts / No Financial case, function opens empty Excel file. For configs with no financial model, I think it should return False and not open Excel.

  2. The function runs a simulation, which means that in some cases (like the CPA macros) it runs a simulation when there are already results. It might be best to a) not run a simulation and return a message if there are no results, or b) add a flag parameter that determines whether to run a simulation.

  3. In Linux, the function runs and returns Null. I think it should return False.

  4. What is the "page name" input parameter?

  5. After opening Excel, the function displays the SAM Results window. I think that should be left to the script writer: If they want to display a page, they can use show_page() after calling the function.

@sjanzou

sjanzou commented Oct 3, 2025

Copy link
Copy Markdown
Collaborator Author

With commit 0a4b9c0, the fcall_export_cashflow_excel performs as follows:

  1. always returns a boolean
  2. no case - returns 0 (false from script)
image 3. case with no financial model - returns 0 (false from script) image 4. case not yet run - returns 0 (false from script) image 5. after base case run - returns 1 (true from script) image

@sjanzou
sjanzou requested a review from cpaulgilman October 3, 2025 08:28
* Use cf_om_fixed_expense to determine if financial model is cash flow-based
* Run simulation only if there are no results in base case
* Revise message text

@cpaulgilman cpaulgilman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sjanzou. I made some additional changes based on your updates. I think this looks good now.

@sjanzou
sjanzou merged commit 20c39bb into develop Oct 5, 2025
8 checks passed
@sjanzou
sjanzou deleted the reports_and_script_updates branch October 5, 2025 06:51
@brtietz brtietz added this to the SAM 2026 Release milestone Jun 25, 2026
@cpaulgilman cpaulgilman added the added to release notes PR and/or issue has been added to release notes for a public release label Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

added to release notes PR and/or issue has been added to release notes for a public release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants