Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0013273
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] 07. Sales managementmajoralways2010-05-10 09:312010-05-18 21:44
ReporterpsarobeView Statuspublic 
Assigned Todalsasua 
PriorityimmediateResolutionfixedFixed in Version
StatusclosedFix in branchpiFixed in SCM revision9db4acddd5a5
ProjectionnoneETAnoneTarget Version2.50MP17
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product Version2.50MP13SCM revision 
Review Assigned To
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0013273: Volume discount does not work

DescriptionThe volume discount is no longer working. The regression is due to the project "Line net amount"
Steps To Reproduce1. Login as Openbravo/openbravo
2. Go to Master data management->Business partner setup->Volume discount
3. Click new. Dates 01-01-2010 to 31-12-2010. Move to Products and select Donuts. 13%. Save
4. Move to the volume discount and for the product categories, select "Not selected". Save
5. Go to Mafalda business partner and move to volume discount tab. Select the newly volume discount
5. Go to Sales management->transactions->Sales invoice. Click new
6. Select mafalda. Save
7. Move to lines and select donuts (Sales price list, not mafalda price list). Qty=123. Save
8. Go back to header and complete
9. Go to business partner window. Select mafalda and move to the volume discount tab. Press the button create invoice

You will see the error
Proposed SolutionI have found the problem and technically what we did in the trigger is perfect. The problem comes with the procedure that creates the invoice.

The stored procedure that calculates the volume discount invoice is M_RAPPEL_INVOICE_CREATE. This procedure creates the invoice header and the line. When it creates the line, for the linenetamt:

1. It calculates first
2. Then it inserts directly the linenetmat
3. For the prices, it directly puts 0 because it doesn't matter. The same for the quantity. So finally we have qty=0 and price=0 but the linetamt is <>0. You can see the inser that the PL does. Let me say that that PL has not being change for along time. Please keep seeing my comments under the PL code

INSERT
      INTO C_INVOICELINE
        (
          C_INVOICELINE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE,
          CREATED, CREATEDBY, UPDATED, UPDATEDBY,
          C_INVOICE_ID, C_ORDERLINE_ID, M_INOUTLINE_ID, LINE,
          DESCRIPTION, M_PRODUCT_ID, QTYINVOICED, PRICELIST,
          PRICEACTUAL, PRICELIMIT, LINENETAMT, C_CHARGE_ID,
          CHARGEAMT, C_UOM_ID, C_TAX_ID, S_RESOURCEASSIGNMENT_ID,
          TAXAMT, M_ATTRIBUTESETINSTANCE_ID, ISDESCRIPTION,
          QUANTITYORDER, M_PRODUCT_UOM_ID, PRICESTD, M_OFFER_ID
        )
        VALUES
        (
          v_invoicelineId, CUR_INVOICE.AD_CLIENT_ID, CUR_INVOICE.AD_ORG_ID, 'Y',
          now(), v_AD_User_ID, now(), v_AD_User_ID,
          v_invoiceId, NULL, NULL, v_line,
          v_description, CUR_INVOICE.M_PRODUCT_ID, 0, 0,
          0, 0, CUR_INVOICE.LINENET, NULL,
          0, CUR_INVOICE.C_UOM_ID, CUR_INVOICE.C_TAX_ID, NULL,
          0, NULL, 'N',
          NULL, NULL, 0, NULL
        )
        ;


In the "Line net amount" project, the project allows you to edit the line net amount and because of this there is a call-out that modifies the price so finally the qty*price=linet amount. But in addition there is a trigger that ensures you that qty*price=line net amount. Please see the below trigger code

-- Rounds linenetAmt and ChargeAmt
  IF(INSERTING OR UPDATING) THEN
    SELECT STDPRECISION
    INTO v_Prec
    FROM C_CURRENCY
    WHERE C_CURRENCY_ID=v_Currency;
    :NEW.LineNetAmt:=ROUND(:NEW.LineNetAmt, v_Prec) ;
    :NEW.ChargeAmt:=ROUND(:NEW.ChargeAmt, v_Prec) ;

    IF (ROUND(TO_NUMBER(:NEW.QTYINVOICED) * TO_NUMBER(:NEW.PRICEACTUAL),v_Prec)!=TO_NUMBER(:NEW.LINENETAMT)) THEN
      RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
    END IF;
  END IF;
END C_INVLINE_CHK_RESTRICTIONS_TRG

So we could say that the trigger does what it has to do, but because the other procedure inserts the lines that way (qty=0 * price=0 <> line net amount) the error shows up.

So since now the problem is clear we have to make a decision. To me exists two approaches:

1. To avoid further problems in MP15 and in MP16 we should add a condition on the trigger code which is to add the condition of ISEDITLINENETAMT='Y'. Take into account that this procedures and other will create the invoice line with the value ISEDITLINENETAMT='N'. Doing this we will avoid further problems that could come from other procedures that create invoice lines in a "free" manner, I mean, without taking in account the formula qty*price=line net amt. For MP17 we should investigate the procedures that might not follow this formula and look for the best solution
2. Second approach: Investigate all the procedures that creates invoice lines.

So the solution would be:

IF (ROUND(TO_NUMBER(:NEW.QTYINVOICED) * TO_NUMBER(:NEW.PRICEACTUAL),v_Prec)!=TO_NUMBER(:NEW.LINENETAMT) AND :NEW.ISEDITLINENETAMT='Y')

I have already tested with that change and it works.
TagsRegression
Attached Files

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0027089)
hgbot (developer)
2010-05-10 10:13

Repository: erp/devel/pi
Changeset: 9db4acddd5a51b0498a2cb8b4fbde593edf07aff
Author: Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
Date: Mon May 10 10:14:48 2010 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/9db4acddd5a51b0498a2cb8b4fbde593edf07aff [^]

Fixed bug 13273: Volume discount does not work

---
M src-db/database/model/triggers/C_INVLINE_CHK_RESTRICTIONS_TRG.xml
---
(0027228)
sureshbabu (reporter)
2010-05-14 11:25

tested working fine
(0027507)
hudsonbot (developer)
2010-05-18 21:44

A changeset related to this issue has been promoted to main after passing a series of tests and an OBX has been generated:

Changeset: http://code.openbravo.com/erp/devel/main/rev/9db4acddd5a5 [^]
Merge Changeset: http://code.openbravo.com/erp/devel/main/rev/aa11838d5f80 [^]
Tests: http://builds.openbravo.com/view/devel-int/ [^]
OBX: http://builds.openbravo.com/erp/core/obx/OpenbravoERP-2.50CI.17380.obx [^]

- Issue History
Date Modified Username Field Change
2010-05-10 09:31 psarobe New Issue
2010-05-10 09:31 psarobe Assigned To => dalsasua
2010-05-10 09:32 psarobe Status new => scheduled
2010-05-10 09:32 psarobe fix_in_branch => pi
2010-05-10 10:12 psarobe Tag Attached: Regression
2010-05-10 10:13 hgbot Checkin
2010-05-10 10:13 hgbot Note Added: 0027089
2010-05-10 10:13 hgbot Status scheduled => resolved
2010-05-10 10:13 hgbot Resolution open => fixed
2010-05-10 10:13 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/9db4acddd5a51b0498a2cb8b4fbde593edf07aff [^]
2010-05-14 11:25 sureshbabu Note Added: 0027228
2010-05-14 11:25 sureshbabu Status resolved => closed
2010-05-15 00:00 anonymous sf_bug_id 0 => 3001863
2010-05-18 12:12 gorka_gil Target Version 2.50MP15 => 2.50MP17
2010-05-18 21:44 hudsonbot Checkin
2010-05-18 21:44 hudsonbot Note Added: 0027507


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker