forked from mtottrup/restaurant-pos-gas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code.gs
31 lines (27 loc) · 1008 Bytes
/
Code.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function doGet() {
return HtmlService.createTemplateFromFile('index').evaluate();
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
}
function getData() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
let ws = ss.getSheetByName("Items");
let res = {};
res.items = ws.getRange(2 , 1, ws.getLastRow()-1, 5).getValues();
ws = ss.getSheetByName("Sales");
res.sales = ws.getRange(2, 1, ws.getLastRow()-1, 6).getValues();
return res;
}
function setData(data) {
const importedData = JSON.parse(data);
const orderLength = importedData.order.length;
const ss = SpreadsheetApp.getActiveSpreadsheet();
ws = ss.getSheetByName("Sales");
range = ws.getRange(ws.getLastRow()+1, 1, orderLength, 6);
range.setValues(importedData.order);
ws = ss.getSheetByName("Payments");
const paymentColumns = importedData.payment[0].length;
range = ws.getRange(ws.getLastRow()+1, 1, 1, paymentColumns);
range.setValues(importedData.payment);
}