This table is calculated using the lineitems facet
The lineitems facet contains formulas that calculate the Line Cost
and Line Offer
cells for each row as well as the aggregate values total_cost
, total_offer
and profit
that are displayed at the bottom of the table
Item | Item Cost | Unit Price | Quantity | Line Cost | Line Offer |
---|---|---|---|---|---|
No matching records found. | |||||
Profit: |
Create and populate the noSheet table:
1//
2//create and define the table
3//
4let new_table = createTable(['item', 'unit_cost', 'unit_offer', 'quantity'], lineitems);
5
6//
7//populate the table
8//
9new_table.load(data);
10new_table.calculate();
The lineitems facet:
1"use strict";
2/**
3A simple invoice/quotation calculator
4*/
5export default function(table, row) {
6
7 row.line_cost = () => row.quantity * row.unit_cost;
8 row.line_offer = () => row.quantity * row.unit_offer;
9
10 table.total_quantity = () => SUM(this.column('quantity'));
11 table.total_cost = () => SUM(this.column('line_cost'));
12 table.total_offer = () => SUM(this.column('line_offer'));
13 table.profit = () => table.total_offer - table.total_cost;
14};