CTS / Estratek-BZ — Coding Standards

CTS / Estratek-BZ — Coding Standards

CTS / Estratek-BZ — Coding Standards

Applies to both repos: ctsdealer (port 3001) and cts-service-layer (port 3000)


1. Everything in English

Comments, variable names, function names, and commit messages must always be in English, no exceptions.

✓ Correct✗ Incorrect
// Fetch cylinder list from DB
const cylinderList = []
// Obtener cilindros
const listaCilindros = []

2. Styles via CSS classes, never inline

Colors and styles are applied exclusively using CSS classes. Using element.style.* inline styles in JavaScript is prohibited.
CSS classes are defined as constants in src/js/constants.js under the cssClasses object and referenced as cssClasses.NAME. New classes are added in ctssection.scss with the ticket number as a comment.

✓ Correct✗ Incorrect
// constants.js
cssClasses: { STATUS_OK: 'cts-status--ok' }

// usage
el.classList.add(cssClasses.STATUS_OK)
el.style.color = 'green'
el.classList.add('cts-status--ok')

3. Prefer Sequelize ORM over JavaScript for data operations

Everything the ORM can do must be done at the Sequelize level: filtering, sorting, grouping, pagination, and limits. Never fetch data to the server and process it with JavaScript when the database can do it directly.

✓ Correct✗ Incorrect
Model.findAll({
  where: { active: true },
  order: [['createdAt', 'DESC']],
  limit: 50
})
const rows = await Model.findAll()
rows.filter(r => r.active)
  .sort((a,b) => b.createdAt - a.createdAt)

4. Each ticket gets its own branch and pull request

Every new case or ticket is worked on a separate branch. When finished, a pull request is opened for review. Corrections or observations on that PR are applied on the same branch. Changes of a different scope must go on a separate branch with a new PR to keep things clean.

✓ Correct✗ Incorrect
feature/CTS-2201-approved-field → PR #1
  (corrections stay on same branch)
feature/CTS-2210-new-report → PR #2
feature/CTS-2201-approved-field
  (mixing CTS-2210 changes into
   the same branch/PR)

5. Prices and discounts are Dynamics' responsibility, not CTS

Everything related to final prices and discounts is calculated and applied on the Microsoft Dynamics side. CTS only consumes the final price delivered by Dynamics. If a dealer reports that discounts are not being applied, the issue is in Dynamics — not in our code.

Confirmed by Mario Velasco: "Good morning Shamae, all related to price and discount is on Dynamics side."