This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository lima. See http://git.chorem.org/lima.git commit f78563f4d98f779075aaeb2428b540dc298c5102 Author: dcosse <japbiw74> Date: Fri Feb 13 16:39:11 2015 +0100 fixes #1162 be sure the fiscal periods or ordered by begin date --- .../lima/business/ejb/ImportServiceImpl.java | 12 +++++++- .../org/chorem/lima/entity/FiscalPeriodImpl.java | 35 ++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java index 9848089..fbdd513 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java @@ -24,6 +24,7 @@ package org.chorem.lima.business.ejb; import com.google.common.base.Function; import com.google.common.collect.Maps; +import com.google.common.collect.Ordering; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.chorem.lima.beans.EntryEBP; @@ -74,6 +75,7 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialStatement; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.FiscalPeriodImpl; import org.chorem.lima.entity.Identity; import org.chorem.lima.entity.VatStatement; import org.nuiton.csv.Import; @@ -213,6 +215,7 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ return results; } + @Override public ImportExportResults importFiscalPeriodsAsCSV(String contents) { ImportExportResults results = new ImportExportResults(); @@ -227,8 +230,9 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ Import<FiscalPeriod> fiscalPeriods = Import.newImport(model, contentStream); + List<FiscalPeriod> orderedFiscalPeriods = Ordering.from(FiscalPeriodImpl.BEGIN_DATE_COMPARATOR).sortedCopy(fiscalPeriods); try { - for (FiscalPeriod fiscalPeriod : fiscalPeriods) { + for (FiscalPeriod fiscalPeriod : orderedFiscalPeriods) { fiscalPeriodService.createFiscalPeriod(fiscalPeriod); result.increaseCreated(); } @@ -247,6 +251,12 @@ public class ImportServiceImpl extends AbstractLimaService implements ImportServ return results; } + /** + * + * @param contents financial transaction to import + * @param validAccountingRule True: Account rule validation is done otherwise it is not. (useful to restore backup) + * @return + */ protected ImportExportResults importFinancialTransactionsAsCSV(String contents, Boolean validAccountingRule) { ImportExportResults results = new ImportExportResults(); ImportResult result = results.createAddAndGetImportResult(FinancialTransaction.class); diff --git a/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodImpl.java b/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodImpl.java new file mode 100644 index 0000000..5b3e62a --- /dev/null +++ b/lima-callao/src/main/java/org/chorem/lima/entity/FiscalPeriodImpl.java @@ -0,0 +1,35 @@ +package org.chorem.lima.entity; + + +import java.util.Comparator; +import java.util.Date; + +/** + * Created by davidcosse on 13/02/15. + */ +public class FiscalPeriodImpl extends FiscalPeriodAbstract { + + private static final long serialVersionUID = 3487305853036673333L; + + public static final Comparator<FiscalPeriod> BEGIN_DATE_COMPARATOR = new BeginDateComparator(); + + private static class BeginDateComparator + implements Comparator<FiscalPeriod>, java.io.Serializable { + + private static final long serialVersionUID = 0L; + + public int compare(FiscalPeriod s1, FiscalPeriod s2) { + Date d1 = s1.getBeginDate(); + Date d2 = s2.getBeginDate(); + + int result = 0; + if (d1.after(d2)) { + result = 1; + } else if (d1.before(d2)){ + result = -1; + } + + return result; + } + } +} -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.