You are on page 1of 1

AccountingReportManagementRepository.

java 12/26/2021 12:33 PM

1 /*
2 * Axelor Business Solutions
3 *
4 * Copyright (C) 2021 Axelor (<http://axelor.com>).
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License, version 3,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package com.axelor.apps.account.db.repo;
19
20 import com.axelor.apps.account.db.AccountingReport;
21 import com.axelor.apps.account.service.AccountingReportService;
22 import com.axelor.exception.service.TraceBackService;
23 import com.google.inject.Inject;
24 import java.math.BigDecimal;
25 import javax.persistence.PersistenceException;
26
27 public class AccountingReportManagementRepository extends AccountingReportRepository {
28
29 @Inject protected AccountingReportService accountingReportService;
30
31 @Override
32 public AccountingReport save(AccountingReport accountingReport) {
33 try {
34
35 if (accountingReport.getRef() == null) {
36
37 String seq = accountingReportService.getSequence(accountingReport);
38 accountingReportService.setSequence(accountingReport, seq);
39 }
40
41 return super.save(accountingReport);
42 } catch (Exception e) {
43 TraceBackService.traceExceptionFromSaveMethod(e);
44 throw new PersistenceException(e);
45 }
46 }
47
48 @Override
49 public AccountingReport copy(AccountingReport entity, boolean deep) {
50
51 AccountingReport copy = super.copy(entity, deep);
52
53 copy.setRef(null);
54 copy.setStatusSelect(this.STATUS_DRAFT);
55 copy.setPublicationDateTime(null);
56 copy.setTotalDebit(BigDecimal.ZERO);
57 copy.setTotalCredit(BigDecimal.ZERO);
58 copy.setBalance(BigDecimal.ZERO);
59
60 return copy;
61 }
62 }
63

Page 1 of 1

You might also like