Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value .00 is not a valid Decimal(5,2) when draftActive after upgrade to @cap-js/hana 1.3.1 #851

Open
LeoZhangSH opened this issue Oct 18, 2024 · 1 comment · May be fixed by #853
Open
Labels
bug Something isn't working

Comments

@LeoZhangSH
Copy link

Description of erroneous behaviour

we have an entity StudyTreatmentPeriods defined as below, with Decimal(5,2) data type.

entity Studies: {
    scenarios  : Composition of many db.StudyScenarios  on scenarios.study = $self;
}

entity StudyScenarios: {
    randomizationGroups  : db.RandomizationGroups on randomizationGroups.scenario = $self;
}
...

entity StudyTreatmentPeriods : cuid, managed {
...
    overage               : Decimal(5,2);
    dropout               : Decimal(5,2);
    noSwitchRate       : Decimal(5,2);
}

After we upgrade @cap-js/hana from 1.2.0 to 1.3.1, when we save study (draftActive), we got below error

image

[cds] - Error: Multiple errors occurred. Please see the details for more information.
    at ApplicationService.commonGenericInput (/Users/I530479/Desktop/Dev/gitcode/ctsm/ctsm-v8/node_modules/@sap/cds/libx/_runtime/common/generic/input.js:242:27)
    at ApplicationService.handle (/Users/I530479/Desktop/Dev/gitcode/ctsm/ctsm-v8/node_modules/@sap/cds/lib/srv/srv-dispatch.js:52:53)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ApplicationService.handle (/Users/I530479/Desktop/Dev/gitcode/ctsm/ctsm-v8/node_modules/@sap/cds/libx/_runtime/common/Service.js:84:16)
    at async cds.ApplicationService.handle (/Users/I530479/Desktop/Dev/gitcode/ctsm/ctsm-v8/node_modules/@sap/cds/libx/_runtime/fiori/lean-draft.js:588:20) {
  statusCode: 400,
  details: [
    {
      message: 'Value .000 is not a valid Decimal(15,3)',
      target: 'in/scenarios(ID=6c40da0d-3b8d-4127-9e2a-5a26d4ebc868,IsActiveEntity=false)/treatments(ID=ca5983fc-3328-4777-98c3-444ec1a8d067,IsActiveEntity=false)/kitTypeAssignments(ID=04d78411-6a43-4c07-9d60-d262c15f0372,IsActiveEntity=false)/kitQtyBasedOnBulk',
      args: [Array]
    },
    {
      message: 'Value .00 is not a valid Decimal(5,2)',
      target: 'in/scenarios(ID=6c40da0d-3b8d-4127-9e2a-5a26d4ebc868,IsActiveEntity=false)/randomizationGroups(ID=d1e2a55a-be24-4946-a1ab-6e1a396a254f,IsActiveEntity=false)/treatmentSchedule(ID=b1d38b35-fd46-42f9-bc9b-060945fae070,IsActiveEntity=false)/treatmentPeriods(ID=6834cc5a-b3cb-40bc-9074-771e3f55fa97,IsActiveEntity=false)/dropout',
      args: [Array]
    },
...

In the after read handler, the data was like below, but it works on @cap-js/hana 1.3.0, after we upgrade to 1.3.1, it failed.
image

Detailed steps to reproduce

For example (→ replace by appropriate ones for your case):

  1. git clone https://github.wdf.sap.corp/ctsm/ctsm

Details about your project

Remove the lines not applicable, and fill in versions for remaining ones:

Your Project Name https://github.wdf.sap.corp/ctsm/ctsm
Node.js v20.11.1
@sap/cds 8.2.2
@sap/cds-compiler 5.3.2
@sap/cds-dk 8.2.2
@sap/cds-dk (global) 7.1.0
@sap/eslint-plugin-cds 3.0.5
@sap/cds-mtxs 2.1.0

Run cds v -i in your project root to generate this

@LeoZhangSH LeoZhangSH added the bug Something isn't working label Oct 18, 2024
@johannes-vogel
Copy link
Contributor

Hi @LeoZhangSH,

thanks for reporting!

What's the value in the database for these fields?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants