The customer module handles the full lifecycle of customer records inside Arsinous V8 Sales. It bridges the Google Sheets “Customers” tab and the MySQLDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/arsinousltd-sudo/Arsinous-V8-Sales/llms.txt
Use this file to discover all available pages before exploring further.
customers table, providing modal dialogs for creating and editing customer data, a sync function that rewrites the sheet from the database on demand, and a shortcut to navigate directly to a customer’s linked Google Drive folder. All write operations are ultimately routed through saveCustomerToDb in the DB layer, which manages Drive folder creation for new customers and issues the correct INSERT or UPDATE statement.
showCustomer(customerData)
Opens a 600 × 650 modal dialog rendered from the Customer/index HTML template. The dialog title and loading state depend on whether a customer object is passed.
- When called without
customerData: usesDefaultCustomeras the template data, setsloading: false, and titles the dialog “Add New Customer”. - When called with
customerData: passes the object as-is, setsloading: true(triggering an immediate DB fetch inside the dialog), and titles the dialog “Edit Customer” (becausecustomerData.idis truthy).
A partial customer object. When the
id property is set (non-null), the dialog operates in edit mode and shows “Edit Customer” as the title. If omitted or null, the dialog opens in create mode with DefaultCustomer defaults. The full shape of the object mirrors the customers table columns: id, code, name, address, municipality, city, zip, phone, details, folder, discounts.The
DefaultCustomer constant (defined in Constants.gs) provides null values for all fields. The dialog’s front-end replaces these with form inputs. Setting loading: true causes the dialog to immediately call back to getItemsFromDB to hydrate fields from the database before the user can interact with the form.editCustomer()
Reads the currently selected row on the Customers sheet, builds a sparse customer object from the sheet’s column headers, and delegates to showCustomer(customerData) in edit mode.
Validation rules (throws on failure):
- Active sheet name must be
"Customers". - Active cell row must be ≥ 2 (skips the header row).
- Column A value of the selected row must be non-empty (the customer
id).
'Select customer to edit from "Customers" tab'.
customerData with null for every column. It then sets customerData.id to the value found in column A of the selected row, which causes showCustomer to render the edit dialog with loading: true.
Only the
id field is pre-populated before the dialog opens. All other customer fields are fetched from the database by the dialog’s own initialization logic once it is rendered.updateCustomers(conn)
Refreshes the Customers sheet by clearing its existing data and rewriting every row from a SELECT * FROM customers query. After writing the raw data, it replaces the second-to-last column with a Google Drive folder hyperlink formula for each customer.
customers result column to its matching sheet column by name. This means the sheet headers and the MySQL column names must match exactly.
Folder link: After writing all data, a =HYPERLINK(...) formula pointing to https://drive.google.com/drive/folders/<folder_id> is injected into the column at position lastCol - 1 (the second-to-last populated column) for every customer row.
An already-open JDBC connection to reuse. If not provided, the function opens its own connection using the
InstanceUrl, User, and UserPwd constants. The connection is always closed at the end of this function, so callers that pass an open connection should not rely on it remaining open afterward.navigateToCustomersFolder()
Opens the Google Drive folder associated with the selected customer in a new browser tab. It uses the same row-validation logic as editCustomer and then delegates to navigateTo('folder', id).
Validation rules (throws on failure):
- Active sheet name must be
"Customers". - Active cell row must be ≥ 2.
- Column A value of the selected row must be non-empty.
"folder", reads the folder ID from that column in the selected row, and passes it to navigateTo. The navigateTo helper (defined in onOpen.gs) renders a tiny redirect modal that calls window.open(...) with the Drive URL and then closes itself.
The variable
id is shadowed inside the function: the first id is the customer record’s primary key (from column A), and the second id (reassigned before calling navigateTo) is the Google Drive folder ID stored in the folder column. The Drive folder ID — not the customer database ID — is what gets passed to navigateTo.