Repository navigation
v0.24.1: currency decimals
What's new
Generated amounts have their currency's decimals
A generated order in yen had cents, which the yen doesn't have:
{ "Material": "Safety Valve", "NetPrice": 254.87, "Currency": "JPY" }An amount now has the decimals of its currency: none in JPY, KRW or VND, three in KWD, BHD or OMR, two in the rest. The number is the one SAP shows for them, with its digits kept and the point moved, so a price in yen is a price in yen:
{ "Material": "Safety Valve", "NetPrice": 25487.00, "Currency": "JPY" }An order's total follows: 11468.21 JPY is now 1146821.00 JPY, the sum of its items' prices times their quantities.
- The currency of an amount is the property the metadata gives it (
sap:unit,Measures.ISOCurrency), or the row's only currency when the amount is named like one:NetPrice,TotalAmount,Cost. ScaleandPrecisionstill win. AScaleof 2 cuts a dinar's third decimal, and a number too long for thePrecisionkeeps its point and loses only the decimals.- An amount with a
Scaleof 3 in a two-decimal currency ends in0:12.340 EUR, not12.345 EUR. - An amount a mock rule sets keeps the rule's value. Quantities, keys and the rows of data files aren't touched.
The PurchaseOrderSrv example says which currency an amount is in
Its metadata.xml had amounts and a currency with nothing joining them, so a Fiori app generated from it showed 1146821.00 in one column and JPY in another. The amounts and the quantity now name their currency and unit, as an SAP Gateway service does:
<Property Name="Currency" Type="Edm.String" Nullable="false" MaxLength="3" sap:semantics="currency-code"/>
<Property Name="TotalAmount" Type="Edm.Decimal" Nullable="false" Precision="15" Scale="2" sap:unit="Currency"/>The generated V4 $metadata carries the same as Measures.ISOCurrency and Measures.Unit. The example's rows are the same as before.
Docs
- Keeping the data says what replicas are for: a shared test or demo environment that has to stay up, not load.
- The README links these release pages as the changelog.
Tested with the fiori-devstack apps on V2 and V4, on Docker Compose: 117,015 JPY beside 5,019.71 GBP in both list reports, and the apps' OPA tests, with the draft sample on PostgreSQL 18.6.
Upgrading
- Generated amounts in a currency without two decimals change, and so do the totals of their orders. A test that expects one of the old values needs the new one. Amounts in EUR, USD, GBP or CHF with a
Scaleof 2 are as they were. - A generated amount with a
Scaleof 3 or more now has two decimals in a two-decimal currency.
Install
npx odata-prova@0.24.1 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.24.1