No UI option to mark a pipeline stage as Won or Lost, causing silent JavaScript crash

Author: dbadanielCreated Jun 9, 2026Updated Aug 4, 2026

Bug Report

Title

No UI option to mark a pipeline stage as Won or Lost, causing silent JavaScript crash

Issue Description

When creating or editing a pipeline, there is no option to mark a stage as "Won" or "Lost". The Ganho/Perdido button on the lead view requires stages with code = 'won' and code = 'lost' to exist in the pipeline, but there is no way to set this through the UI.

The only workaround is to create stages with the exact names won and lost, which causes the system to automatically assign the matching codes. However, this forces non-English stage names to break the feature, and there is no documentation or UI hint about this requirement.

When the user clicks the Won/Lost button without these stages configured, the application throws a silent JavaScript crash with no user-friendly error message.

Preconditions

  1. Krayin CRM version: 2.1.5 (image: webkul/krayin:2.1.5)
  2. Browser: Chrome 148
  3. A pipeline created through the UI with custom stage names (not named exactly won and lost)

Steps to Reproduce

  1. Create a new pipeline through Settings → Pipelines
  2. Add stages with custom names (e.g. "Cadastro", "Compra Concluída", "Ganho", "Perdido")
  3. Save the pipeline
  4. Open any lead that uses this pipeline
  5. Click the Won/Lost button in the top stage bar

Expected Result

  • The pipeline builder should have an explicit option to mark a stage as Won or Lost, independent of the stage name
  • Or at minimum, a clear error message should be shown when Won/Lost stages are missing
  • Users should not be required to name stages in English for the feature to work

Actual Result

The button crashes silently with a JavaScript error:

TypeError: Cannot read properties of undefined (reading 'code')
    at Proxy.openModal

This happens because this.stages.find(stage => stage.code == 'won') returns undefined when the stage name (and therefore its code) is not exactly won.

The only workaround is to create stages named exactly won and lost, which is not intuitive and forces English names on non-English pipelines.