[
https://issues.apache.org/jira/browse/OFBIZ-7482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16576014#comment-16576014 ]
Gil Portenseigne commented on OFBIZ-7482:
-----------------------------------------
Hello [~suraj.khurana],
I've no objections (not tested), but from a quick review i got just some remarks about the form :
{code:java}
GenericValue depositAmount = EntityQuery.use(delegator).from("ProductPrice").where(UtilMisc.toMap("productId", this.getProductId(),"productPricePurposeId", "DEPOSIT", "productPriceTypeId", "DEFAULT_PRICE")).cache(false).filterByDate(UtilDateTime.nowTimestamp(), "fromDate", "thruDate").queryFirst(); {code}
You can simplify it using public EntityQuery where(Object...fields) method, useCache is set to {{false}} by default, and you are using default date filter.
Resulting in :·
{code:java}
GenericValue depositAmount = EntityQuery.use(delegator).from("ProductPrice").where("productId", this.getProductId(),"productPricePurposeId", "DEPOSIT", "productPriceTypeId", "DEFAULT_PRICE").filterByDate().queryFirst(); {code}
When testing GenericValue presence, UtilValidate is not needed, using if (depositAmount != null) suffice.
I tend to avoid using Boolean if not needed (collection requirement), primitive boolean is enough and avoid possible NPE.
Thanks for your work :) !
> Deposit price support
> ----------------------
>
> Key: OFBIZ-7482
> URL:
https://issues.apache.org/jira/browse/OFBIZ-7482> Project: OFBiz
> Issue Type: New Feature
> Components: product
> Affects Versions: Trunk
> Reporter: Suraj Khurana
> Assignee: Suraj Khurana
> Priority: Major
> Attachments: OFBIZ-7482.patch
>
>
> Business requirements:
> In many business industry this is very common pattern that you need to pay some amount as deposit for particular products. Such as when you purchase wine or other bottle products, you need to pay some amount as deposit and whenever you return back that bottle, that deposited amount will be refunded to you.
> Technical Details:
> Create a new ProductPricePurpose as 'DEPOSIT' and for similar products we will create product price record with productPriceTypeId as 'DEFAULT_PRICE' and productPricePurposeId as 'DEPOSIT'. At the time of Order creation simply create order adjustments for such products.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)