You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Vikas Mayur <vi...@gmail.com> on 2014/06/03 11:08:09 UTC

OrderItemPriceInfo Entity Referential integrity

Hi Devs,

I’ve created a bad price rule action for a price rule and I can’t delete it because the price rule is already applied on some orders and ProductPriceAction is referenced by OrderItemPriceInfo through a foreign key. I just want to get rid of the bad price rule action, I think the easiest way would be to put a thru date on the existing price rule and create a new price rule with correct price rule action.

Of-course an update on the existing price rule action is still allowed as only productPriceRuleId & productPriceActionSeqId fields are referenced through foreign key by the OrderItemPriceInfo entity but if we update the action type to something else, lets say the action type was ‘Flat Amount Override’ and now you update it to ‘Percent of Default Price’ the existing referenced record in the OrderItemPriceInfo will still be obsolete (description, modify amount etc.), right?

I think we should just put foreign key reference on the productPriceRuleId field so that we can also delete any product price rule action.

Below is the snip from the OrderItemPriceInfo entity definition

{code}
      <relation type="one-nofk" rel-entity-name="ProductPriceRule">
        <key-map field-name="productPriceRuleId"/>
      </relation>
      <relation type="one" fk-name="ORDER_OIPI_PRAI" rel-entity-name="ProductPriceAction">
        <key-map field-name="productPriceRuleId"/>
        <key-map field-name="productPriceActionSeqId"/>
      </relation> 
{code}

and I think we should change this to

{code}
      <relation type="one"  fk-name=“ORDER_OIPI_PPR" rel-entity-name="ProductPriceRule">
        <key-map field-name="productPriceRuleId"/>
      </relation>d
      <relation type=“one-nofk" rel-entity-name="ProductPriceAction">
        <key-map field-name="productPriceRuleId"/>
        <key-map field-name="productPriceActionSeqId"/>
      </relation>
{code}


What do you think?

Regards
Vikas

Re: OrderItemPriceInfo Entity Referential integrity

Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Vikas,

If you use a Through Date then your only concern is keeping wrong info in OrderItemPriceInfo, right?

Jacques


Le 03/06/2014 11:08, Vikas Mayur a écrit :
> Hi Devs,
>
> I’ve created a bad price rule action for a price rule and I can’t delete it because the price rule is already applied on some orders and ProductPriceAction is referenced by OrderItemPriceInfo through a foreign key. I just want to get rid of the bad price rule action, I think the easiest way would be to put a thru date on the existing price rule and create a new price rule with correct price rule action.
>
> Of-course an update on the existing price rule action is still allowed as only productPriceRuleId & productPriceActionSeqId fields are referenced through foreign key by the OrderItemPriceInfo entity but if we update the action type to something else, lets say the action type was ‘Flat Amount Override’ and now you update it to ‘Percent of Default Price’ the existing referenced record in the OrderItemPriceInfo will still be obsolete (description, modify amount etc.), right?
>
> I think we should just put foreign key reference on the productPriceRuleId field so that we can also delete any product price rule action.
>
> Below is the snip from the OrderItemPriceInfo entity definition
>
> {code}
>        <relation type="one-nofk" rel-entity-name="ProductPriceRule">
>          <key-map field-name="productPriceRuleId"/>
>        </relation>
>        <relation type="one" fk-name="ORDER_OIPI_PRAI" rel-entity-name="ProductPriceAction">
>          <key-map field-name="productPriceRuleId"/>
>          <key-map field-name="productPriceActionSeqId"/>
>        </relation>
> {code}
>
> and I think we should change this to
>
> {code}
>        <relation type="one"  fk-name=“ORDER_OIPI_PPR" rel-entity-name="ProductPriceRule">
>          <key-map field-name="productPriceRuleId"/>
>        </relation>d
>        <relation type=“one-nofk" rel-entity-name="ProductPriceAction">
>          <key-map field-name="productPriceRuleId"/>
>          <key-map field-name="productPriceActionSeqId"/>
>        </relation>
> {code}
>
>
> What do you think?
>
> Regards
> Vikas
>