details: https://code.openbravo.com/erp/devel/main/rev/26e826aabf4e changeset: 25666:26e826aabf4e user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Wed Jan 07 16:02:36 2015 +0100 summary: Fixes issue 28537: Grid is loaded properly after scrolling it and sorting it
In this changeset [1] a change was done to prevent modifying improperly the totalRows property of the grid after scrolling. This code was meant to be executed after scrolling the grid, and to check it the lastScrollTop property and the getScrollTop() function of the grid body were compared. This check works properly when event that triggered the datasource request was the grid being filtered or a new page being fetched due to scrolling the grid. The problem was that the check did not work properly when the datasource request was triggered due to having sorted the grid. In this case, the totalRows property should be left as is. To fix this, a new flag is used to control when the datasource request has been triggered by a sorting event. [1] https://code.openbravo.com/erp/devel/pi/rev/c51dce7e9fd3 details: https://code.openbravo.com/erp/devel/main/rev/98f2b57e1abd changeset: 25667:98f2b57e1abd user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Jan 09 07:44:53 2015 +0100 summary: fixed bug 28541: date value in DateTime reference changes to current date When a DateTime reference column is hidden in grid, the date part was set to current date when navigating to form view. This was caused by an incorrect conversion to UTC where current date was set. details: https://code.openbravo.com/erp/devel/main/rev/64e85ddb0031 changeset: 25668:64e85ddb0031 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Jan 09 07:45:56 2015 +0100 summary: related to bug 28541: added test case details: https://code.openbravo.com/erp/devel/main/rev/c465b6e821fc changeset: 25669:c465b6e821fc user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Jan 09 07:48:24 2015 +0100 summary: related to bug 28541: added FICTest.class to AllWebserviceTests suite details: https://code.openbravo.com/erp/devel/main/rev/7b8b96447dc3 changeset: 25670:7b8b96447dc3 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Jan 09 10:46:48 2015 +0100 summary: fixed bug 28545: filters in HQL Query tables don't work in some cases Filters in HQL Query tables didn't work for columns having a different column name than its alias. This was caused because the reaplcement was not properly done because it didn't take into account the table alias. Table alias was added when fixing issue #28432 details: https://code.openbravo.com/erp/devel/main/rev/262bffb5558d changeset: 25671:262bffb5558d user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Mon Jan 12 13:02:24 2015 +0100 summary: related to bug 28545: added jUnit test case details: https://code.openbravo.com/erp/devel/main/rev/0a4d1b59faae changeset: 25672:0a4d1b59faae user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Wed Jan 07 10:18:24 2015 +0100 summary: Fixes bug 28519:OrganizationStructureProvider.initialize should be synchronized The method OrganizationStructureProvider.initialize should be synchronized, because otherwise it could be executed concurrently. The first thing the method does it to check if it the OrganizationStructureProvider has been already initialized, but this is not enough to prevent the concurrent initializations. One of the consequences of the concurrent initializations is that the three maps used in that method (naturalTreesByOrgID, parentByOrganizationID and childByOrganizationID) can be left in an inconsistent state, resulting in the a 100% CPU usage when trying to access them. details: https://code.openbravo.com/erp/devel/main/rev/56b2deb47198 changeset: 25673:56b2deb47198 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Dec 31 11:03:15 2014 +0100 summary: Fixes bug 28502: Inv Amt Update takes into account Costing Rule warehouse dim The problem was that the process was checking if the warehouse in Inventory Amount Update is null or not, and if not, it uses it. This is correct when the Costing Rule is set as Warehouse Dimension, but if is not, it should not use it, and even if the Costing Rule is not set as Warehouse Dimension and the warehouse field is hidden in Inventory Amount Lines, it is filled with the Warehouse set in session value. details: https://code.openbravo.com/erp/devel/main/rev/89ac014b635f changeset: 25674:89ac014b635f user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Dec 31 13:50:58 2014 +0100 summary: Fixes bug 28509: Inventory Amt Update now works with negative stock. In this case the Qty Count and Qty Book have been reverted in the Physical Inventory Lines and negate them to make them positive, maintaining the difference between them to create the same transaction quantity. Also getInventoryClosingCost function in AverageAlgorithm has been changed to negate the cost obtained from an inventory closing when the movement qty is positive (closing from negative to 0), because the cost obtained was negative, and this is wrong. details: https://code.openbravo.com/erp/devel/main/rev/bac119a18b86 changeset: 25675:bac119a18b86 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Dec 31 16:16:00 2014 +0100 summary: Fixes Bug 28487: Fixed Null Pointer Exception. The problem was that in updateBDCostingTimeRange function inside AverageCostAdjustment class, the code was trying to get the movement date of a Inventory Transaction related to a Costing record. But not all costing have Inventory Transaction, so it was giving a NPE. Now, if there is a previous Costing record than the one created due to a backdated transaction, this Costing will be shortened till transaction process date, and the new Backdated costing record will start at that moment. This only happens the first time that a related transaction is found that is not a backdated transaction, because if is done with a backdated transaction time overlap can happen. details: https://code.openbravo.com/erp/devel/main/rev/5d5f68403fb7 changeset: 25676:5d5f68403fb7 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Jan 07 19:31:01 2015 +0100 summary: Fixes bug 28531: Fix Backdated fails when backdated from is before starting date. A check has been added to be sure that fix backdated from date is not earlier than starting date of the costing rule. Also some code has been changed to handle correctly the error messages and return them properly to the user. Finally the reference of Fix Backdated From Parameter in Fix Backdated Transactions Process Definitio has been changed from Date to DateTime. details: https://code.openbravo.com/erp/devel/main/rev/26e29327d389 changeset: 25677:26e29327d389 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Thu Jan 08 12:30:31 2015 +0100 summary: Fixes Bug 28534: Fix Backdated From is now displayed properly. 'Fix Backdated From' now is only displayed when 'Backdated Transactions Fixed' is set to Yes. Also a callout has been added to clear the value in 'Fix Backdated From' when is hidden. details: https://code.openbravo.com/erp/devel/main/rev/2517423ec50b changeset: 25678:2517423ec50b user: Unai Martirena <unai.martirena <at> openbravo.com> date: Thu Jan 08 12:50:05 2015 +0100 summary: Related to Bug 28531: Fix backdated is not correctly set with big amount of data createCostingRuleInits method inside CostingRuleProcess.java cleares session every 100 records, and if this happens then the reference to current Costing Rule is missed, so the code that sets the fix backdated from is not properly done (rule.setFixbackdatedfrom(startingDate)). To avoid this the Fix Backdated From is set before creating Costing Rule Inventories. details: https://code.openbravo.com/erp/devel/main/rev/5ffc6e9cd5a8 changeset: 25679:5ffc6e9cd5a8 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Thu Jan 08 13:08:27 2015 +0100 summary: Related to issue 28534: Fix Copyright details: https://code.openbravo.com/erp/devel/main/rev/54ad451b0485 changeset: 25680:54ad451b0485 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Jan 14 09:39:32 2015 +0100 summary: Fixes bug 28554: No error is shown now in oracle creating LC from Goods receipt The problem was in 'SELECT PROCESSED INTO v_Processed FROM M_LandedCost WHERE M_landedcost_ID=v_M_LandedCost_ID' statement. If no result is given in the select, in postgres no value is inserted in v_Processed but it works, but in oracle it fails. To fix this an check has been added to execute this statement only when v_M_LandedCost_ID is not null. An if statement has been added in case v_M_LandedCost_ID is null and v_m_Inout_ID is not (Goods Receipt window), to prevent adding, updating or inserting Landed Cost Cost records when the Goods Receipt is processed. Finally, in case of updating, the restriction of not being able to change landed cost header has been removed. This was causing problems when launching Cost Background for a Goods Receipt with Landed Cost Cost records, because this process creates the Landed Cost Header and assigns to Landed Cost Cost records. details: https://code.openbravo.com/erp/devel/main/rev/bb4b71f58c54 changeset: 25681:bb4b71f58c54 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Tue Jan 13 09:58:54 2015 +0100 summary: fixed bug 28530: can't enter 2nd matched amount in Match LC Costs When trying to edit the 2nd line in Match LC Costs, UI didn't allow to enter then matched amount field. After this failure it was needed to reload the whole page in order make it work again. The problem was in this situation validation for amount fields is triggered for all selected records including the new one where the amount is '', it was tried to be converted to BigDecimal resulting on a JavaScript exception thrown. Fix check if the amount has a value (or 0) to only sum it in this case. details: https://code.openbravo.com/erp/devel/main/rev/d655a11691ef changeset: 25682:d655a11691ef user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Tue Jan 13 10:50:29 2015 +0100 summary: fixed bug 28565: not possible to filter by LineNo field in Match LC Cost The problem was caused by a reference mistmatch between lineNo property in HQL table, which was correctly Integer, and the reference for the M_LC_Cost.lineNo which was Number. Fixed M_LC_Cost.lineNo to be Integer. details: https://code.openbravo.com/erp/devel/main/rev/017fa1e0d009 changeset: 25683:017fa1e0d009 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Mon Jan 12 12:07:15 2015 +0100 summary: Fixes bug 28563: Filters in Match LC Costs P&E now are working This grid has been implemented using an hql query based table. The entity alias field was empty for all this columns, and it is necessary to correct implementation of the filtering, so the left part of the select has been added on all of them. details: https://code.openbravo.com/erp/devel/main/rev/da97e2f7803d changeset: 25684:da97e2f7803d user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Tue Jan 13 17:52:27 2015 +0100 summary: Related to issue 28531 Update Copyright details: https://code.openbravo.com/erp/devel/main/rev/5bd6da7f0dad changeset: 25685:5bd6da7f0dad user: Unai Martirena <unai.martirena <at> openbravo.com> date: Tue Jan 27 20:08:23 2015 +0100 summary: Fixes bug 28792: Null Pointer exception now is avoided in Costing Background The problem was in AverageCostAdjustment java process while calling AverageAlgorithm.getProductCost method. While returning null, Null Pointer Exception error was raised. details: https://code.openbravo.com/erp/devel/main/rev/af2f037123b1 changeset: 25686:af2f037123b1 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Tue Jan 27 20:10:56 2015 +0100 summary: Related to issue 28792: Uncomment a piece of code details: https://code.openbravo.com/erp/devel/main/rev/e1e71f3b0a4f changeset: 25687:e1e71f3b0a4f user: Unai Martirena <unai.martirena <at> openbravo.com> date: Thu Jan 29 19:04:28 2015 +0100 summary: Fixes bug 28814: NPE fixed in Costing Background for a production product When a product is defined as production the costing records created in the system are always for * organization. If a transaction of this product it was creating a backdated cost adjustment, in one place of the code a NPE exception error was happening because a costing record of legal entity org it was being trying to get. This has been fixed always filtering by client instead of organization when the product is of production type. details: https://code.openbravo.com/erp/devel/main/rev/207433b8ebba changeset: 25688:207433b8ebba user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Jan 09 15:18:45 2015 +0100 summary: fixed bug 28552: big numbers are changed in some cases Big numbers are modified in case their scientific notation represntation ends with zeros, trailing zeros were removed. So, ie., 3.5E10 was changed to 3.5E1 this is: 3.5. The problem was caused by fix for #26132 which tries to transform scientific to decimal notation (and then remove trailing zeros, which is correct). But it expected 3.5E+10 instead of 3.5E10, so in latter case, which is actually used it didn't do the transformation. The fix accepts scientific notation with both + and no +. details: https://code.openbravo.com/erp/devel/main/rev/56eb6b2608eb changeset: 25689:56eb6b2608eb user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Mon Jan 12 18:07:06 2015 +0100 summary: Fixed bug 28560 Cannot modify alternate taxableamt of invoice and order lines Backout of commit that caused the regression(27562) and fixed taxable amount for not stocked bom lines is not calculated in M_EXPLODEBOMNOTSTOCK and M_INVEXPLODEBOMNOTSTOCK procedures diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/costing/ob-lc-matchfrominvoice.js | 6 +- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js | 20 ++- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js | 6 +- modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/DateTimeUIDefinition.java | 14 +- modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java | 27 +++- src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml | 17 ++- src-db/database/model/functions/M_INVEXPLODEBOMNOTSTOCK.xml | 18 ++- src-db/database/model/triggers/C_INVLINE_CHK_RESTRICTIONS_TRG.xml | 14 +-- src-db/database/model/triggers/C_ORDERLINE_TRG.xml | 14 +-- src-db/database/model/triggers/M_LC_COST_CHK_TRG.xml | 15 +- src-db/database/sourcedata/AD_CALLOUT.xml | 10 + src-db/database/sourcedata/AD_COLUMN.xml | 13 +- src-db/database/sourcedata/AD_FIELD.xml | 1 + src-db/database/sourcedata/AD_MESSAGE.xml | 15 ++- src-db/database/sourcedata/AD_MODEL_OBJECT.xml | 12 + src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml | 10 + src-db/database/sourcedata/OBUIAPP_PARAMETER.xml | 2 +- src-test/src/org/openbravo/test/AllWebserviceTests.java | 10 +- src-test/src/org/openbravo/test/datasource/FICTest.java | 48 +++++++- src-test/src/org/openbravo/test/datasource/HQLDataSourceTest.java | 65 ++++++++++ src/org/openbravo/costing/AverageAlgorithm.java | 3 + src/org/openbravo/costing/AverageCostAdjustment.java | 59 +++++++- src/org/openbravo/costing/CostingRuleProcess.java | 4 +- src/org/openbravo/costing/FixBackdatedTransactionsProcess.java | 27 ++- src/org/openbravo/costing/InventoryAmountUpdateProcess.java | 8 +- src/org/openbravo/dal/security/OrganizationStructureProvider.java | 2 +- src/org/openbravo/erpCommon/ad_callouts/SL_CostingRule_FixBackdated.java | 39 ++++++ 27 files changed, 382 insertions(+), 97 deletions(-) diffs (truncated from 1207 to 300 lines): diff -r c28206c4abc9 -r 56eb6b2608eb modules/org.openbravo.client.application/web/org.openbravo.client.application/js/costing/ob-lc-matchfrominvoice.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/costing/ob-lc-matchfrominvoice.js Fri Jan 16 10:29:45 2015 +0000 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/costing/ob-lc-matchfrominvoice.js Mon Jan 12 18:07:06 2015 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2014 Openbravo SLU + * All portions are Copyright (C) 2014-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -34,7 +34,9 @@ // Check that matched amount is not higher than invoice line net amount for (i = 0; i < selectedRecordsLength; i++) { editedRecord = isc.addProperties({}, selectedRecords[i], item.grid.getEditedRecord(selectedRecords[i])); - matchedamt = matchedamt.add(new BigDecimal(String(editedRecord.matchedAmt))); + if (editedRecord.matchedAmt) { + matchedamt = matchedamt.add(new BigDecimal(String(editedRecord.matchedAmt))); + } } if (matchedamt.compareTo(invoiceamt) > 0) { item.grid.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, OB.I18N.getLabel('OBUIAPP_Costing_MachedMoreThanInvoice', [invoiceamt.toString()])); diff -r c28206c4abc9 -r 56eb6b2608eb modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js Fri Jan 16 10:29:45 2015 +0000 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js Mon Jan 12 18:07:06 2015 +0100 @@ -238,7 +238,8 @@ }, transformData: function (newData, dsResponse) { - var i, length, timeFields, responseToFilter, newTotalRows; + var i, length, timeFields, responseToFilter, responseToSort = false, + newTotalRows; // when the data is received from the datasource, time fields are formatted in UTC time. They have to be converted to local time if (dsResponse && dsResponse.context && (dsResponse.context.operationType === 'fetch' || dsResponse.context.operationType === 'update' || dsResponse.context.operationType === 'add')) { @@ -259,6 +260,10 @@ responseToFilter = true; } + if (dsResponse.context && dsResponse.context._dsRequest && dsResponse.context._dsRequest.params && dsResponse.context._dsRequest.params.isSorting) { + responseToSort = true; + } + if (this.localData && !responseToFilter) { length = this.localData.length; newTotalRows = dsResponse.totalRows; @@ -278,7 +283,8 @@ } // detects if the request was issued due to having scrolled up - if (this.grid.body.lastScrollTop !== undefined && this.grid.body.lastScrollTop > this.grid.body.getScrollTop()) { + // this does not apply when the grid has just been sorted, as the previous local data is discarded + if (!responseToSort && this.grid.body.lastScrollTop !== undefined && this.grid.body.lastScrollTop > this.grid.body.getScrollTop()) { // in that case, set the totalRows of the response to the length of the localData, to avoid // setting the totalRows of the grid to an invalid value dsResponse.totalRows = this.localData.length; @@ -2225,6 +2231,11 @@ params[OB.Constants.WHERE_PARAMETER] = null; } + if (this.isSorting) { + params.isSorting = true; + delete this.isSorting; + } + if (!isExporting) { first = true; selectedProperties = ''; @@ -4010,6 +4021,11 @@ me.view.updateSubtabVisibility(); }); } + }, + + setSort: function (sortSpecifiers, forceSort) { + this.isSorting = true; + this.Super('setSort', arguments); } }); diff -r c28206c4abc9 -r 56eb6b2608eb modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js Fri Jan 16 10:29:45 2015 +0000 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js Mon Jan 12 18:07:06 2015 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2011-2014 Openbravo SLU + * All portions are Copyright (C) 2011-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -450,8 +450,8 @@ } //Create the final number number = '0.' + zeros + coeficient; - } else if (exponent.indexOf('+') !== -1) { // Case the number is bigger than 1 - numberOfZeros = exponent.substring(1, exponent.length); + } else { // Case the number is bigger than 1 + numberOfZeros = exponent.indexOf('+') !== -1 ? exponent.substring(1, exponent.length) : exponent; if (split) { numberOfZeros = numberOfZeros - split[1].length; } diff -r c28206c4abc9 -r 56eb6b2608eb modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/DateTimeUIDefinition.java --- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/DateTimeUIDefinition.java Fri Jan 16 10:29:45 2015 +0000 +++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/DateTimeUIDefinition.java Mon Jan 12 18:07:06 2015 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2010-2014 Openbravo SLU + * All portions are Copyright (C) 2010-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -35,7 +35,6 @@ public class DateTimeUIDefinition extends DateUIDefinition { private String lastUsedPattern = null; private SimpleDateFormat dateFormat = null; - private static final SimpleDateFormat ficDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Override public String getParentType() { @@ -65,17 +64,14 @@ return convertedValue.toString(); } - private StringBuffer convertLocalDateTimeToUTC(Date UTCDate) { + private StringBuffer convertLocalDateTimeToUTC(Date date) { StringBuffer localTimeColumnValue = null; - Calendar now = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); - calendar.setTime(UTCDate); - calendar.set(Calendar.DATE, now.get(Calendar.DATE)); - calendar.set(Calendar.MONTH, now.get(Calendar.MONTH)); - calendar.set(Calendar.YEAR, now.get(Calendar.YEAR)); + calendar.setTime(date); - int gmtMillisecondOffset = (now.get(Calendar.ZONE_OFFSET) + now.get(Calendar.DST_OFFSET)); + int gmtMillisecondOffset = (calendar.get(Calendar.ZONE_OFFSET) + calendar + .get(Calendar.DST_OFFSET)); calendar.add(Calendar.MILLISECOND, -gmtMillisecondOffset); localTimeColumnValue = getClassicFormat().format(calendar.getTime(), new StringBuffer(), new FieldPosition(0)); diff -r c28206c4abc9 -r 56eb6b2608eb modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java --- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java Fri Jan 16 10:29:45 2015 +0000 +++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java Mon Jan 12 18:07:06 2015 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2014 Openbravo SLU + * All portions are Copyright (C) 2014-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -318,8 +318,12 @@ if (hqlQuery.indexOf(MAIN_FROM) != -1) { hqlQuery = hqlQuery.replace(MAIN_FROM, FROM); } + + log.debug("HQL query: {}", hqlQuery); Query query = OBDal.getInstance().getSession().createQuery(hqlQuery); + StringBuffer paramsLog = new StringBuffer(); + // sets the parameters of the query for (String key : queryNamedParameters.keySet()) { // Injection and transforms might have modified the query removing named parameters. Check @@ -331,9 +335,14 @@ } else { query.setParameter(key, parameter); } + if (log.isDebugEnabled()) { + paramsLog.append("\n").append(key).append(": ").append(parameter); + } } } + log.debug(" parameters:{}", paramsLog); + OBContext.restorePreviousMode(); return query; } @@ -494,18 +503,21 @@ // if the property is a primitive, just replace the property name with the column alias propertyNameBefore = property.getName(); propertyNameAfter = column.getEntityAlias(); - addEntryToReplacementMap(replacementMap, propertyNameBefore, propertyNameAfter); + addEntryToReplacementMap(replacementMap, propertyNameBefore, propertyNameAfter, + table.getEntityAlias()); } else { // the criteria can refer to the foreign key via its ID... propertyNameBefore = property.getName() + "." + JsonConstants.ID; propertyNameAfter = column.getEntityAlias() + "." + JsonConstants.ID; - addEntryToReplacementMap(replacementMap, propertyNameBefore, propertyNameAfter); + addEntryToReplacementMap(replacementMap, propertyNameBefore, propertyNameAfter, + table.getEntityAlias()); // ... or through its identifier Entity refEntity = property.getReferencedProperty().getEntity(); String identifierPropertyName = refEntity.getIdentifierProperties().get(0).getName(); propertyNameBefore = property.getName() + "." + identifierPropertyName; propertyNameAfter = column.getEntityAlias() + "." + identifierPropertyName; - addEntryToReplacementMap(replacementMap, propertyNameBefore, propertyNameAfter); + addEntryToReplacementMap(replacementMap, propertyNameBefore, propertyNameAfter, + table.getEntityAlias()); } for (String toBeReplaced : replacementMap.keySet()) { updatedWhereClause = updatedWhereClause.replaceAll(toBeReplaced, @@ -520,11 +532,16 @@ * added to the replacement map */ private void addEntryToReplacementMap(Map<String, String> replacementMap, String oldName, - String newName) { + String newName, String mainAlias) { replacementMap.put(" " + oldName + " ", " " + newName + " "); replacementMap.put("[(]" + oldName + "[)]", "(" + newName + ")"); replacementMap.put("[(]" + oldName + " ", "(" + newName + " "); replacementMap.put(" " + oldName + "[)]", " " + newName + ")"); + + if (StringUtils.isNotEmpty(mainAlias)) { + // if table has alias, add also replacements taking it into account + addEntryToReplacementMap(replacementMap, mainAlias + "." + oldName, newName, null); + } } /** diff -r c28206c4abc9 -r 56eb6b2608eb src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml --- a/src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml Fri Jan 16 10:29:45 2015 +0000 +++ b/src-db/database/model/functions/M_EXPLODEBOMNOTSTOCK.xml Mon Jan 12 18:07:06 2015 +0100 @@ -19,7 +19,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU -* All portions are Copyright (C) 2013-2014 Openbravo SLU +* All portions are Copyright (C) 2013-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************/ @@ -46,6 +46,8 @@ v_gross_price_list NUMBER; v_line_net_amt NUMBER; v_istaxincluded CHAR(1); + v_BaseAmount VARCHAR2(32); + v_orderline_ID VARCHAR2(32); BEGIN IF (p_PInstance_ID IS NOT NULL) THEN @@ -115,7 +117,7 @@ FROM M_PRODUCT p WHERE l.M_Product_ID=p.M_Product_ID AND p.IsBOM='Y' - AND p.IsStocked='N' + AND p.IsStocked='N' ) ORDER BY l.Line FOR UPDATE ) @@ -153,6 +155,7 @@ END IF; v_Line:=v_Line + 1; + v_orderline_ID:=get_uuid(); INSERT INTO C_ORDERLINE ( @@ -173,7 +176,7 @@ ) VALUES ( - get_uuid(), CUR_BOM_Line.AD_Client_ID, CUR_BOM_Line.AD_Org_ID, CUR_BOM_Line.IsActive, + v_orderline_ID, CUR_BOM_Line.AD_Client_ID, CUR_BOM_Line.AD_Org_ID, CUR_BOM_Line.IsActive, now(), '0', now(), '0', CUR_BOM_Line.C_Order_ID, v_Line, CUR_BOM_Line.C_BPartner_ID, CUR_BOM_Line.C_BPartner_Location_ID, CUR_BOM_Line.DateOrdered, CUR_BOM_Line.DatePromised, CUR_BOM_Line.DateDelivered, CUR_BOM_Line.DateInvoiced, @@ -189,6 +192,14 @@ CUR_BOM_Line.user1_id, CUR_BOM_Line.user2_id, v_Record_ID, v_gross_unit_price, v_gross_price_list, v_line_gross_amount ); + SELECT BASEAMOUNT + INTO v_BaseAmount + FROM C_TAX + WHERE C_TAX_ID = V_C_Tax_Id; + IF (v_BaseAmount='TBA' OR v_BaseAmount='TBATAX') THEN + UPDATE C_ORDERLINE SET Taxbaseamt= M_BOM_PriceStd(CUR_BOM.M_ProductBOM_ID, v_PriceList_Version_ID) where C_ORDERLINE_id=v_orderline_ID; + END IF; + END LOOP; -- Create New Lines END LOOP; -- Replace Lines UPDATE c_orderline set explode='Y' where c_orderline_id = v_Record_ID; diff -r c28206c4abc9 -r 56eb6b2608eb src-db/database/model/functions/M_INVEXPLODEBOMNOTSTOCK.xml --- a/src-db/database/model/functions/M_INVEXPLODEBOMNOTSTOCK.xml Fri Jan 16 10:29:45 2015 +0000 +++ b/src-db/database/model/functions/M_INVEXPLODEBOMNOTSTOCK.xml Mon Jan 12 18:07:06 2015 +0100 @@ -19,7 +19,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU -* All portions are Copyright (C) 2013 Openbravo SLU +* All portions are Copyright (C) 2013-2015 Openbravo SLU ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
