The product module manages the catalog of goods tracked in Arsinous V8 Sales. It provides a modal dialog for creating and editing product records, a sheet sync function that rewrites the Products tab from 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.
products table, and an edit helper that works from either the Products or Inventory sheet. Products carry pricing tiers (cost, price, retail), a VAT code, and default discount rules that drive the invoice line-item calculations. All persistent changes route through saveProductToDb, which handles the INSERT/UPDATE and triggers a sheet refresh.
showProduct(productData)
Opens a 600 × 600 modal dialog rendered from the product/index HTML template. The dialog title and initial loading state are determined by whether a product object is supplied.
- When called without
productData: usesDefaultProductas the template data, setsloading: false, and titles the dialog “Add New Product”. - When called with
productData: passes the object to the template, setsloading: true(triggering a database fetch inside the dialog), and titles the dialog “Edit Product” (becauseproductData.idis truthy).
Vat constant is always injected into the template data so the dialog can render the correct VAT rate options.
A partial product object. When the
id property is set, the dialog operates in edit mode. If omitted or null, the dialog opens in create mode using DefaultProduct defaults. The default product shape (from Constants.gs) is:The
Vat constant (defined in Constants.gs) maps VAT codes to their percentage values and display names. Code "1" = 0%, "2" = 5%, "3" = 19%. It is passed to the dialog so the UI can render a dropdown without an additional database round-trip.editProduct()
Reads the currently selected row from the Products or Inventory sheet, builds a sparse product object from the sheet’s column headers, and delegates to showProduct(productData) in edit mode.
Validation rules (throws on failure):
- Active sheet name must be
"Products"or"Inventory". - Active cell row must be ≥ 2.
- Column A value of the selected row must be non-empty (the product
id).
'Select product to edit from "Products" or "Inventory" tab'.
editProduct uses .splice(1, 1)[0] — it reads row index 1 (the second row of the data range, i.e., the display row beneath the top header) to obtain column headers. This is significant on the Inventory sheet, which has two header rows: a title row (row 1) and a column-name row (row 2). The splice call extracts that second array element.
Only the
id field is populated before the dialog opens. All other product field values are fetched from the database by the dialog’s own initialization logic after rendering.updateProducts(conn)
Refreshes the Products sheet by clearing its existing data rows and rewriting every product from a SELECT * FROM products query. After writing data, it stamps the update time into cells K1:L1.
.splice(0, 1)[0]). Each column returned by MySQL is matched to its corresponding sheet column by name. Columns present in MySQL but absent from the sheet header row are silently skipped.
Timestamp: After writing all product rows, updateProducts writes ["Updated:", new Date()] into cells K1:L1 so users can see exactly when the last sync occurred.
An already-open JDBC connection to reuse. If not provided, the function opens its own connection using the global
InstanceUrl, User, and UserPwd constants. The connection is closed after reading results, so a passed-in connection will be closed by the time the function returns.