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

ensure decimal is persisted by adding leading 0 if applicable #24

Merged
merged 10 commits into from
Dec 17, 2024
7 changes: 6 additions & 1 deletion data/Templates/eCR/Utils/_ValueHelper.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"valueBoolean" : {{ value.value }}
{% elsif value.value -%}
"valueQuantity": {
"value":{{ value.value | to_json_number }},
"value":
{% if value.value startswith "." %}
{{ "0" | append: value.value }},
{% else %}
{{ value.value }},
{% endif %}
{% if value.unit and value.unit != "null" -%}
"unit":"{{ value.unit }}",
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void GivenDecimalProperlyReturnsWithDecimal()
var attributes = new Dictionary<string, object>{
{"value", Hash.FromAnonymousObject(new { value = ".29"})}
};
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\":.29, },");
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\": 0.29, },");
}

[Fact]
Expand All @@ -32,7 +32,7 @@ public void GivenIntProperlyReturnsInt()
var attributes = new Dictionary<string, object>{
{"value", Hash.FromAnonymousObject(new { value = "300"})}
};
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\":300, },");
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\": 300, },");
}

[Fact]
Expand All @@ -41,7 +41,7 @@ public void GivenDecimalProperlyReturnsDecimal()
var attributes = new Dictionary<string, object>{
{"value", Hash.FromAnonymousObject(new { value = "300.00"})}
};
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\":300.00, },");
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\": 300.00, },");
}

[Fact]
Expand All @@ -50,7 +50,7 @@ public void GivenNegativeValueProperlyReturnsNegativeValue()
var attributes = new Dictionary<string, object>{
{"value", Hash.FromAnonymousObject(new { value = "-300.00"})}
};
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\":-300.00, },");
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\": -300.00, },");
}

[Fact]
Expand All @@ -59,7 +59,7 @@ public void GivenValueUnitProperlyReturnsWithValueUnit()
var attributes = new Dictionary<string, object>{
{"value", Hash.FromAnonymousObject(new { value = ".29" , unit = "/d"})}
};
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\":.29, \"unit\":\"/d\", },");
ConvertCheckLiquidTemplate(ECRPath, attributes, "\"valueQuantity\": { \"value\": 0.29, \"unit\":\"/d\", },");
}
}
}
Loading