Skip to content
Permalink
Browse files

Implemented: Homogenize displaying number with multiple format

(OFBIZ-7532)

To display a number we had different possibilities :
 * on ftl use the template <@ofbizAmount and <@ofbizCurrency
 * by java call a function UtilFormatOut.formatAmount, UtilFormatOut.formatPrice, UtilFormatOut.formatQuantity, etc..
 * by form widget, use <display type=accounting-number for accounting but nothing for other

To simplify and homogenize all, I implemented a number type purpose :
   * default: display a number by default, use when no purpose is present
   * quantity: display a number as a quantity
   * amount: display a number as an amount (like price without currency)
   * spelled: litteral displaying for a number (use on <@ofbizAmount ftl only before)
   * percentage: display a number as a percentage
   * accounting: diplay a number for accounting specific

Each purpose can be associate to a number for displaying it :
   * on ftl <@ofbizNumber number=value format=purpose/>
   * on java UtilFormatOut.formatNumber(value, purpose, delegator, locale)
   * on form widget <display type=number format=purpose/>

The format use by a purpose is define on framework/common/config/number.properties with the template
    .displaying.format = ##0.00

With this, you can surchage a configuration, create your own purpose or surchage only one through entity SystemProperty.

Concerning the backware compatibility: 
 * For the ftl the template <@ofbizAmount is now a link to '<@ofbizNumber format=amount'
 * For java all previous function call UtilFormatOut.formatNumber with the matching purpose
 * For form xml accounting-number is managed as an exection

Last point, display a currency is different that a number, so I didn't refactoring some code for this case (only move properties from general to number for centralize de configuration on the same file)

Thanks Charles Steltzlen to start the refactoring

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1864832 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
nmalin committed Aug 9, 2019
1 parent b529900 commit 4a511be1cc3fa026027d1c9bf4a267d0017280af
@@ -49,6 +49,3 @@ finaccount.roundingSimpleMethod = HalfUp
salestax.calc.decimals = 3
salestax.final.decimals = 2
salestax.rounding = ROUND_HALF_UP

# the default accounting-number format for negatives in parentheses
accounting-number.format = #,##0.00;(#,##0.00)
@@ -175,7 +175,7 @@ under the License.
<td class="align-text" valign="top" nowrap="nowrap">
<#-- check for permission to modify price -->
<#if (allowPriceChange) && !("ITEM_CANCELLED" == orderItem.statusId || "ITEM_COMPLETED" == orderItem.statusId)>
<input type="text" size="8" name="ipm_${orderItem.orderItemSeqId}" value="<@ofbizAmount amount=orderItem.unitPrice/>"/>
<input type="text" size="8" name="ipm_${orderItem.orderItemSeqId}" value="<@ofbizNumber number=orderItem.unitPrice format="quantity"/>"/>
&nbsp;<input type="checkbox" name="opm_${orderItem.orderItemSeqId}" value="Y"/>
<#else>
<div><@ofbizCurrency amount=orderItem.unitPrice isoCode=currencyUomId/> / <@ofbizCurrency amount=orderItem.unitListPrice isoCode=currencyUomId/></div>
@@ -497,7 +497,7 @@ under the License.
</field>
<field name="requirementStartDate" title="${uiLabelMap.OrderRequirementStartDate}"><display/></field>
<field name="requiredByDate" title="${uiLabelMap.OrderRequirementByDate}"><display/></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display/></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display type="number" format="quantity"/></field>
</form>

<form name="LookupShoppingList" target="LookupShoppingList" title="" type="single"
@@ -189,11 +189,11 @@ under the License.
<field name="supplierProductId"><display/></field>
<field name="supplierProductName"><display/></field>
<field name="internalName"><display/></field>
<field name="lastPrice"><display/></field>
<field name="minimumOrderQuantity"><display/></field>
<field name="minimumStock"><display/></field>
<field name="lastPrice"><display type="number" format="amount"/></field>
<field name="minimumOrderQuantity"><display type="number" format="quantity"/></field>
<field name="minimumStock"><display type="number" format="quantity"/></field>
<field name="qohAtp" title="${uiLabelMap.ProductAtpQoh}"><display/></field>
<field name="quantityOnOrder"><display/></field>
<field name="quantityOnOrder"><display type="number" format="quantity"/></field>
<field name="quantity" title="${uiLabelMap.OrderQuantity}">
<text size="5" maxlength="10"/>
</field>
@@ -212,7 +212,7 @@ under the License.
</field>
<field name="workEffortId" title="${uiLabelMap.OrderOrderQuoteWorkEffortId}"></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"></field>
<field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"></field>
<field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"><display type="number" format="amount"/></field>
<field name="estimatedDeliveryDate" title="${uiLabelMap.OrderOrderQuoteEstimatedDeliveryDate}"></field>
<field name="productFeatureId"><hidden/></field>
<field name="skillTypeId"><hidden/></field>
@@ -267,8 +267,8 @@ under the License.
</drop-down>
</field>
<field name="workEffortId" title="${uiLabelMap.OrderOrderQuoteWorkEffortId}"></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"></field>
<field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display type="number" format="quantity"/></field>
<field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"><display type="number" format="amount"/></field>
<field name="estimatedDeliveryDate" title="${uiLabelMap.OrderOrderQuoteEstimatedDeliveryDate}"></field>
<field name="comments" title="${uiLabelMap.CommonComments}"></field>
<!--
@@ -358,11 +358,11 @@ under the License.
<field name="productId" title="${uiLabelMap.ProductProductId}">
<display-entity entity-name="Product" key-field-name="productId" description="${productId} - ${internalName}"/>
</field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display/></field>
<field name="averageCost" title="${uiLabelMap.OrderOrderQuoteAverageCost}"><display/></field>
<field name="costToPriceMult" title="${uiLabelMap.OrderOrderQuoteCostToPrice}"><display/></field>
<field name="defaultQuoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteDefaultUnitPrice}"><display/></field>
<field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"><display/></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display type="number" format="quantity"/></field>
<field name="averageCost" title="${uiLabelMap.OrderOrderQuoteAverageCost}"><display type="number" format="amount"/></field>
<field name="costToPriceMult" title="${uiLabelMap.OrderOrderQuoteCostToPrice}"><display type="number" format="amount"/></field>
<field name="defaultQuoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteDefaultUnitPrice}"><display type="number" format="amount"/></field>
<field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"><display type="number" format="amount"/></field>
<field name="manualQuoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteManualUnitPrice}"><text/></field>
<field name="_rowSubmit" title="${uiLabelMap.CommonSelected}"><check/></field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" use-when="quoteItemAndCostInfos!=[]" widget-style="smallSubmit"><submit/></field>
@@ -447,9 +447,9 @@ under the License.
<field name="productId" title="${uiLabelMap.ProductProductId}">
<display-entity entity-name="Product" key-field-name="productId" description="${productId} - ${internalName}"/>
</field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display/></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display type="number" format="quantity"/></field>
<field name="averageCost" title="${uiLabelMap.OrderOrderQuoteAverageCost}"><display/></field>
<field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"><display/></field>
<field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"><display type="number" format="amount"/></field>
<field name="profit" title="${uiLabelMap.OrderOrderQuoteProfit}"><display/></field>
<field name="percProfit" title="${uiLabelMap.OrderOrderQuotePercProfit}"><display/></field>
</form>
@@ -129,37 +129,37 @@ under the License.
<!-- list open order items -->
<form name="OpenOrderItemsList" type="list" list-name="orderItemList"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar" paginate-target="OpenOrderItemsReport">
<field name="orderDate" title="${uiLabelMap.OrderDate}"><display/></field>
<field name="orderDate" title="${uiLabelMap.OrderDate}"><display type="date-time"/></field>
<field name="orderId" title="${uiLabelMap.OrderOrderId}" widget-style="buttontext">
<hyperlink description="${orderId}" target="orderview">
<parameter param-name="orderId"/>
</hyperlink>
</field>
<field name="productId" title="${uiLabelMap.ProductProduct}"><display/></field>
<field name="itemDescription" title="${uiLabelMap.CommonDescription}"><display/></field>
<field name="quantityOrdered" title="${uiLabelMap.ProductQuantity}"><display/></field>
<field name="quantityIssued" title="${uiLabelMap.OrderQtyShipped}"><display/></field>
<field name="quantityOpen" title="${uiLabelMap.ProductOpenQuantity}"><display/></field>
<field name="shipAfterDate" title="${uiLabelMap.OrderShipAfterDate}"><display/></field>
<field name="shipBeforeDate" title="${uiLabelMap.OrderShipBeforeDate}"><display/></field>
<field name="quantityOrdered" title="${uiLabelMap.ProductQuantity}"><display type="number" format="quantity"/></field>
<field name="quantityIssued" title="${uiLabelMap.OrderQtyShipped}"><display type="number" format="quantity"/></field>
<field name="quantityOpen" title="${uiLabelMap.ProductOpenQuantity}"><display type="number" format="quantity"/></field>
<field name="shipAfterDate" title="${uiLabelMap.OrderShipAfterDate}"><display type="date-time"/></field>
<field name="shipBeforeDate" title="${uiLabelMap.OrderShipBeforeDate}"><display type="date-time"/></field>
<field name="comments" title="${uiLabelMap.CommonComments}"><display/></field>
<field name="costPrice" title="${uiLabelMap.ProductCostPrice}"><display/></field>
<field name="listPrice" title="${uiLabelMap.ProductListPrice}"><display/></field>
<field name="retailPrice" title="${uiLabelMap.ProductRetailPrice}"><display/></field>
<field name="discount" title="${uiLabelMap.ProductDiscount}"><display/></field>
<field name="costPrice" title="${uiLabelMap.ProductCostPrice}"><display type="number" format="amount"/></field>
<field name="listPrice" title="${uiLabelMap.ProductListPrice}"><display type="number" format="amount"/></field>
<field name="retailPrice" title="${uiLabelMap.ProductRetailPrice}"><display type="number" format="amount"/></field>
<field name="discount" title="${uiLabelMap.ProductDiscount}"><display type="number" format="amount"/></field>
<field name="calculatedMarkup" title="${uiLabelMap.OrderCalculatedMarkup}"><display/></field>
<field name="percentMarkup" title="${uiLabelMap.OrderPercentageMarkup}"><display/></field>
</form>

<form name="OpenOrderItemsTotal" type="list" list-name="totalAmountList"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<field name="total" title="${uiLabelMap.CommonTotal}"><display/></field>
<field name="totalQuantityOrdered"><display/></field>
<field name="totalQuantityOpen"><display/></field>
<field name="totalCostPrice"><display/></field>
<field name="totalListPrice"><display/></field>
<field name="totalRetailPrice"><display/></field>
<field name="totalDiscount"><display/></field>
<field name="total" title="${uiLabelMap.CommonTotal}"><display type="number" format="quantity"/></field>
<field name="totalQuantityOrdered"><display type="number" format="quantity"/></field>
<field name="totalQuantityOpen"><display type="number" format="quantity"/></field>
<field name="totalCostPrice"><display type="number" format="amount"/></field>
<field name="totalListPrice"><display type="number" format="amount"/></field>
<field name="totalRetailPrice"><display type="number" format="amount"/></field>
<field name="totalDiscount"><display type="number" format="amount"/></field>
<field name="totalMarkup"><display/></field>
<field name="totalPercentMarkup"><display/></field>
</form>
@@ -91,9 +91,9 @@ under the License.
</field>
<field name="requirementStartDate"><display/></field>
<field name="requiredByDate"><display/></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display/></field>
<field name="facilityQuantityOnHandTotal"><display/></field>
<field name="quantityOnHandTotal"><display/></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display type="number" format="quantity"/></field>
<field name="facilityQuantityOnHandTotal"><display type="number" format="quantity"/></field>
<field name="quantityOnHandTotal"><display type="number" format="quantity"/></field>
<field name="requestsLink" widget-style="buttontext">
<hyperlink description="${uiLabelMap.OrderRequests}" target="ListRequirementCustRequests">
<parameter param-name="requirementId"/>
@@ -249,7 +249,7 @@ under the License.
</field>
<field name="requirementStartDate"><display/></field>
<field name="requiredByDate"><display/></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display/></field>
<field name="quantity" title="${uiLabelMap.CommonQuantity}"><display type="number" format="quantity"/></field>
<field name="_rowSubmit" title="${uiLabelMap.CommonSelect}"><check/></field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit">
<submit/>
@@ -322,10 +322,10 @@ under the License.
<hyperlink description="${supplierProductId}" target="/catalog/control/EditProductSuppliers?productId=${productId}" target-type="inter-app"/>
</field>
<field name="idValue" title="${uiLabelMap.ProductUPCA}"><display/></field>
<field name="minimumOrderQuantity" widget-area-style="align-text"><display/></field>
<field name="minimumOrderQuantity" widget-area-style="align-text"><display type="number" format="quantity"/></field>
<field name="lastPrice" widget-area-style="align-text"><display type="currency" currency="${currencyUomId}"/></field>
<field name="requiredByDate"><display/></field>
<field name="quantity" widget-area-style="align-text"><display/></field>
<field name="quantity" widget-area-style="align-text"><display type="number" format="quantity"/></field>
<field name="comments"><display/></field>
</form>
<form name="ApprovedProductRequirements" type="multi" use-row-submit="true" target="quickPurchaseOrderEntry" title="" list-name="requirementsForSupplier"
@@ -353,7 +353,7 @@ under the License.
<field name="supplierCurrencyUomId" entry-name="parameters.supplierCurrencyUomId"><display/></field>
<field name="supplierProductId" title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
<field name="idValue" title="${uiLabelMap.ProductUPCA}"><display/></field>
<field name="minimumOrderQuantity" title="${uiLabelMap.FormFieldTitle_minimumOrderQuantity}" widget-area-style="align-text"><display/></field>
<field name="minimumOrderQuantity" title="${uiLabelMap.FormFieldTitle_minimumOrderQuantity}" widget-area-style="align-text"><display type="number" format="quantity"/></field>
<field name="lastPrice" widget-area-style="align-text"><display type="currency" currency="${currencyUomId}"/></field>
<field name="requiredByDate"><display/></field>
<field name="atp" title="${uiLabelMap.ProductAtp}" widget-area-style="align-text"><display/></field>
@@ -373,7 +373,7 @@ under the License.
<form name="ApprovedProductRequirementsSummary" type="single" default-map-name="quantityReport" target="ApprovedProductRequirements"
header-row-style="header-row" default-table-style="basic-table">
<field name="distinctProductCount" title="${uiLabelMap.OrderRequirementNumberOfProducts}"><display/></field>
<field name="quantityTotal"><display/></field>
<field name="quantityTotal"><display type="number" format="quantity"/></field>
<field name="amountTotal"><display type="currency" currency="${currencyUomId}"/></field>
</form>
<form name="ApprovedProductRequirementsByVendor" type="list" use-row-submit="true" list-name="requirements" target="ApprovedProductRequirements" separate-columns="true"

0 comments on commit 4a511be

Please sign in to comment.
You can’t perform that action at this time.