Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Script overview
Imports/validation, standard lambda function implementation. This function promises we return an ApiBase64SuccessResponse...
... which is returned at the bottom of the function.
Lines 21-70
Sorting inputs of the periodsEstimate incoming JSON.
Example payload:
The payload is sorted on the SNOW side, however we sort it again on the Lambda side for extra safety.
Setting the fundingDocument number, this will be at the top of each page.
These ranges are on the
CLIN Info
page:Get the unique CLINs and contractType for a given period.
Alphabetic sort of the CLINs.
###71-204
Create the workbook (exceljs notation) from the template file.
getWorksheet
on the Summary page, so we can use summarySheet later.periodSheetHelper stores the range of the summary calculations of each periodSheet:
If there are less than 20 items in the periodLineItems for a given period,
the range will always be the default:
!A28:I41
.periodSheetHelper's stored summary ranges are used on the Summary sheet:
For each period in the periodEstimate object (see example payload above), go through the periodLine items
and write them to the correct periodSheet
Determine the sheet that we are currently writing to based on period...
Set static values into the specific cells (funding document number and pop.
20 rows is the template default. If there are more than 20 items in the periodLineItems, we need to add more rows.
We accomplish this with
duplicateRow
which preserves the template formatting.Using excelJs's getRows (Get or create rows by 1-based index)...
We get the row (example row 1) and then set all cells in that row. numberOfItems is the number of cells to fill.
.dataValidation allows use to set specific formulae
Maps all the properties of an object in the periodLineItems array.
^This part.
Fills up the bottom of the periodSheet with unique CLINs
Calling
populatePeriodLineItems()
on base and option periods.211-295
6 is the starting point:
and we fill it for as many uniqueCLINs exist. In the example above it would be 2 unqiueCLINs.
Uses the clinRangeString, which is a reference to the CLIN Info sheet.
Uses the contractRangeString, which is a reference to the CLIN Info sheet.
Using specific periodSheet helper to find the summary range for the period sheet.
In this example, the range for Base Period would be
A28:I41
Populates the formula for each period sheet. If an IGCE has 3 periods (base, op1, op2), it would fill 3 cells.
Example formula output
=IFERROR(VLOOKUP(A6,'Base Period'!A28:I41,9, FALSE),0)
This formula searches the periodsheet in the specific range for a the matching total CLIN (located at bottom of the periodSheet).
Setting static values.
Convert the workbook into a buffer so it can be sent as a base64 string.