details: https://code.openbravo.com/erp/devel/pi/rev/9a7e4cc7bd8f changeset: 29714:9a7e4cc7bd8f user: Sanjota <sanjota.nelagi <at> promantia.com> date: Fri Jun 24 02:49:55 2016 +0530 summary: Fixes issue 33301: Extra "Asset Amortization" record with total amount of 0
Extra "Asset Amortization" record with total amount of 0 when Asset defined as "Every Month Is 30 Day"= NO. In case it is defined with "Every Month Is 30 Day"= YES then no extra line is created details: https://code.openbravo.com/erp/devel/pi/rev/edafa9b0e0b0 changeset: 29715:edafa9b0e0b0 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Thu Jun 30 12:42:50 2016 +0200 summary: Related to issue 33301: Code review improvements diffstat: src/org/openbravo/erpCommon/ad_process/assets/AssetLinearDepreciationMethodProcess.java | 71 +++++---- 1 files changed, 38 insertions(+), 33 deletions(-) diffs (92 lines): diff -r 901f72e322e4 -r edafa9b0e0b0 src/org/openbravo/erpCommon/ad_process/assets/AssetLinearDepreciationMethodProcess.java --- a/src/org/openbravo/erpCommon/ad_process/assets/AssetLinearDepreciationMethodProcess.java Wed Jun 29 15:36:39 2016 +0000 +++ b/src/org/openbravo/erpCommon/ad_process/assets/AssetLinearDepreciationMethodProcess.java Thu Jun 30 12:42:50 2016 +0200 @@ -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) 2013-2014 Openbravo SLU + * All portions are Copyright (C) 2013-2016 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -448,42 +448,47 @@ proportionaldPercentage = HUNDRED.subtract(totalizedPercentage); } - log4j.debug(OBDateUtils.formatDate(calFirstDayOfPeriod.getTime()) + " to " - + OBDateUtils.formatDate(calLastDayOfPeriod.getTime()) + " " + proportionalAmount - + " " + proportionaldPercentage); + if (proportionalAmount.compareTo(BigDecimal.ZERO) != 0 + || proportionaldPercentage.compareTo(BigDecimal.ZERO) != 0) { - // Accumulate amount and percentage - totalizedAmount = totalizedAmount.add(proportionalAmount); - totalizedPercentage = totalizedPercentage.add(proportionaldPercentage); + log4j.debug(OBDateUtils.formatDate(calFirstDayOfPeriod.getTime()) + " to " + + OBDateUtils.formatDate(calLastDayOfPeriod.getTime()) + " " + proportionalAmount + + " " + proportionaldPercentage); - // Search for not processed amortization (calFirstDayOfPeriod - calLastDayOfPeriod) - Amortization amortization = getAmortization(asset.getOrganization(), null, - calLastDayOfPeriod.getTime(), asset.getProject()); - if (amortization == null) { - amortization = createNewAmortization(asset.getOrganization(), - OBDateUtils.formatDate(calLastDayOfPeriod.getTime()), null /* description */, - calFirstDayOfPeriod.getTime(), calLastDayOfPeriod.getTime(), asset.getCurrency(), + // Accumulate amount and percentage + totalizedAmount = totalizedAmount.add(proportionalAmount); + totalizedPercentage = totalizedPercentage.add(proportionaldPercentage); + + // Search for not processed amortization (calFirstDayOfPeriod - calLastDayOfPeriod) + Amortization amortization = getAmortization(asset.getOrganization(), null, + calLastDayOfPeriod.getTime(), asset.getProject()); + if (amortization == null) { + amortization = createNewAmortization(asset.getOrganization(), + OBDateUtils.formatDate(calLastDayOfPeriod.getTime()), null /* description */, + calFirstDayOfPeriod.getTime(), calLastDayOfPeriod.getTime(), asset.getCurrency(), + asset.getProject(), null /* campaign */, null /* activity */, null /* user1 */, + null /* user2 */); + } + + // Calculate asset sequence number. + // Asset 1 + // January lineno = 10, seqnoasset = 10 + // February lineno = 10, seqnoasset = 20 + if (seqNoAsset == null) { + seqNoAsset = getMaxSeqNoAsset(asset) + 10L; + } + + // Calculate amortization line number because the amortization can already exists. + Long lineNo = getMaxLineNo(amortization) + 10L; + + // Create the amortization line + amortizationLine = createNewAmortizationLine(amortization, lineNo, seqNoAsset, asset, + proportionaldPercentage, proportionalAmount, asset.getCurrency(), asset.getProject(), null /* campaign */, null /* activity */, null /* user1 */, - null /* user2 */); + null /* user2 */, null /* costcenter */); + + seqNoAsset += 10L; } - - // Calculate asset sequence number. - // Asset 1 - // January lineno = 10, seqnoasset = 10 - // February lineno = 10, seqnoasset = 20 - if (seqNoAsset == null) { - seqNoAsset = getMaxSeqNoAsset(asset) + 10L; - } - - // Calculate amortization line number because the amortization can already exists. - Long lineNo = getMaxLineNo(amortization) + 10L; - - // Create the amortization line - amortizationLine = createNewAmortizationLine(amortization, lineNo, seqNoAsset, asset, - proportionaldPercentage, proportionalAmount, asset.getCurrency(), asset.getProject(), - null /* campaign */, null /* activity */, null /* user1 */, null /* user2 */, null /* costcenter */); - - seqNoAsset += 10L; } // Initialize new range ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits