diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a2a70be --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,49 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Test", + "request": "launch", + "mainClass": "com.axelor.apps.account.service.Test", + "projectName": "axelor-account" + }, + { + "type": "java", + "name": "Previous", + "request": "launch", + "mainClass": "com.axelor.apps.production.service.Previous", + "projectName": "axelor-production" + }, + { + "type": "java", + "name": "AccountingCutOffServiceImpl", + "request": "launch", + "mainClass": "com.axelor.apps.supplychain.service.AccountingCutOffServiceImpl", + "projectName": "axelor-supplychain" + }, + { + "type": "java", + "name": "Test", + "request": "launch", + "mainClass": "com.axelor.apps.stock.service.Test", + "projectName": "axelor-stock" + }, + { + "type": "java", + "name": "Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "QAPortType_QAPortType_Client", + "request": "launch", + "mainClass": "com.qas.web_2005_02.QAPortType_QAPortType_Client", + "projectName": "axelor-tool" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..df76fc4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "java.compile.nullAnalysis.mode": "automatic", + "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx8G -Xms100m -Xlog:disable", + "java.debug.settings.onBuildFailureProceed": true +} \ No newline at end of file diff --git a/PyWhatKit_DB.txt b/PyWhatKit_DB.txt new file mode 100644 index 0000000..429ed72 --- /dev/null +++ b/PyWhatKit_DB.txt @@ -0,0 +1,180 @@ +Date: 21/6/2024 +Time: 19:13 +Phone Number: +213554130569 +Message: hello +-------------------- +Date: 22/6/2024 +Time: 21:33 +Phone Number: +213554130569 +Message: hello +-------------------- +Date: 22/6/2024 +Time: 21:36 +Phone Number: +213542291107 +Message: hello +-------------------- +Date: 7/7/2024 +Time: 0:8 +Phone Number: +213541229487 +Message: TEST MESSAGE +-------------------- +Date: 7/7/2024 +Time: 0:10 +Phone Number: +213541229487 +Message: TEST MESSAGE +-------------------- +Date: 7/7/2024 +Time: 0:16 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté +-------------------- +Date: 7/7/2024 +Time: 0:19 +Phone Number: +213541229487 +Message: Votre TCO a ete acceptéhttp://localhost:8080/axelor-erp/#/ds/action-meta-actions/edit/3815 +-------------------- +Date: 7/7/2024 +Time: 0:20 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté http://localhost:8080/axelor-erp/#/ds/action-meta-actions/edit/3815 +-------------------- +Date: 7/7/2024 +Time: 0:21 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté http://localhost:8080/axelor-erp/#/ds/action-meta-actions/edit/3815 +-------------------- +Date: 7/7/2024 +Time: 0:25 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté http://localhost:8080/axelor-erp/#/ds/action-meta-actions/edit/23400 +-------------------- +Date: 7/7/2024 +Time: 11:53 +Phone Number: +213541229487 +Message: hello https://dsi.sophal.dz//front/drh.MonDossierRH.php +-------------------- +Date: 7/7/2024 +Time: 11:54 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté http://localhost:8080/axelor-erp/#/ds/action-meta-actions/edit/22874 +-------------------- +Date: 7/7/2024 +Time: 11:56 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/22874 +-------------------- +Date: 7/7/2024 +Time: 12:0 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/22873 +-------------------- +Date: 7/7/2024 +Time: 12:1 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/21515 +-------------------- +Date: 7/7/2024 +Time: 12:1 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/21515 +-------------------- +Date: 7/7/2024 +Time: 12:1 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/21515 +-------------------- +Date: 7/7/2024 +Time: 12:1 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/20428 +-------------------- +Date: 7/7/2024 +Time: 12:2 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/21515 +-------------------- +Date: 7/7/2024 +Time: 12:2 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/21514 +-------------------- +Date: 7/7/2024 +Time: 13:27 +Phone Number: +213541229487 +Message: 40 +-------------------- +Date: 7/7/2024 +Time: 13:31 +Phone Number: +213541229487 +Message: 52 +-------------------- +Date: 8/7/2024 +Time: 13:12 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/22026 sc.root.purchase.orders.supplier.lines.requests/edit 22026 +-------------------- +Date: 8/7/2024 +Time: 13:13 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/22027 sc.root.purchase.orders.supplier.lines.requests/edit 22027 +-------------------- +Date: 8/7/2024 +Time: 13:23 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/22026 sc.root.purchase.orders.supplier.lines.requests/edit 22026 +-------------------- +Date: 8/7/2024 +Time: 13:26 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/22024 sc.root.purchase.orders.supplier.lines.requests/edit 22024 +-------------------- +Date: 8/7/2024 +Time: 13:31 +Phone Number: +213541229487 +Message: Votre TCO a ete accepté https://erp.sophal.net/sophal/#/ds/action-meta-actions/edit/23777 23777 +-------------------- +Date: 28/7/2024 +Time: 11:30 +Phone Number: +213541229487 +Message: TEST MESSAGE sc.root.purchase.quotations/edit 22877 +-------------------- +Date: 28/7/2024 +Time: 11:33 +Phone Number: +213541229487 +Message: TEST MESSAGE sc.root.purchase.quotations/edit 22878 +-------------------- +Date: 5/10/2024 +Time: 22:53 +Phone Number: +213541229487 +Message: msg 123 +-------------------- +Date: 5/10/2024 +Time: 23:5 +Phone Number: +213541229487 +Message: TCO ACCEPTER sc.root.purchase.orders.supplier.lines.requests/edit 25759 +-------------------- +Date: 5/10/2024 +Time: 23:15 +Phone Number: +213541229487 +Message: TCO ACCEPTER http://localhost:8080/axelor-erp/#/ds/sc.root.purchase.orders.supplier.lines.requests/edit 25759 +-------------------- +Date: 5/10/2024 +Time: 23:23 +Phone Number: +213541229487 +Message: TCO ACCEPTER [go to](http://localhost:8080/axelor-erp/#/ds/sc.root.purchase.orders.supplier.lines.requests/edit) 25759 +-------------------- +Date: 5/10/2024 +Time: 23:25 +Phone Number: +213541229487 +Message: TCO ACCEPTER [go to](https://erp.sophal.net/#/ds/sc.root.purchase.orders.supplier.lines.requests/edit) 25759 +-------------------- +Date: 5/10/2024 +Time: 23:27 +Phone Number: +213541229487 +Message: TCO ACCEPTER https://erp.sophal.net/#/ds/sc.root.purchase.orders.supplier.lines.requests/edit25759 25759 +-------------------- +Date: 5/10/2024 +Time: 23:27 +Phone Number: +213541229487 +Message: TCO ACCEPTER https://erp.sophal.net/#/ds/sc.root.purchase.orders.supplier.lines.requests/edit/25759 25759 +-------------------- diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/db/repo/PaymentVoucherManagementRepository.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/db/repo/PaymentVoucherManagementRepository.java index 56c6d7e..d00f03a 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/db/repo/PaymentVoucherManagementRepository.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/db/repo/PaymentVoucherManagementRepository.java @@ -29,20 +29,24 @@ public class PaymentVoucherManagementRepository extends PaymentVoucherRepository @Override public PaymentVoucher copy(PaymentVoucher entity, boolean deep) { + /** + * copy set are commented because there is a lot of vouchers that contains the same element to pay but partially + */ + PaymentVoucher copy = super.copy(entity, deep); copy.setStatusSelect(STATUS_DRAFT); copy.setRef(null); copy.setPaymentDate(Beans.get(AppBaseService.class).getTodayDate()); - copy.clearPayVoucherDueElementList(); - copy.clearPayVoucherElementToPayList(); + // copy.clearPayVoucherDueElementList(); + // copy.clearPayVoucherElementToPayList(); copy.setGeneratedMove(null); copy.setBankCardTransactionNumber(null); copy.clearBatchSet(); copy.setImportId(null); copy.setReceiptNo(null); - copy.setRemainingAmount(null); - copy.setRemainingAllocatedAmount(null); + // copy.setRemainingAmount(null); + // copy.setRemainingAllocatedAmount(null); copy.setToSaveEmailOk(false); copy.setDefaultEmailOk(false); copy.setEmail(null); diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/report/IReport.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/report/IReport.java index 103c14f..023bd07 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/report/IReport.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/report/IReport.java @@ -29,4 +29,5 @@ public interface IReport { public static final String SUBROGATION_RELEASE = "SubrogationRelease.rptdesign"; public static final String CHEQUE_DEPOSIT_SLIP = "ChequeDepositSlip.rptdesign"; public static final String CASH_DEPOSIT_SLIP = "CashDepositSlip.rptdesign"; + public static final String CASH_INVENTORY = "CashInventory%s.rptdesign"; } diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/AccountingSituationServiceImpl.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/AccountingSituationServiceImpl.java index f8f5538..e80a56d 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/AccountingSituationServiceImpl.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/AccountingSituationServiceImpl.java @@ -19,17 +19,23 @@ package com.axelor.apps.account.service; import com.axelor.apps.account.db.Account; import com.axelor.apps.account.db.AccountConfig; +import com.axelor.apps.account.db.AccountType; import com.axelor.apps.account.db.AccountingSituation; import com.axelor.apps.account.db.PaymentMode; import com.axelor.apps.account.db.repo.AccountConfigRepository; +import com.axelor.apps.account.db.repo.AccountRepository; +import com.axelor.apps.account.db.repo.AccountTypeRepository; import com.axelor.apps.account.db.repo.AccountingSituationRepository; import com.axelor.apps.account.exception.IExceptionMessage; +import com.axelor.apps.account.service.app.AppAccountService; import com.axelor.apps.account.service.config.AccountConfigService; import com.axelor.apps.account.service.payment.PaymentModeService; +import com.axelor.apps.base.db.AppAccount; import com.axelor.apps.base.db.BankDetails; import com.axelor.apps.base.db.Company; import com.axelor.apps.base.db.Partner; import com.axelor.apps.base.db.Sequence; +import com.axelor.apps.base.db.repo.AppAccountRepository; import com.axelor.apps.base.service.administration.SequenceService; import com.axelor.apps.tool.StringTool; import com.axelor.common.StringUtils; @@ -120,14 +126,54 @@ public class AccountingSituationServiceImpl implements AccountingSituationServic } } + Account acc = this.createPartnerAccount(partner, company); AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(company); accountingSituation.setInvoiceAutomaticMail(accountConfig.getInvoiceAutomaticMail()); accountingSituation.setInvoiceMessageTemplate(accountConfig.getInvoiceMessageTemplate()); + if (acc != null) { + if (partner.getIsCustomer()) { + accountingSituation.setCustomerAccount(acc); + } else if (partner.getIsSupplier()) { + accountingSituation.setSupplierAccount(acc); + } + } + partner.addAccountingSituationListItem(accountingSituation); return accountingSituationRepo.save(accountingSituation); } + // sophal creating account + @Transactional + private Account createPartnerAccount(Partner partner, Company company) { + Account sAccount = new Account(); + AppAccount appAccount = Beans.get(AppAccountService.class).getAppAccount(); + int partnerCode = appAccount.getSupplierCodeSequence() + 1; + appAccount.setSupplierCodeSequence(partnerCode); + + String accounString = "Fournisseurs"; + if (partner.getIsCustomer()) { + accounString = "Clients"; + partnerCode = appAccount.getClientCodeSequence() + 1; + appAccount.setClientCodeSequence(partnerCode); + } + + AccountType accountType = Beans.get(AccountTypeRepository.class).findByName(accounString); + Account parenAccount = Beans.get(AccountRepository.class).findByCode("0"); + + sAccount.setAccountType(accountType); + sAccount.setCode(String.valueOf(partnerCode)); + sAccount.setName(partner.getName()); + sAccount.setReconcileOk(true); + sAccount.setUseForPartnerBalance(true); + sAccount.setCompany(company); + sAccount.setParentAccount(parenAccount); + + Beans.get(AppAccountRepository.class).save(appAccount); + + return sAccount; + } + @Override public AccountingSituation getAccountingSituation(Partner partner, Company company) { if (partner == null || partner.getAccountingSituationList() == null) { diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/CashInventoryService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/CashInventoryService.java new file mode 100644 index 0000000..8359207 --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/CashInventoryService.java @@ -0,0 +1,81 @@ +package com.axelor.apps.account.service; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.axelor.apps.account.db.CashDenomination; +import com.axelor.apps.account.db.CashInventory; +import com.axelor.apps.account.db.CashInventoryLine; +import com.axelor.apps.account.db.repo.CashDenominationRepository; +import com.axelor.apps.account.db.repo.CashInventoryRepository; +import com.axelor.inject.Beans; +import com.google.inject.persist.Transactional; + +public class CashInventoryService { + + @Transactional + public void initThetoricalSoldeInWords(CashInventory cashInventory) { + CashInventoryRepository cashInventoryRepository = Beans.get(CashInventoryRepository.class); + CashInventory lastCashInventory = cashInventoryRepository.all().order("-createdOn").fetchOne(); + BigDecimal theoricalSolde = BigDecimal.ZERO; + if(lastCashInventory == null){ + theoricalSolde = BigDecimal.ZERO; + }else{ + theoricalSolde = lastCashInventory.getTheoricalSolde(); + } + cashInventory.setTheoricalSolde(theoricalSolde); + cashInventory.setRealDate(LocalDateTime.now()); + cashInventoryRepository.save(cashInventory); + } + + + public Map computeToTals(CashInventory cashInventory){ + + HashMap map = new HashMap<>(); + + List cashInventoryLines = cashInventory.getCashInventoryLines(); + + BigDecimal theoricalSolde = cashInventory.getTheoricalSolde(); + + BigDecimal totalBankNotes = BigDecimal.ZERO; + BigDecimal totalCoins = BigDecimal.ZERO; + BigDecimal physicalSolde = BigDecimal.ZERO; + BigDecimal gap = BigDecimal.ZERO; + + for (CashInventoryLine cashInventoryLine : cashInventoryLines) { + switch (cashInventoryLine.getCashDenomination().getTypeSelect()) { + case CashDenominationRepository.BANK_NOTE_TYPE: + totalBankNotes = totalBankNotes.add(cashInventoryLine.getTotalCashCount()); + break; + case CashDenominationRepository.COINT_TYPE: + totalCoins = totalCoins.add(cashInventoryLine.getTotalCashCount()); + break; + + default: + totalBankNotes = BigDecimal.ZERO; + totalCoins = BigDecimal.ZERO; + break; + } + } + + physicalSolde = physicalSolde.add(totalBankNotes).add(totalCoins); + gap = physicalSolde.subtract(theoricalSolde); + + map.put("totalCoinsAmount", totalCoins); + map.put("totalBankNotesAmount", totalBankNotes); + map.put("totalCash", totalBankNotes); + map.put("physicalSolde", physicalSolde); + map.put("gap", gap); + + return map; + + } + + + +} + diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/InvoiceTemplateService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/InvoiceTemplateService.java new file mode 100644 index 0000000..a485e51 --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/InvoiceTemplateService.java @@ -0,0 +1,123 @@ +package com.axelor.apps.account.service; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import org.apache.http.annotation.Contract; + +import com.axelor.apps.account.db.Invoice; +import com.axelor.apps.account.db.InvoiceLine; +import com.axelor.apps.account.db.InvoiceTemplate; +import com.axelor.apps.account.db.InvoiceTemplateLine; +import com.axelor.apps.account.db.repo.InvoiceRepository; +import com.axelor.apps.account.service.invoice.generator.InvoiceGenerator; +import com.axelor.apps.account.service.invoice.generator.InvoiceLineGenerator; +import com.axelor.apps.base.db.Company; +import com.axelor.apps.base.db.Partner; +import com.axelor.apps.base.db.Product; +import com.axelor.apps.base.service.app.AppBaseService; +import com.axelor.exception.AxelorException; +import com.axelor.inject.Beans; +import com.axelor.rpc.ActionRequest; +import com.axelor.rpc.ActionResponse; +import com.google.inject.persist.Transactional; + +public class InvoiceTemplateService { + + @Transactional + public Invoice generateInvoiceFromTemplate(InvoiceTemplate invoiceTemplate) throws AxelorException { + + Partner partner = invoiceTemplate.getPartner(); + Company company = invoiceTemplate.getCompany(); + InvoiceGenerator invoiceGenerator = + new InvoiceGenerator( + InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE, + company, + null, + null, + null, + partner, + partner, + partner.getCurrency(), + null, + "", + "", + null, + company.getDefaultBankDetails(), + null) { + + @Override + public Invoice generate() throws AxelorException { + + return super.createInvoiceHeader(); + } + }; + + List invoiceLineList = new ArrayList<>(); + + + Invoice invoice = invoiceGenerator.generate(); + + int priority = 0; + for (InvoiceTemplateLine invoiceTemplateLine : invoiceTemplate.getMoveTemplateLineList()) { + invoiceLineList.addAll(createInvoiceLine(invoice, invoiceTemplateLine, priority)); + priority++; + } + invoiceGenerator.populate(invoice, invoiceLineList); + + Invoice returnInvoiced = Beans.get(InvoiceRepository.class).save(invoice); + + return returnInvoiced; + + } + + + + protected List createInvoiceLine( + Invoice invoice, InvoiceTemplateLine invoiceTemplateLine, int priority) throws AxelorException { + + Product product = invoiceTemplateLine.getProduct(); + + InvoiceLineGenerator invoiceLineGenerator = + new InvoiceLineGenerator( + invoice, + product, + invoiceTemplateLine.getProduct().getName(), + BigDecimal.ZERO, + BigDecimal.ZERO, + BigDecimal.ZERO, + "", + invoiceTemplateLine.getQty(), + invoiceTemplateLine.getProduct().getUnit(), + null, + priority, + BigDecimal.ZERO, + 0, + BigDecimal.ZERO, + BigDecimal.ZERO, + false, + false, + null) { + + @Override + public List creates() throws AxelorException { + + InvoiceLine invoiceLine = this.createInvoiceLine(); + invoiceLine.setQty(BigDecimal.ONE); + invoiceLine.setPrice(BigDecimal.ZERO); + invoiceLine.setPriceDiscounted(BigDecimal.ZERO); + + List invoiceLines = new ArrayList(); + invoiceLines.add(invoiceLine); + + return invoiceLines; + } + }; + + return invoiceLineGenerator.creates(); + } + + + +} diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileGroupService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileGroupService.java index f77321a..ceecbb0 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileGroupService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileGroupService.java @@ -87,6 +87,15 @@ public interface ReconcileGroupService { */ void addAndValidate(ReconcileGroup reconcileGroup, Reconcile reconcile) throws AxelorException; + /** + * Add a reconcile to a group and validate the group if it is balanced. + * + * @param reconcileGroup a reconcileGroup. + * @param List a list reconcile. + */ + public void addAllAndValidate(ReconcileGroup reconcileGroup, List reconcileList) + throws AxelorException; + /** * Add the reconcile and its move line to the reconcile group. * diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileGroupServiceImpl.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileGroupServiceImpl.java index 6ae82fa..c894ee1 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileGroupServiceImpl.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileGroupServiceImpl.java @@ -201,6 +201,18 @@ public class ReconcileGroupServiceImpl implements ReconcileGroupService { } } + @Override + public void addAllAndValidate(ReconcileGroup reconcileGroup, List reconcileList) + throws AxelorException { + + for (Reconcile reconcile : reconcileList) { + addToReconcileGroup(reconcileGroup, reconcile); + } + if (isBalanced(reconcileList)) { + validate(reconcileGroup, reconcileList); + } + } + @Override public void addToReconcileGroup(ReconcileGroup reconcileGroup, Reconcile reconcile) { reconcile.setReconcileGroup(reconcileGroup); diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileServiceImpl.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileServiceImpl.java index a18ef2c..2a8d2d8 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileServiceImpl.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/ReconcileServiceImpl.java @@ -174,11 +174,21 @@ public class ReconcileServiceImpl implements ReconcileService { if (updateInvoicePayments) { this.updateInvoicePayments(reconcile); } - this.addToReconcileGroup(reconcile); + // this.addToReconcileGroup(reconcile); return reconcileRepository.save(reconcile); } + public void addAllToReconcileGroup(List reconciles) throws AxelorException { + ReconcileGroupService reconcileGroupService = Beans.get(ReconcileGroupService.class); + + ReconcileGroup reconcileGroup = reconcileGroupService.findOrCreateGroup(reconciles.get(0)); + reconcileGroupService.addAllAndValidate(reconcileGroup, reconciles); + for (Reconcile reconcile : reconciles) { + this.confirmReconcile(reconcile, true); + } + } + @Override public void addToReconcileGroup(Reconcile reconcile) throws AxelorException { ReconcileGroupService reconcileGroupService = Beans.get(ReconcileGroupService.class); @@ -474,6 +484,8 @@ public class ReconcileServiceImpl implements ReconcileService { log.debug("Seuil respecté"); + log.debug("Entrain de se cree"); + MoveLine creditAdjustMoveLine = moveAdjustementService.createAdjustmentCreditMove(debitMoveLine); @@ -502,6 +514,7 @@ public class ReconcileServiceImpl implements ReconcileService { if (creditMoveLine != null) { BigDecimal creditAmountRemaining = creditMoveLine.getAmountRemaining(); log.debug("Montant à payer / à lettrer au crédit : {}", creditAmountRemaining); + log.debug("creditMoveLine: {}", creditMoveLine.toString()); if (creditAmountRemaining.compareTo(BigDecimal.ZERO) > 0) { AccountConfig accountConfig = @@ -515,8 +528,9 @@ public class ReconcileServiceImpl implements ReconcileService { log.debug("Seuil respecté"); MoveLine debitAdjustmentMoveLine = - moveAdjustementService.createAdjustmentCreditMove(creditMoveLine); + moveAdjustementService.createAdjustmentDebitMove(creditMoveLine); + log.debug("/////////////// {}", creditAmountRemaining); // Création de la réconciliation Reconcile newReconcile = this.createReconcile( diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/Test.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/Test.java new file mode 100644 index 0000000..2fe850f --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/Test.java @@ -0,0 +1,24 @@ +package com.axelor.apps.account.service; + +import java.math.BigDecimal; + +public class Test { + + public static void main(String[] args) { + + BigDecimal debitTotalRemaining = BigDecimal.ZERO; + + + System.out.println(debitTotalRemaining); + setData(debitTotalRemaining); + System.out.println(debitTotalRemaining); + + + } + + + public static void setData(BigDecimal debitTotalRemaining){ + debitTotalRemaining = debitTotalRemaining.add(BigDecimal.TEN); + } + +} diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/invoice/generator/InvoiceGenerator.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/invoice/generator/InvoiceGenerator.java index 7c7edaf..4479ef0 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/invoice/generator/InvoiceGenerator.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/invoice/generator/InvoiceGenerator.java @@ -45,7 +45,6 @@ import com.axelor.apps.base.service.AddressService; import com.axelor.apps.base.service.BlockingService; import com.axelor.apps.base.service.PartnerService; import com.axelor.apps.base.service.TradingNameService; -import com.axelor.apps.base.service.app.AppService; import com.axelor.exception.AxelorException; import com.axelor.exception.db.repo.TraceBackRepository; import com.axelor.i18n.I18n; @@ -420,12 +419,21 @@ public abstract class InvoiceGenerator { } // In the invoice currency - invoice.setInTaxTotal(invoice.getExTaxTotal().add(invoice.getTaxTotal())); - // invoice.setCompanyInTaxTotal(invoice.getCompanyInTaxTotal().add(invoice.getStamp().add(invoice.getFixTax()))); + // invoice.setInTaxTotal(invoice.getExTaxTotal().add(invoice.getTaxTotal())); + invoice.setInTaxTotal( + invoice + .getExTaxTotal() + .add(invoice.getTaxTotal()) + .add(invoice.getStamp().add(invoice.getFixTax()))); // In the company accounting currency - invoice.setCompanyInTaxTotal(invoice.getCompanyExTaxTotal().add(invoice.getCompanyTaxTotal())); - //invoice.setInTaxTotal(invoice.getExTaxTotal().add(invoice.getTaxTotal()).add(invoice.getStamp().add(invoice.getFixTax()))); + // + // invoice.setCompanyInTaxTotal(invoice.getCompanyExTaxTotal().add(invoice.getCompanyTaxTotal())); + invoice.setCompanyInTaxTotal( + invoice + .getCompanyExTaxTotal() + .add(invoice.getCompanyTaxTotal()) + .add(invoice.getStamp().add(invoice.getFixTax()))); invoice.setAmountRemaining(invoice.getInTaxTotal()); invoice.setHasPendingPayments(false); diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveAdjustementService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveAdjustementService.java index 8bc0c67..f4877a7 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveAdjustementService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveAdjustementService.java @@ -30,10 +30,15 @@ import com.axelor.apps.base.db.Partner; import com.axelor.exception.AxelorException; import com.google.inject.Inject; import com.google.inject.persist.Transactional; +import java.lang.invoke.MethodHandles; import java.math.BigDecimal; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MoveAdjustementService { + private final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + protected MoveLineService moveLineService; protected MoveCreateService moveCreateService; protected MoveValidateService moveValidateService; @@ -66,7 +71,7 @@ public class MoveAdjustementService { * @throws AxelorException */ @Transactional(rollbackOn = {Exception.class}) - public void createAdjustmentDebitMove(MoveLine debitMoveLine) throws AxelorException { + public MoveLine createAdjustmentDebitMove(MoveLine debitMoveLine) throws AxelorException { Partner partner = debitMoveLine.getPartner(); Account account = debitMoveLine.getAccount(); @@ -76,6 +81,8 @@ public class MoveAdjustementService { BigDecimal debitAmountRemaining = debitMoveLine.getAmountRemaining(); + log.debug("============ debitAmountRemaining", debitAmountRemaining.toString()); + Journal miscOperationJournal = accountConfigService.getAutoMiscOpeJournal(accountConfig); Move adjustmentMove = @@ -87,6 +94,11 @@ public class MoveAdjustementService { null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC); + adjustmentMove.setPaymentVoucher(debitMoveLine.getMove().getPaymentVoucher()); + adjustmentMove.setPaymentMode(debitMoveLine.getMove().getPaymentVoucher().getPaymentMode()); + debitMoveLine.getMove().getPaymentVoucher().getGeneratedMoveList().add(adjustmentMove); + + log.debug("============ move", adjustmentMove.toString()); // Création de la ligne au crédit MoveLine creditAdjustmentMoveLine = moveLineService.createMoveLine( @@ -94,7 +106,7 @@ public class MoveAdjustementService { partner, account, debitAmountRemaining, - false, + true, appAccountService.getTodayDate(), 1, null, @@ -107,7 +119,7 @@ public class MoveAdjustementService { partner, accountConfigService.getCashPositionVariationAccount(accountConfig), debitAmountRemaining, - true, + false, appAccountService.getTodayDate(), 2, null, @@ -118,6 +130,8 @@ public class MoveAdjustementService { moveValidateService.validate(adjustmentMove); moveRepository.save(adjustmentMove); + + return creditAdjustmentMoveLine; } /** @@ -138,6 +152,8 @@ public class MoveAdjustementService { Journal miscOperationJournal = accountConfigService.getAutoMiscOpeJournal(accountConfig); + log.debug("============ debitMoveLine", debitMoveLine.toString()); + Move adjustmentMove = moveCreateService.createMove( miscOperationJournal, diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveLineService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveLineService.java index 6a420c3..c2a43e7 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveLineService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveLineService.java @@ -38,11 +38,14 @@ import com.axelor.apps.account.exception.IExceptionMessage; import com.axelor.apps.account.service.AccountManagementAccountService; import com.axelor.apps.account.service.AnalyticMoveLineService; import com.axelor.apps.account.service.FiscalPositionAccountService; +import com.axelor.apps.account.service.ReconcileServiceImpl; import com.axelor.apps.account.service.TaxAccountService; import com.axelor.apps.account.service.TaxPaymentMoveLineService; import com.axelor.apps.account.service.app.AppAccountService; +import com.axelor.apps.account.service.config.AccountConfigService; import com.axelor.apps.account.service.invoice.InvoiceToolService; import com.axelor.apps.account.service.payment.PaymentService; +import com.axelor.apps.account.service.payment.PaymentServiceImpl; import com.axelor.apps.base.db.Company; import com.axelor.apps.base.db.Currency; import com.axelor.apps.base.db.Partner; @@ -514,6 +517,52 @@ public class MoveLineService { moveLines.add(moveLine); } } + if (invoice.getFixTax().compareTo(BigDecimal.ZERO) > 0) { + Account taxAccount = + Beans.get((AccountConfigService.class)) + .getAccountConfig(move.getCompany()) + .getTaxAccount(); + MoveLine moveLine2 = + this.createMoveLine( + move, + partner, + taxAccount, + invoice.getFixTax(), + invoice.getFixTax(), + null, + !isDebitCustomer, + invoice.getInvoiceDate(), + null, + invoice.getOriginDate(), + moveLineId++, + origin, + taxAccount.getName()); + log.debug("#################### moveLine {}", moveLine2.toString()); + moveLines.add(moveLine2); + } + if (invoice.getStamp().compareTo(BigDecimal.ZERO) > 0) { + Account stampAccount = + Beans.get((AccountConfigService.class)) + .getAccountConfig(move.getCompany()) + .getStampAccount(); + MoveLine moveLine2 = + this.createMoveLine( + move, + partner, + stampAccount, + invoice.getStamp(), + invoice.getStamp(), + null, + !isDebitCustomer, + invoice.getInvoiceDate(), + null, + invoice.getOriginDate(), + moveLineId++, + origin, + stampAccount.getName()); + log.debug("#################### moveLine {}", moveLine2.toString()); + moveLines.add(moveLine2); + } // Creation of tax move lines for each invoice line tax for (InvoiceLineTax invoiceLineTax : invoice.getInvoiceLineTaxList()) { @@ -948,32 +997,38 @@ public class MoveLineService { * * @param moveLineList */ - public void reconcileMoveLinesWithCacheManagement(List moveLineList) throws AxelorException{ + public void reconcileMoveLinesWithCacheManagement(List moveLineList) + throws AxelorException { List reconciliableCreditMoveLineList = getReconciliableCreditMoveLines(moveLineList); List reconciliableDebitMoveLineList = getReconciliableDebitMoveLines(moveLineList); - - //pour desactiver le lettrage (Provisoire) - BigDecimal totalDebit = BigDecimal.ZERO; - BigDecimal totalCredit = BigDecimal.ZERO; - if (reconciliableCreditMoveLineList.size() > 0 && reconciliableDebitMoveLineList.size() > 0) { - for (MoveLine moveLine : reconciliableCreditMoveLineList) { - totalCredit = totalCredit.add(moveLine.getCredit()); - } - for (MoveLine moveLine : reconciliableDebitMoveLineList) { - totalDebit = totalDebit.add(moveLine.getDebit()); - } - } - //pour desactiver le lettrage (Provisoire) + // pour desactiver le lettrage (Provisoire) + // BigDecimal totalDebit = BigDecimal.ZERO; + // BigDecimal totalCredit = BigDecimal.ZERO; - if(totalDebit.equals(totalCredit)){ + // if (reconciliableCreditMoveLineList.size() > 0 && reconciliableDebitMoveLineList.size() > 0) + // { + // for (MoveLine moveLine : reconciliableCreditMoveLineList) { + // totalCredit = totalCredit.add(moveLine.getCredit()); + // } + // for (MoveLine moveLine : reconciliableDebitMoveLineList) { + // totalDebit = totalDebit.add(moveLine.getDebit()); + // } + // } + // pour desactiver le lettrage (Provisoire) + + // if(totalDebit.equals(totalCredit)){ Map, Pair, List>> moveLineMap = new HashMap<>(); populateCredit(moveLineMap, reconciliableCreditMoveLineList); populateDebit(moveLineMap, reconciliableDebitMoveLineList); + System.out.println("************************************************"); + System.out.println(moveLineMap.toString()); + System.out.println("************************************************"); + Comparator byDate = Comparator.comparing(MoveLine::getDate); PaymentService paymentService = Beans.get(PaymentService.class); @@ -989,11 +1044,13 @@ public class MoveLineService { JPA.clear(); } } - }else{ - throw new AxelorException( - TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, - "(total Credit ="+totalCredit+") != (total Debit="+totalDebit+")"); - } + + // } + // else{ + // throw new AxelorException( + // TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, + // "(total Credit ="+totalCredit+") != (total Debit="+totalDebit+")"); + // } } protected Pair, List> findMoveLineLists( @@ -1075,7 +1132,7 @@ public class MoveLineService { keys.add(move.getCompany()); keys.add(moveLine.getAccount()); - keys.add(moveLine.getPartner()); + // keys.add(moveLine.getPartner()); Pair, List> moveLineLists = moveLineMap.get(keys); diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveRemoveService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveRemoveService.java index 0f5d037..ec7a5eb 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveRemoveService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveRemoveService.java @@ -83,7 +83,7 @@ public class MoveRemoveService { return move; } - protected void cleanMoveToArchived(Move move) throws Exception { + public void cleanMoveToArchived(Move move) throws Exception { for (MoveLine moveLine : move.getMoveLineList()) { for (Reconcile reconcile : moveLine.getDebitReconcileList()) { reconcileService.unreconcile(reconcile); diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveSequenceService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveSequenceService.java index 6837f42..bf9de90 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveSequenceService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveSequenceService.java @@ -27,6 +27,7 @@ import com.axelor.exception.db.repo.TraceBackRepository; import com.axelor.i18n.I18n; import com.google.common.base.Strings; import com.google.inject.Inject; +import java.time.LocalDate; public class MoveSequenceService { @@ -47,7 +48,7 @@ public class MoveSequenceService { } } - public void setSequence(Move move) throws AxelorException { + public void setSequence(Move move, LocalDate refDate) throws AxelorException { Journal journal = move.getJournal(); @@ -57,6 +58,6 @@ public class MoveSequenceService { I18n.get(IExceptionMessage.MOVE_5), journal.getName()); } - move.setReference(sequenceService.getSequenceNumber(journal.getSequence())); + move.setReference(sequenceService.getSequenceNumber(journal.getSequence(), refDate)); } } diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveValidateService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveValidateService.java index c875cd5..6d966ef 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveValidateService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/move/MoveValidateService.java @@ -228,7 +228,7 @@ public class MoveValidateService { accountConfigService.getAccountConfig(move.getCompany()).getAccountingDaybook(); if (!dayBookMode || move.getStatusSelect() == MoveRepository.STATUS_DAYBOOK) { - moveSequenceService.setSequence(move); + moveSequenceService.setSequence(move, move.getDate()); } if (move.getPeriod().getStatusSelect() == PeriodRepository.STATUS_ADJUSTING) { diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/PaymentModeServiceImpl.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/PaymentModeServiceImpl.java index 43567ca..32844e9 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/PaymentModeServiceImpl.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/PaymentModeServiceImpl.java @@ -110,8 +110,7 @@ public class PaymentModeServiceImpl implements PaymentModeService { public Sequence getPaymentModeSequence( PaymentMode paymentMode, Company company, BankDetails bankDetails) throws AxelorException { - AccountManagement accountManagement = - this.getAccountManagement(paymentMode, company, bankDetails); + AccountManagement accountManagement = this.getAccountManagement(paymentMode, company); if (accountManagement == null || accountManagement.getSequence() == null) { throw new AxelorException( diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/PaymentServiceImpl.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/PaymentServiceImpl.java index d2ace6c..0fcab8d 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/PaymentServiceImpl.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/PaymentServiceImpl.java @@ -25,6 +25,7 @@ import com.axelor.apps.account.db.PayVoucherElementToPay; import com.axelor.apps.account.db.PaymentScheduleLine; import com.axelor.apps.account.db.Reconcile; import com.axelor.apps.account.service.ReconcileService; +import com.axelor.apps.account.service.ReconcileServiceImpl; import com.axelor.apps.account.service.app.AppAccountService; import com.axelor.apps.account.service.move.MoveLineService; import com.axelor.apps.base.db.Company; @@ -32,6 +33,7 @@ import com.axelor.apps.base.db.Partner; import com.axelor.db.JPA; import com.axelor.exception.AxelorException; import com.axelor.exception.service.TraceBackService; +import com.axelor.inject.Beans; import com.google.inject.Inject; import com.google.inject.persist.Transactional; import java.lang.invoke.MethodHandles; @@ -50,7 +52,7 @@ public class PaymentServiceImpl implements PaymentService { protected ReconcileService reconcileService; protected MoveLineService moveLineService; - + public List reconciles = new ArrayList<>(); protected AppAccountService appAccountService; @Inject @@ -125,7 +127,7 @@ public class PaymentServiceImpl implements PaymentService { log.debug( "Emploie du trop perçu : ligne en crédit (restant à payer): {})", creditMoveLine.getAmountRemaining()); - creditTotalRemaining = creditTotalRemaining.add(creditMoveLine.getAmountRemaining()); + creditTotalRemaining = creditTotalRemaining.add(creditMoveLine.getAmountRemaining().setScale(2,BigDecimal.ROUND_HALF_EVEN)); } for (MoveLine debitMoveLine : debitMoveLines) { @@ -134,7 +136,7 @@ public class PaymentServiceImpl implements PaymentService { log.debug( "Emploie du trop perçu : ligne en débit (restant à payer): {})", debitMoveLine.getAmountRemaining()); - debitTotalRemaining = debitTotalRemaining.add(debitMoveLine.getAmountRemaining()); + debitTotalRemaining = debitTotalRemaining.add(debitMoveLine.getAmountRemaining().setScale(2,BigDecimal.ROUND_HALF_EVEN)); } for (MoveLine creditMoveLine : creditMoveLines) { @@ -146,7 +148,7 @@ public class PaymentServiceImpl implements PaymentService { && (creditMoveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) == 1)) { try { createReconcile( - debitMoveLine, creditMoveLine, debitTotalRemaining, creditTotalRemaining); + debitMoveLine, creditMoveLine, debitTotalRemaining.setScale(4), creditTotalRemaining.setScale(4)); } catch (Exception e) { if (dontThrow) { TraceBackService.trace(e); @@ -159,6 +161,7 @@ public class PaymentServiceImpl implements PaymentService { } } } + Beans.get(ReconcileServiceImpl.class).addAllToReconcileGroup(reconciles); } } @@ -201,6 +204,7 @@ public class PaymentServiceImpl implements PaymentService { } else { reconcile = reconcileService.createReconcile(debitMoveLine, creditMoveLine, amount, false); } + this.reconciles.add(reconcile); // End gestion du passage en 580 if (reconcile != null) { diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherConfirmService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherConfirmService.java index 0b05c14..870da15 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherConfirmService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherConfirmService.java @@ -18,28 +18,39 @@ package com.axelor.apps.account.service.payment.paymentvoucher; import com.axelor.apps.account.db.Account; +import com.axelor.apps.account.db.AccountConfig; import com.axelor.apps.account.db.Invoice; import com.axelor.apps.account.db.Journal; import com.axelor.apps.account.db.Move; import com.axelor.apps.account.db.MoveLine; +import com.axelor.apps.account.db.PayVoucherDueElement; import com.axelor.apps.account.db.PayVoucherElementToPay; import com.axelor.apps.account.db.PaymentMode; import com.axelor.apps.account.db.PaymentVoucher; import com.axelor.apps.account.db.Reconcile; +import com.axelor.apps.account.db.ReconcileGroup; +import com.axelor.apps.account.db.repo.InvoiceRepository; import com.axelor.apps.account.db.repo.MoveRepository; import com.axelor.apps.account.db.repo.PayVoucherElementToPayRepository; import com.axelor.apps.account.db.repo.PaymentVoucherRepository; import com.axelor.apps.account.exception.IExceptionMessage; import com.axelor.apps.account.service.AccountCustomerService; +import com.axelor.apps.account.service.MoveLineExportService; +import com.axelor.apps.account.service.ReconcileGroupServiceImpl; import com.axelor.apps.account.service.ReconcileService; import com.axelor.apps.account.service.app.AppAccountService; +import com.axelor.apps.account.service.config.AccountConfigService; +import com.axelor.apps.account.service.move.MoveCancelService; import com.axelor.apps.account.service.move.MoveLineService; import com.axelor.apps.account.service.move.MoveService; +import com.axelor.apps.account.service.move.MoveServiceImpl; import com.axelor.apps.account.service.payment.PaymentModeService; import com.axelor.apps.account.service.payment.PaymentService; import com.axelor.apps.base.db.BankDetails; import com.axelor.apps.base.db.Company; import com.axelor.apps.base.db.Partner; +import com.axelor.apps.purchase.db.PurchaseOrder; +import com.axelor.auth.AuthUtils; import com.axelor.exception.AxelorException; import com.axelor.exception.db.repo.TraceBackRepository; import com.axelor.i18n.I18n; @@ -50,7 +61,12 @@ import java.lang.invoke.MethodHandles; import java.math.BigDecimal; import java.time.LocalDate; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,6 +84,7 @@ public class PaymentVoucherConfirmService { protected PaymentVoucherToolService paymentVoucherToolService; protected PayVoucherElementToPayRepository payVoucherElementToPayRepo; protected PaymentVoucherRepository paymentVoucherRepository; + protected List reconciles = new ArrayList(); @Inject public PaymentVoucherConfirmService( @@ -105,21 +122,36 @@ public class PaymentVoucherConfirmService { * @param paymentVoucher */ @Transactional(rollbackOn = {Exception.class}) - public void confirmPaymentVoucher(PaymentVoucher paymentVoucher) throws AxelorException { + public void confirmPaymentVoucher(PaymentVoucher paymentVoucher, Boolean isConfirmed) + throws AxelorException { log.debug("In confirmPaymentVoucherService ...."); paymentVoucherSequenceService.setReference(paymentVoucher); PaymentMode paymentMode = paymentVoucher.getPaymentMode(); Company company = paymentVoucher.getCompany(); BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails(); - Journal journal = - paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails); - - Account paymentModeAccount = - paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails); + Journal journal; + + + if (paymentVoucher.getPaymentMode().getId() == 12 || paymentVoucher.getPaymentMode().getId() == 23) { + if(paymentVoucher.getPartner().getAccountingManagementList().size() == 0){ + throw new AxelorException( + paymentVoucher, + TraceBackRepository.CATEGORY_INCONSISTENCY, + I18n.get("Journal manquant !!"), + I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION)); + }else{ + journal = paymentVoucher.getPartner().getAccountingManagementList().get(0).getJournal(); + } + }else{ + journal = + paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails); + Account paymentModeAccount = + paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails); paymentVoucherControlService.checkPaymentVoucherField( paymentVoucher, company, paymentModeAccount, journal); + } if (paymentVoucher.getRemainingAmount().compareTo(BigDecimal.ZERO) > 0 && !journal.getExcessPaymentOk()) { @@ -141,9 +173,15 @@ public class PaymentVoucherConfirmService { && paymentVoucher.getPaymentMode().getValidatePaymentByDepositSlipPublication()) { waitForDepositSlip(paymentVoucher); } else { - createMoveAndConfirm(paymentVoucher); + if (!isConfirmed && paymentVoucher.getGeneratedMoveList().size() == 0) { + createMoveAndConfirm(paymentVoucher); + } + if ((paymentVoucher.getPaymentMode().getId() == 12 || paymentVoucher.getPaymentMode().getId() == 23) && isConfirmed) { + confirmBankMove(paymentVoucher); + } } + paymentVoucher.setStatusTypeSelect(1); // confirmé paymentVoucherSequenceService.setReceiptNo(paymentVoucher, company, journal); paymentVoucherRepository.save(paymentVoucher); } @@ -172,12 +210,23 @@ public class PaymentVoucherConfirmService { PaymentMode paymentMode = paymentVoucher.getPaymentMode(); Company company = paymentVoucher.getCompany(); BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails(); - Journal journal = - paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails); - LocalDate paymentDate = paymentVoucher.getPaymentDate(); + Journal journal; + // LocalDate paymentDate = paymentVoucher.getPaymentDate(); + LocalDate paymentDate = paymentVoucher.getPaymentEmissionDate(); + boolean scheduleToBePaid = false; - Account paymentModeAccount = + Account paymentModeAccount; + + if (paymentVoucher.getPaymentMode().getId() == 12 || paymentVoucher.getPaymentMode().getId() == 23) { + paymentModeAccount = + paymentVoucher.getPartner().getAccountingManagementList().get(0).getCashAccount(); + journal = paymentVoucher.getPartner().getAccountingManagementList().get(0).getJournal(); + }else{ + journal = + paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails); + paymentModeAccount = paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails); + } // If paid by a moveline check if all the lines selected have the same account + company // Excess payment @@ -218,37 +267,99 @@ public class PaymentVoucherConfirmService { move.setPaymentVoucher(paymentVoucher); paymentVoucher.setGeneratedMove(move); + + // confirmed by + paymentVoucher.setConfirmedByUser(AuthUtils.getUser()); + paymentVoucher.setConfirmationDate(LocalDate.now()); + // Create move lines for payment lines BigDecimal paidLineTotal = BigDecimal.ZERO; int moveLineNo = 1; boolean isDebitToPay = paymentVoucherToolService.isDebitToPay(paymentVoucher); - for (PayVoucherElementToPay payVoucherElementToPay : - this.getPayVoucherElementToPayList(paymentVoucher)) { + List payVoucherElementToPayList = + this.getPayVoucherElementToPayList(paymentVoucher); + + MoveLine moveLineInvoices = null; + + if(paymentVoucher.getOperationTypeSelect() == 6){ + + moveLineInvoices = + moveLineService.createMoveLine( + move, + payerPartner, + payerPartner.getAccountingSituationList().get(0).getCustomerAccount(), + paymentVoucher.getPaidAmount(), + !isDebitToPay, + paymentDate, + moveLineNo++, + paymentVoucher.getRef(), + null); + paidLineTotal = paymentVoucher.getPaidAmount(); + + move.getMoveLineList().add(moveLineInvoices); + + }else{ + + + for (PayVoucherElementToPay payVoucherElementToPay : payVoucherElementToPayList) { MoveLine moveLineToPay = payVoucherElementToPay.getMoveLine(); log.debug("PV moveLineToPay debit : {}", moveLineToPay.getDebit()); + log.debug("PV moveLineToPay credit : {}", moveLineToPay.getCredit()); log.debug("PV moveLineToPay amountPaid : {}", moveLineToPay.getAmountPaid()); BigDecimal amountToPay = payVoucherElementToPay.getAmountToPayCurrency(); + log.debug(">>>> PV amountToPay : {}", amountToPay); - if (amountToPay.compareTo(BigDecimal.ZERO) > 0) { + Invoice invoice = payVoucherElementToPay.getMoveLine().getMove().getInvoice(); + isDebitToPay = paymentVoucherToolService.isDebitToPay(invoice); + + boolean isRefundInvoice = false; + if (invoice.getOperationTypeSelect() + == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND) { + isRefundInvoice = true; + } + + log.debug("heyyyyyyyyyyyyyyyyy : {}", isRefundInvoice); + + if (amountToPay.compareTo(BigDecimal.ZERO) > 0 || isRefundInvoice) { + + if (isRefundInvoice + // || paymentVoucher.getOperationTypeSelect() + // == PaymentVoucherRepository.OPERATION_TYPE_CLIENT_SALE_CLIENT_REFUND + // || paymentVoucher.getOperationTypeSelect() + // == PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_PURCHASE_SUPPLIER_REFUND + ) { + amountToPay = payVoucherElementToPay.getTotalAmount(); + log.debug( + "**** getInvoiceId {} *** isDebitToPay {} **** amountToPay {}", + invoice.getInvoiceId(), + isDebitToPay, + amountToPay); + } paidLineTotal = paidLineTotal.add(amountToPay); + log.debug("amountToPay >>>>>>>>>>> {}", amountToPay); + this.payMoveLine( move, moveLineNo++, payerPartner, moveLineToPay, amountToPay, + amountToPay, + // isRefundInvoice ? amountToPay : payVoucherElementToPay.getAmountToPayCurrency(), payVoucherElementToPay, isDebitToPay, paymentDate); } } + } // Create move line for the payment amount MoveLine moveLine = null; + isDebitToPay = paymentVoucherToolService.isDebitToPay(paymentVoucher); // cancelling the moveLine (excess payment) by creating the balance of all the payments // on the same account as the moveLine (excess payment) @@ -266,20 +377,27 @@ public class PaymentVoucherConfirmService { paymentVoucher.getRef(), null); - Reconcile reconcile = - reconcileService.createReconcile( - moveLine, paymentVoucher.getMoveLine(), moveLine.getDebit(), !isDebitToPay); - if (reconcile != null) { - reconcileService.confirmReconcile(reconcile, true); - } + // Reconcile reconcile = + // reconcileService.createReconcile( + // moveLine, paymentVoucher.getMoveLine(), moveLine.getDebit(), !isDebitToPay); + // if (reconcile != null) { + // reconcileService.confirmReconcile(reconcile, true); + // } } else { + BigDecimal paidAmount = BigDecimal.ZERO; + + // if(paymentVoucher.getOperationTypeSelect() == 6){ + // paidAmount = processSaleAndRefund(payVoucherElementToPayList); + // }else{ + paidAmount = paymentVoucher.getPaidAmount(); + // } moveLine = moveLineService.createMoveLine( move, payerPartner, paymentModeAccount, - paymentVoucher.getPaidAmount(), + paidAmount, isDebitToPay, paymentDate, moveLineNo++, @@ -287,9 +405,14 @@ public class PaymentVoucherConfirmService { null); } move.getMoveLineList().add(moveLine); + // Check if the paid amount is > paid lines total // Then Use Excess payment on old invoices / moveLines - if (paymentVoucher.getPaidAmount().compareTo(paidLineTotal) > 0) { + if (paymentVoucher.getPaidAmount().compareTo(paidLineTotal) > 0 + || paymentVoucher + .getPaidAmount() + .compareTo(processSaleAndRefundTotal(paymentVoucher).get("total")) + > 0) { BigDecimal remainingPaidAmount = paymentVoucher.getRemainingAmount(); // TODO rajouter le process d'imputation automatique @@ -321,20 +444,201 @@ public class PaymentVoucherConfirmService { moveLineNo++, paymentVoucher.getRef(), null); + move.getMoveLineList().add(moveLine); + log.debug("******************** remainingPaidAmount {}", remainingPaidAmount); + log.debug("******************** isDebitToPay confirm voucher{}", moveLine.toString()); + log.debug("******************** isDebitToPay confirm voucher{}", moveLine.toString()); + if (isDebitToPay) { reconcileService.balanceCredit(moveLine); } } moveService.getMoveValidateService().validate(move); paymentVoucher.setGeneratedMove(move); + paymentVoucher.addGeneratedMoveListItem(move); } - paymentVoucher.setStatusSelect(PaymentVoucherRepository.STATUS_CONFIRMED); + // paymentVoucher.setStatusSelect(PaymentVoucherRepository.STATUS_CONFIRMED); + + Beans.get(PaymentVoucherLoadService.class).updateVoucher(paymentVoucher); deleteUnPaidLines(paymentVoucher); } + @Transactional(rollbackOn = {Exception.class}) + public void confirmBankMove(PaymentVoucher paymentVoucher) throws AxelorException { + Partner payerPartner = paymentVoucher.getPartner(); + PaymentMode paymentMode = paymentVoucher.getPaymentMode(); + Company company = paymentVoucher.getCompany(); + BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails(); + Journal journal = + paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails); + // LocalDate paymentDate = paymentVoucher.getPaymentDate(); + LocalDate paymentDate = paymentVoucher.getPaymentEmissionDate(); + LocalDate paymentDateEchance = paymentVoucher.getDueDate(); + + if(paymentVoucher.getSort() == 3){ + paymentDateEchance = paymentVoucher.getCreditDate(); + } + + boolean scheduleToBePaid = false; + Account paymentModeAccount = + paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails); + + Move move = + moveService + .getMoveCreateService() + .createMoveWithPaymentVoucher( + journal, + company, + paymentVoucher, + payerPartner, + paymentDateEchance, + paymentMode, + MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC); + + move.setPaymentVoucher(paymentVoucher); + + boolean isDebitToPay = paymentVoucherToolService.isDebitToPay(paymentVoucher); + + List payVoucherElementToPayList = + this.getPayVoucherElementToPayList(paymentVoucher); + + BigDecimal paidAmount = paymentVoucher.getPaidAmount(); + + int moveLineNo = 1; + + MoveLine moveLine2 = + moveLineService.createMoveLine( + move, + payerPartner, + paymentVoucher.getPartner().getAccountingManagementList().get(0).getCashAccount(), + paidAmount, + !isDebitToPay, + paymentDateEchance, + moveLineNo++, + paymentVoucher.getRef(), + null); + + MoveLine moveLine = + moveLineService.createMoveLine( + move, + payerPartner, + paymentModeAccount, + paidAmount, + isDebitToPay, + paymentDateEchance, + moveLineNo++, + paymentVoucher.getRef(), + null); + + move.getMoveLineList().add(moveLine); + move.getMoveLineList().add(moveLine2); + + moveService.getMoveValidateService().validate(move); + paymentVoucher.setGeneratedMove(move); + paymentVoucher.addGeneratedMoveListItem(move); + + if (isDebitToPay) { + reconcileService.balanceCredit(moveLine); + } + Beans.get(PaymentVoucherLoadService.class).updateVoucher(paymentVoucher); + } + + @Transactional(rollbackOn = {Exception.class}) + public void confirmOtherPayment(PaymentVoucher paymentVoucher) throws AxelorException { + PaymentMode paymentMode = paymentVoucher.getPaymentMode(); + Company company = paymentVoucher.getCompany(); + BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails(); + Journal journal = + paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails); + // LocalDate paymentDate = paymentVoucher.getPaymentDate(); + LocalDate paymentDate = paymentVoucher.getPaymentEmissionDate(); + LocalDate paymentDateEchance = paymentVoucher.getDueDate(); + + if(paymentVoucher.getSort() == 3){ + paymentDateEchance = paymentVoucher.getCreditDate(); + } + + boolean scheduleToBePaid = false; + Account paymentModeAccount = + paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails); + + Move move = + moveService + .getMoveCreateService() + .createMoveWithPaymentVoucher( + journal, + company, + paymentVoucher, + null, + paymentDate, + paymentMode, + MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC); + + move.setPaymentVoucher(paymentVoucher); + + List payVoucherElementToPayList = + this.getPayVoucherElementToPayList(paymentVoucher); + + Boolean isDebitToPay = false; + + Account accountToPay = null; + + if(paymentModeAccount.getIsOriginRequired()){ + MoveLine moveLineToPay = payVoucherElementToPayList.get(0).getMoveLine(); + + if(moveLineToPay.getCredit().compareTo(BigDecimal.ZERO) > 0){ + isDebitToPay = true; + } + accountToPay = moveLineToPay.getAccount(); + }else{ + accountToPay = paymentVoucher.getPartner().getAccountingSituationList().get(0).getPartnerPaymentAccount(); + } + + BigDecimal paidAmount = paymentVoucher.getPaidAmount(); + + int moveLineNo = 1; + + MoveLine moveLine2 = + moveLineService.createMoveLine( + move, + null, + accountToPay, + paidAmount, + !isDebitToPay, + paymentDateEchance, + moveLineNo++, + paymentVoucher.getRef(), + null); + + MoveLine moveLine = + moveLineService.createMoveLine( + move, + null, + paymentModeAccount, + paidAmount, + isDebitToPay, + paymentDateEchance, + moveLineNo++, + paymentVoucher.getRef(), + null); + + move.getMoveLineList().add(moveLine); + move.getMoveLineList().add(moveLine2); + + moveService.getMoveValidateService().validate(move); + paymentVoucher.setGeneratedMove(move); + paymentVoucher.addGeneratedMoveListItem(move); + + if (isDebitToPay) { + reconcileService.balanceCredit(moveLine); + } + // Beans.get(PaymentVoucherLoadService.class).updateVoucher(paymentVoucher); + } + + public void deleteUnPaidLines(PaymentVoucher paymentVoucher) { if (paymentVoucher.getPayVoucherElementToPayList() == null) { @@ -418,6 +722,7 @@ public class PaymentVoucherConfirmService { Partner payerPartner, MoveLine moveLineToPay, BigDecimal amountToPay, + BigDecimal amountToPayReel, PayVoucherElementToPay payVoucherElementToPay, boolean isDebitToPay, LocalDate paymentDate) @@ -446,11 +751,341 @@ public class PaymentVoucherConfirmService { BigDecimal amountInCompanyCurrency = moveLine.getDebit().add(moveLine.getCredit()); Reconcile reconcile = - reconcileService.createReconcile(moveLineToPay, moveLine, amountInCompanyCurrency, true); + reconcileService.createReconcile(moveLineToPay, moveLine, amountToPayReel, true); + reconciles.add(reconcile); if (reconcile != null) { log.debug("Reconcile : : : {}", reconcile); reconcileService.confirmReconcile(reconcile, true); } return moveLine; } + + public Map processSaleAndRefund(PaymentVoucher paymentVoucher) { + List payVoucherElementToPayList = + paymentVoucher.getPayVoucherDueElementList(); + BigDecimal total = BigDecimal.ZERO; + BigDecimal remaining = BigDecimal.ZERO; + Map tot = new HashMap<>(); + + for (PayVoucherDueElement dueElement : payVoucherElementToPayList) { + total = + total.add(dueElement.getMoveLine().getDebit().add(dueElement.getMoveLine().getCredit())); + } + if (paymentVoucher.getPaidAmount().compareTo(total) > 0) { + remaining = paymentVoucher.getPaidAmount().abs().subtract(total).abs(); + } + tot.put("total", total.abs()); + tot.put("remaining", remaining); + return tot; + } + + public Map processSaleAndRefundTotal(PaymentVoucher paymentVoucher) { + List payVoucherElementToPayList = + paymentVoucher.getPayVoucherElementToPayList(); + BigDecimal total = BigDecimal.ZERO; + BigDecimal remaining = BigDecimal.ZERO; + Map tot = new HashMap<>(); + + for (PayVoucherElementToPay elementToPay : payVoucherElementToPayList) { + total = + total.add( + elementToPay + .getMoveLine() + .getDebit() + .subtract(elementToPay.getMoveLine().getCredit())); + } + BigDecimal absTotal = total.abs(); + if (paymentVoucher.getPaidAmount().compareTo(total) > 0) { + remaining = paymentVoucher.getPaidAmount().subtract(absTotal).abs(); + } else { + remaining = BigDecimal.ZERO; + } + tot.put("total", absTotal); + tot.put("remaining", remaining); + return tot; + } + + @Transactional(rollbackOn = {Exception.class}) + public PaymentVoucher copyPaymentVoucher(PaymentVoucher paymentVoucher) throws AxelorException { + + PaymentVoucher paymentVoucher2 = + Beans.get(PaymentVoucherRepository.class).copy(paymentVoucher, false); + paymentVoucher2.setGeneratedMove(null); + paymentVoucher2.setGeneratedMoveList(null); + paymentVoucher2.setOriginPaymentVoucher(paymentVoucher); + paymentVoucher2.setRequestDate(null); + paymentVoucher2.setRequestedByUser(null); + paymentVoucher2.setAcceptanceDate(null); + paymentVoucher2.setAcceptedByUser(null); + paymentVoucher2.setConfirmationDate(null); + paymentVoucher2.setConfirmedByUser(null); + paymentVoucher2.setConfirmedByUser(null); + paymentVoucher2.setRejectedDate(null); + paymentVoucher2.setRejectedByUser(null); + paymentVoucher2.setRejectionRaison(null); + + for (PayVoucherElementToPay elementToPay : paymentVoucher.getPayVoucherElementToPayList()) { + PayVoucherElementToPay elementToPayCopy = + Beans.get(PayVoucherElementToPayRepository.class).copy(elementToPay, false); + paymentVoucher2.addPayVoucherElementToPayListItem(elementToPayCopy); + } + + return paymentVoucherRepository.save(paymentVoucher2); + } + + @Transactional(rollbackOn = {Exception.class}) + public PaymentVoucher rejectPaymentVoucher(PaymentVoucher paymentVoucher, String cancelRaison) + throws AxelorException { + + paymentVoucher.setStatusSelect(PaymentVoucherRepository.STATUS_REJECTED); + paymentVoucher.setRejectionRaison(cancelRaison); + paymentVoucher.setRejectedDate(LocalDate.now()); + paymentVoucher.setRejectedByUser(AuthUtils.getUser()); + paymentVoucher.setRejectedInstanceSelect(1); + + // for (Move move : paymentVoucher.getGeneratedMoveList()) { + // for (MoveLine moveLine : move.getMoveLineList()) { + // ReconcileGroup reconcileGroup = moveLine.getReconcileGroup(); + // if (reconcileGroup != null) { + // Beans.get(ReconcileGroupServiceImpl.class).unletter(reconcileGroup); + // log.debug("Unlettering ::: {} ******", reconcileGroup); + // } + // } + // // Move move = elementToPay.getMoveLine().getMove(); + // // for (InvoicePayment invoicePayment : move.getInvoice().getInvoicePaymentList()) { + // // Beans.get(InvoicePaymentCancelService.class).cancel(invoicePayment); + // // } + + // } + + PaymentVoucher paymentVoucher2 = + Beans.get(PaymentVoucherConfirmService.class).copyPaymentVoucher(paymentVoucher); + + for (Move move : paymentVoucher.getGeneratedMoveList()) { + log.debug("Rejecting move : : : {} **********", move); + + try { + Move reverseMove = Beans.get(MoveServiceImpl.class).generateReverse(move, false, false, true, LocalDate.now()); + paymentVoucher2.addGeneratedMoveListItem(reverseMove); + // moveCancelService.cancel(move); + } catch (AxelorException e) { + log.debug("Error : : : {}", e); + } + } + + paymentVoucherRepository.save(paymentVoucher2); + return paymentVoucher2; + // Beans.get(InvoicePaymentRepository.class).all().filter("self.invoice = ?1", null); + + } + + @Transactional(rollbackOn = {Exception.class}) + public Move confirmMultipleVoucher(List voucherList, List elementToPays, boolean b) throws AxelorException { + if(voucherList != null && voucherList.size() > 0 ){ + if(!samePaymentVoucherSelect(voucherList) || voucherAlreadyInMove(voucherList)){ + throw new AxelorException( + voucherList.get(0), + TraceBackRepository.CATEGORY_INCONSISTENCY, + "Not the same operation type" + ); + } + BigDecimal totalAmount = BigDecimal.ZERO; + totalAmount = voucherList.stream().map(PaymentVoucher::getPaidAmount).reduce(BigDecimal.ZERO,BigDecimal::add); + + PaymentVoucher paymentVoucher = voucherList.get(0); + Partner payerPartner = paymentVoucher.getPartner(); + PaymentMode paymentMode = paymentVoucher.getPaymentMode(); + Company company = paymentVoucher.getCompany(); + BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails(); + Journal journal = paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails); + LocalDate paymentDate = paymentVoucher.getPaymentEmissionDate(); + + Account paymentModeAccount = + paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails); + + if (paymentVoucher.getPaymentMode().getId() == 12 || paymentVoucher.getPaymentMode().getId() == 23) { + paymentModeAccount = + paymentVoucher.getPartner().getAccountingManagementList().get(0).getCashAccount(); + journal = paymentVoucher.getPartner().getAccountingManagementList().get(0).getJournal(); + } + + Move move = + moveService + .getMoveCreateService() + .createMoveWithPaymentVoucher( + journal, + company, + paymentVoucher, + payerPartner, + paymentDate, + paymentMode, + MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC); + + + // move.addPaymentVoucherListItem(paymentVoucher); + // paymentVoucher.setGeneratedMove(move); + paymentVoucher.setConfirmedByUser(AuthUtils.getUser()); + paymentVoucher.setConfirmationDate(LocalDate.now()); + + boolean isDebitToPay = paymentVoucherToolService.isDebitToPay(paymentVoucher); + int moveLineNo = 0; + + MoveLine moveLineAll = + moveLineService.createMoveLine( + move, + payerPartner, + paymentModeAccount, + totalAmount, + isDebitToPay, + paymentDate, + moveLineNo++, + paymentVoucher.getRef(), + null); + move.getMoveLineList().add(moveLineAll); + + Set paymentVoucherIds = new HashSet(); + + for (PayVoucherElementToPay voucherElementToPay : elementToPays) { + MoveLine line = moveLineService.createMoveLine( + move, + payerPartner, + voucherElementToPay.getMoveLine().getAccount(), + voucherElementToPay.getAmountToPay(), + !isDebitToPay, + paymentDate, + moveLineNo++, + voucherElementToPay.getPaymentVoucher().getRef(), + null); + move.addMoveLineListItem(line); + paymentVoucherIds.add(voucherElementToPay.getPaymentVoucher().getId()); + } + for (Long voucherId : paymentVoucherIds) { + PaymentVoucher voucher = Beans.get(PaymentVoucherRepository.class).find(voucherId); + System.out.println(":::::::::::::::::::>"); + System.out.println(paymentVoucherIds); + System.out.println(voucher.getGeneratedMoveList()); + System.out.println(":::::::::::::::::::>"); + move.addPaymentVoucherListItem(voucher); + // voucher.addGeneratedMoveListItem(move); + voucher.setConfirmedByUser(AuthUtils.getUser()); + voucher.setConfirmationDate(LocalDate.now()); + paymentVoucher.setStatusSelect(PaymentVoucherRepository.STATUS_CONFIRMED); + } + return move; + } + return null; + } + + public boolean samePaymentVoucherSelect(List voucherList){ + Integer operationTypeSelect = voucherList.get(0).getOperationTypeSelect(); + BankDetails bankDetails = voucherList.get(0).getCompanyBankDetails(); + Partner partner = voucherList.get(0).getPartner(); + for (int index = 1; index < voucherList.size(); index++) { + PaymentVoucher paymentVoucher = voucherList.get(index); + if(paymentVoucher.getOperationTypeSelect() != operationTypeSelect || paymentVoucher.getPartner() != partner || paymentVoucher.getCompanyBankDetails() != bankDetails){ + return false; + } + } + return true; + } + + public boolean voucherAlreadyInMove(List voucherList) { + if(voucherList != null){ + for (PaymentVoucher voucher : voucherList) { + if(voucher.getGeneratedMoveList().size() > 0){ + return true; + } + } + } + return false; + } + + + // Cash mvt + + @Transactional(rollbackOn = {Exception.class}) + public void confirmCashPayment(PaymentVoucher paymentVoucher) throws AxelorException { + PaymentMode paymentMode = paymentVoucher.getPaymentMode(); + Company company = paymentVoucher.getCompany(); + AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(company); + + Journal journal = accountConfig.getCashJournal(); + // LocalDate paymentDate = paymentVoucher.getPaymentDate(); + LocalDate paymentDate = paymentVoucher.getPaymentEmissionDate(); + + + + boolean scheduleToBePaid = false; + Account paymentModeAccount = paymentVoucher.getPartner().getAccountingSituationList().get(0).getPartnerPaymentAccount(); + + Move move = + moveService + .getMoveCreateService() + .createMoveWithPaymentVoucher( + journal, + company, + paymentVoucher, + null, + paymentDate, + paymentMode, + MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC); + + move.setPaymentVoucher(paymentVoucher); + + Boolean isDebitToPay = false; + + if(Integer.parseInt(paymentVoucher.getDebitCreditSelect()) == 1){ + isDebitToPay = true; + } + + System.out.println(paymentVoucher.getDebitCreditSelect().toString()); + System.out.println(isDebitToPay); + System.out.println("*******************999*********"); + + + Account accountToPay = accountConfig.getCashAccount(); + + BigDecimal paidAmount = paymentVoucher.getPaidAmount(); + + int moveLineNo = 1; + + MoveLine moveLine2 = + moveLineService.createMoveLine( + move, + null, + accountToPay, + paidAmount, + !isDebitToPay, + paymentDate, + moveLineNo++, + paymentVoucher.getRef(), + null); + + MoveLine moveLine = + moveLineService.createMoveLine( + move, + null, + paymentModeAccount, + paidAmount, + isDebitToPay, + paymentDate, + moveLineNo++, + paymentVoucher.getRef(), + null); + + move.getMoveLineList().add(moveLine); + move.getMoveLineList().add(moveLine2); + + moveService.getMoveValidateService().validate(move); + paymentVoucher.setGeneratedMove(move); + paymentVoucher.addGeneratedMoveListItem(move); + + if (isDebitToPay) { + reconcileService.balanceCredit(moveLine); + } + // Beans.get(PaymentVoucherLoadService.class).updateVoucher(paymentVoucher); + } + + + } diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherCreateService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherCreateService.java index 61dacec..9db6168 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherCreateService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherCreateService.java @@ -120,7 +120,7 @@ public class PaymentVoucherCreateService { paymentVoucherRepository.save(paymentVoucher); - paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher); + paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher, true); return paymentVoucher; } diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherLoadService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherLoadService.java index 02bd6bb..37a267c 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherLoadService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherLoadService.java @@ -18,6 +18,7 @@ package com.axelor.apps.account.service.payment.paymentvoucher; import com.axelor.apps.account.db.Account; +import com.axelor.apps.account.db.AccountingSituation; import com.axelor.apps.account.db.Invoice; import com.axelor.apps.account.db.Move; import com.axelor.apps.account.db.MoveLine; @@ -28,6 +29,7 @@ import com.axelor.apps.account.db.repo.InvoiceRepository; import com.axelor.apps.account.db.repo.MoveLineRepository; import com.axelor.apps.account.db.repo.MoveRepository; import com.axelor.apps.account.db.repo.PayVoucherDueElementRepository; +import com.axelor.apps.account.db.repo.PayVoucherElementToPayRepository; import com.axelor.apps.account.db.repo.PaymentVoucherRepository; import com.axelor.apps.account.exception.IExceptionMessage; import com.axelor.apps.base.db.BankDetails; @@ -46,12 +48,14 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; public class PaymentVoucherLoadService { protected CurrencyService currencyService; protected PaymentVoucherToolService paymentVoucherToolService; protected PayVoucherDueElementRepository payVoucherDueElementRepo; + protected PayVoucherElementToPayRepository elementToPayRepository; protected PaymentVoucherRepository paymentVoucherRepository; @Inject @@ -59,11 +63,13 @@ public class PaymentVoucherLoadService { CurrencyService currencyService, PaymentVoucherToolService paymentVoucherToolService, PayVoucherDueElementRepository payVoucherDueElementRepo, + PayVoucherElementToPayRepository elementToPayRepository, PaymentVoucherRepository paymentVoucherRepository) { this.currencyService = currencyService; this.paymentVoucherToolService = paymentVoucherToolService; this.payVoucherDueElementRepo = payVoucherDueElementRepo; + this.elementToPayRepository = elementToPayRepository; this.paymentVoucherRepository = paymentVoucherRepository; } @@ -82,18 +88,33 @@ public class PaymentVoucherLoadService { List moveLines = null; String query = - "self.partner = ?1 " - + "and self.account.useForPartnerBalance = 't' " +"self.account.useForPartnerBalance = 't' " + "and self.amountRemaining > 0 " + "and (self.move.statusSelect = ?3 OR self.move.statusSelect = ?4)" + "and self.move.ignoreInDebtRecoveryOk = 'f' " - + "and self.move.company = ?2 " - + "and self.move.invoice.pfpValidateStatusSelect != ?5"; + + "and self.move.company = ?2 "; + - if (paymentVoucherToolService.isDebitToPay(paymentVoucher)) { - query += " and self.debit > 0 "; - } else { - query += " and self.credit > 0 "; + if (paymentVoucher.getOperationTypeSelect() == PaymentVoucherRepository.OTHER){ + AccountingSituation accountingSituation = paymentVoucher.getPartner().getAccountingSituationList().get(0); + query += " and self.account.id = "+accountingSituation.getPartnerPaymentAccount().getId(); + if(accountingSituation.getDiretion() == 1){ + query += " and self.debit > 0"; + }else{ + query += " and self.credit > 0"; + } + }else{ + query += " and self.move.invoice.pfpValidateStatusSelect != ?5 AND self.partner = ?1"; + if (paymentVoucher.getOperationTypeSelect() + != PaymentVoucherRepository.OPERATION_TYPE_CLIENT_SALE_CLIENT_REFUND + && paymentVoucher.getOperationTypeSelect() + != PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_PURCHASE_SUPPLIER_REFUND) { + if (paymentVoucherToolService.isDebitToPay(paymentVoucher)) { + query += " and self.debit > 0 "; + } else { + query += " and self.credit > 0 "; + } + } } moveLines = @@ -198,16 +219,25 @@ public class PaymentVoucherLoadService { PaymentVoucher paymentVoucher, PaymentVoucher paymentVoucherContext) throws AxelorException { int sequence = paymentVoucher.getPayVoucherElementToPayList().size() + 1; + BigDecimal amountRemaining = paymentVoucher.getRemainingAmount(); + List dueElements = paymentVoucherContext.getPayVoucherDueElementList(); + + int sizeInvoiced = dueElements.stream().filter(t -> t.getMoveLine().getMove().getInvoice() == null).collect(Collectors.toList()).size(); + System.out.println("sizeInvoiced : {}"+sizeInvoiced); + if(sizeInvoiced == 0){ + dueElements.sort((o1, o2) -> o2.getMoveLine().getMove().getInvoice().getInvoiceId().compareTo(o1.getMoveLine().getMove().getInvoice().getInvoiceId())); + } - for (PayVoucherDueElement payVoucherDueElementContext : - paymentVoucherContext.getPayVoucherDueElementList()) { + for (PayVoucherDueElement payVoucherDueElementContext : dueElements) { PayVoucherDueElement payVoucherDueElement = payVoucherDueElementRepo.find(payVoucherDueElementContext.getId()); if (payVoucherDueElementContext.isSelected()) { paymentVoucher.addPayVoucherElementToPayListItem( - this.createPayVoucherElementToPay(payVoucherDueElement, sequence++)); + this.createPayVoucherElementToPay(payVoucherDueElement, sequence++,amountRemaining)); + + amountRemaining = amountRemaining.subtract(amountRemaining.min(payVoucherDueElement.getAmountRemaining())); // Remove the line from the due elements lists paymentVoucher.removePayVoucherDueElementListItem(payVoucherDueElement); @@ -216,10 +246,10 @@ public class PaymentVoucherLoadService { } public PayVoucherElementToPay createPayVoucherElementToPay( - PayVoucherDueElement payVoucherDueElement, int sequence) throws AxelorException { + PayVoucherDueElement payVoucherDueElement, int sequence,BigDecimal amountRemaining) throws AxelorException { PaymentVoucher paymentVoucher = payVoucherDueElement.getPaymentVoucher(); - BigDecimal amountRemaining = paymentVoucher.getRemainingAmount(); + // BigDecimal amountRemaining = paymentVoucher.getRemainingAmount(); LocalDate paymentDate = paymentVoucher.getPaymentDate(); PayVoucherElementToPay payVoucherElementToPay = new PayVoucherElementToPay(); @@ -388,6 +418,8 @@ public class PaymentVoucherLoadService { } int sequence = 0; + BigDecimal amountRemaining = paymentVoucher.getRemainingAmount(); + for (Iterator it = paymentVoucher.getPayVoucherDueElementList().iterator(); @@ -397,9 +429,49 @@ public class PaymentVoucherLoadService { if (invoice.equals(payVoucherDueElement.getMoveLine().getMove().getInvoice()) && paymentVoucher.getCurrency().equals(payVoucherDueElement.getCurrency())) { paymentVoucher.addPayVoucherElementToPayListItem( - createPayVoucherElementToPay(payVoucherDueElement, ++sequence)); + createPayVoucherElementToPay(payVoucherDueElement, ++sequence,amountRemaining)); + amountRemaining = amountRemaining.subtract(amountRemaining.min(payVoucherDueElement.getAmountRemaining())); + it.remove(); } } } + + + @Transactional(rollbackOn = {Exception.class}) + public void updateVoucher(PaymentVoucher paymentVoucher) throws AxelorException{ + List moveLines = new ArrayList<>(); + List payVoucherElementToPayList = paymentVoucher.getPayVoucherElementToPayList(); + + for (PayVoucherElementToPay elementToPay : payVoucherElementToPayList) { + moveLines.add(elementToPay.getMoveLine()); + } + + List elementToPays = elementToPayRepository.all().filter("self.paymentVoucher.id != ?1 and self.moveLine in (?2)",paymentVoucher.getId(),moveLines).fetch(); + + for (PayVoucherElementToPay payVoucherElementToPay : elementToPays) { + Move move = payVoucherElementToPay.getMoveLine().getMove(); + MoveLine moveLine = payVoucherElementToPay.getMoveLine(); + + payVoucherElementToPay.setTotalAmount(moveLine.getCurrencyAmount()); + + BigDecimal paidAmountInElementCurrency = + currencyService + .getAmountCurrencyConvertedAtDate( + move.getCompanyCurrency(), + move.getCurrency(), + moveLine.getAmountPaid(), + moveLine.getDate()) + .setScale(2, RoundingMode.HALF_EVEN); + + + + payVoucherElementToPay.setRemainingAmount( + moveLine.getCurrencyAmount().subtract(paidAmountInElementCurrency)); + + elementToPayRepository.save(payVoucherElementToPay); + } + + } + } diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherSequenceService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherSequenceService.java index 986b1bc..43ea508 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherSequenceService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherSequenceService.java @@ -56,10 +56,12 @@ public class PaymentVoucherSequenceService { PaymentMode paymentMode = paymentVoucher.getPaymentMode(); Company company = paymentVoucher.getCompany(); + // Sequence seq = Beans.get(SequenceRepository.class).find(new Long("126")); return sequenceService.getSequenceNumber( paymentModeService.getPaymentModeSequence( paymentMode, company, paymentVoucher.getCompanyBankDetails())); + // return sequenceService.getSequenceNumber(seq); } public void setReceiptNo(PaymentVoucher paymentVoucher, Company company, Journal journal) { diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherToolService.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherToolService.java index 68056c9..3204f5a 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherToolService.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/service/payment/paymentvoucher/PaymentVoucherToolService.java @@ -17,7 +17,9 @@ */ package com.axelor.apps.account.service.payment.paymentvoucher; +import com.axelor.apps.account.db.Invoice; import com.axelor.apps.account.db.PaymentVoucher; +import com.axelor.apps.account.db.repo.InvoiceRepository; import com.axelor.apps.account.db.repo.PaymentVoucherRepository; import com.axelor.apps.account.exception.IExceptionMessage; import com.axelor.exception.AxelorException; @@ -40,12 +42,18 @@ public class PaymentVoucherToolService { case PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_PURCHASE: isDebitToPay = false; break; + case PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_PURCHASE_SUPPLIER_REFUND: + isDebitToPay = false; + break; case PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_REFUND: isDebitToPay = true; break; case PaymentVoucherRepository.OPERATION_TYPE_CLIENT_SALE: isDebitToPay = true; break; + case PaymentVoucherRepository.OPERATION_TYPE_CLIENT_SALE_CLIENT_REFUND: + isDebitToPay = true; + break; case PaymentVoucherRepository.OPERATION_TYPE_CLIENT_REFUND: isDebitToPay = false; break; @@ -61,6 +69,40 @@ public class PaymentVoucherToolService { return isDebitToPay; } + public boolean isDebitToPay(Invoice invoice) throws AxelorException { + boolean isDebitToPay; + + switch (invoice.getOperationTypeSelect()) { + case InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE: + isDebitToPay = false; + break; + case InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND: + isDebitToPay = true; + break; + case InvoiceRepository.OPERATION_TYPE_CLIENT_SALE: + isDebitToPay = true; + break; + case PaymentVoucherRepository.OPERATION_TYPE_CLIENT_SALE_CLIENT_REFUND: + isDebitToPay = true; + break; + case PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_PURCHASE_SUPPLIER_REFUND: + isDebitToPay = false; + break; + case InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND: + isDebitToPay = false; + break; + + default: + throw new AxelorException( + invoice, + TraceBackRepository.CATEGORY_MISSING_FIELD, + I18n.get(IExceptionMessage.INVOICE_GENERATOR_1), + invoice.getInvoiceId()); + } + + return isDebitToPay; + } + /** * @param paymentVoucher : Une saisie Paiement *

OperationTypeSelect 1 : Achat fournisseur 2 : Avoir fournisseur 3 : Vente client 4 : @@ -76,12 +118,18 @@ public class PaymentVoucherToolService { case PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_PURCHASE: isPurchase = true; break; + case PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_PURCHASE_SUPPLIER_REFUND: + isPurchase = true; + break; case PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_REFUND: isPurchase = true; break; case PaymentVoucherRepository.OPERATION_TYPE_CLIENT_SALE: isPurchase = false; break; + case PaymentVoucherRepository.OPERATION_TYPE_CLIENT_SALE_CLIENT_REFUND: + isPurchase = false; + break; case PaymentVoucherRepository.OPERATION_TYPE_CLIENT_REFUND: isPurchase = false; break; diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/CashInventoryController.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/CashInventoryController.java new file mode 100644 index 0000000..7a89f1f --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/CashInventoryController.java @@ -0,0 +1,109 @@ +package com.axelor.apps.account.web; + +import java.lang.invoke.MethodHandles; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.axelor.apps.ReportFactory; +import com.axelor.apps.account.db.CashInventory; +import com.axelor.apps.account.db.PaymentVoucher; +import com.axelor.apps.account.db.repo.CashInventoryRepository; +import com.axelor.apps.account.db.repo.PaymentVoucherRepository; +import com.axelor.apps.account.report.IReport; +import com.axelor.apps.account.service.CashInventoryService; +import com.axelor.apps.base.service.ConvertNumberToFrenchWordsService; +import com.axelor.exception.AxelorException; +import com.axelor.i18n.I18n; +import com.axelor.inject.Beans; +import com.axelor.meta.schema.actions.ActionView; +import com.axelor.rpc.ActionRequest; +import com.axelor.rpc.ActionResponse; +import com.google.common.base.Strings; + +public class CashInventoryController { + + private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + public void printCashInventory(ActionRequest request, ActionResponse response) + throws AxelorException { + + CashInventory cashInventory = request.getContext().asType(CashInventory.class); + + String name = I18n.get("Cash"); + if (!Strings.isNullOrEmpty(cashInventory.getRef())) { + name += " " + cashInventory.getRef(); + } + + String fileLink = + ReportFactory.createReport(String.format(IReport.CASH_INVENTORY, cashInventory.getOperationTypeSelect()), name + "-${date}") + .addParam("cashInventoryId", cashInventory.getId()) + .generate() + .getFileLink(); + + logger.debug("Printing " + name); + + response.setView(ActionView.define(name).add("html", fileLink).map()); + } + + + public void computeGap(ActionRequest request, ActionResponse response){ + + CashInventory cashInventory = request.getContext().asType(CashInventory.class); + + String[] arrOfStr = cashInventory.getTheoricalSolde().toString().split("\\."); + + String left = Beans.get(ConvertNumberToFrenchWordsService.class).convert(Long.parseLong(arrOfStr[0])); + String right = Beans.get(ConvertNumberToFrenchWordsService.class).convert(Long.parseLong(arrOfStr[1])); + String number = left+" dinars algériens et "+right+" Cts"; + + response.setValue("theoricalSoldeInWords", number); + } + + + public void initThetoricalSoldeInWords(ActionRequest request, ActionResponse response){ + + CashInventory cashInventory = request.getContext().asType(CashInventory.class); + Beans.get(CashInventoryService.class).initThetoricalSoldeInWords(cashInventory); + + } + + + + public void computeToTals(ActionRequest request, ActionResponse response){ + + CashInventory cashInventory = request.getContext().asType(CashInventory.class); + Map map = Beans.get(CashInventoryService.class).computeToTals(cashInventory); + response.setValues(map); + + } + + public void getLastCashData(ActionRequest request, ActionResponse response){ + CashInventory lastCashInventory = Beans.get(CashInventoryRepository.class).all().order("-id").fetchOne(); + + List cashVouchers = Beans.get(PaymentVoucherRepository.class).all().filter("self.operationTypeSelect = 9 and self.cashStatusSelect = 3").fetch(); + + BigDecimal totalSolde = lastCashInventory.getPhysicalSolde(); + + for (PaymentVoucher paymentVoucher : cashVouchers) { + switch (paymentVoucher.getDebitCreditSelect()) { + case "1": + totalSolde = totalSolde.subtract(paymentVoucher.getPaidAmount()); + break; + case "2": + totalSolde = totalSolde.add(paymentVoucher.getPaidAmount()); + break; + + default: + break; + } + } + + response.setValue("theoricalSolde", totalSolde); + + } + +} diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceTemplateControlller.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceTemplateControlller.java new file mode 100644 index 0000000..6bad9e3 --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceTemplateControlller.java @@ -0,0 +1,52 @@ +package com.axelor.apps.account.web; + +import java.time.LocalDate; +import java.util.Map; + +import com.axelor.apps.account.db.Invoice; +import com.axelor.apps.account.db.InvoiceTemplate; +import com.axelor.apps.account.db.repo.InvoiceRepository; +import com.axelor.apps.account.db.repo.InvoiceTemplateRepository; +import com.axelor.apps.account.service.InvoiceTemplateService; +import com.axelor.apps.account.service.invoice.print.InvoicePrintService; +import com.axelor.apps.base.db.repo.LanguageRepository; +import com.axelor.apps.report.engine.ReportSettings; +import com.axelor.exception.AxelorException; +import com.axelor.i18n.I18n; +import com.axelor.inject.Beans; +import com.axelor.meta.schema.actions.ActionView; +import com.axelor.rpc.ActionRequest; +import com.axelor.rpc.ActionResponse; +import com.axelor.rpc.Context; + +public class InvoiceTemplateControlller { + + public void showInvoice2(ActionRequest request, ActionResponse response) + throws AxelorException { + + Context context = request.getContext(); + + InvoiceTemplate invoiceTemplate = Beans.get(InvoiceTemplateRepository.class) + .find(Long.parseLong(context.get("id").toString())); + + + Invoice invoice = Beans.get(InvoiceTemplateService.class).generateInvoiceFromTemplate(invoiceTemplate); + + System.out.println("*********************Invoice***********************"); + System.out.println(invoice); + System.out.println("*********************Invoice***********************"); + + response.setView( + ActionView.define("Invoice") + .model(Invoice.class.getName()) + .add("grid", "invoice-grid") + .add("form", "invoice-form") + .param("forceEdit", "true") + .context("_showRecord", String.valueOf(invoice.getId())) + .context("_operationTypeSelect", invoice.getOperationTypeSelect()) + .context("todayDate", LocalDate.now()) + .map()); + + } + +} diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/PayVoucherElementController.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/PayVoucherElementController.java index eaaa1a3..21d1a6b 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/PayVoucherElementController.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/PayVoucherElementController.java @@ -52,6 +52,12 @@ public class PayVoucherElementController { TraceBackService.trace(response, e); } if (amountToPayCurrency != null) { + if(elementToPay.getRemainingAmount().compareTo(amountToPayCurrency) > 0){ + BigDecimal remainingAmountAfterPayment = elementToPay.getRemainingAmount().subtract(amountToPayCurrency); + elementToPay.setRemainingAmountAfterPayment(remainingAmountAfterPayment); + }else{ + elementToPay.setRemainingAmountAfterPayment(BigDecimal.ZERO); + } elementToPay.setAmountToPayCurrency(amountToPayCurrency); Beans.get(PayVoucherElementToPayRepository.class).save(elementToPay); response.setReload(true); diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/PaymentVoucherController.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/PaymentVoucherController.java index 712659d..081fa9c 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/PaymentVoucherController.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/PaymentVoucherController.java @@ -29,19 +29,26 @@ import com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherSequ import com.axelor.apps.base.db.BankDetails; import com.axelor.apps.base.db.Company; import com.axelor.apps.base.db.Partner; +import com.axelor.apps.base.db.Wizard; import com.axelor.apps.base.db.repo.PartnerRepository; import com.axelor.apps.base.service.BankDetailsService; +import com.axelor.apps.base.service.administration.SequenceService; import com.axelor.db.mapper.Mapper; import com.axelor.exception.AxelorException; import com.axelor.exception.service.TraceBackService; import com.axelor.i18n.I18n; import com.axelor.inject.Beans; import com.axelor.meta.schema.actions.ActionView; +import com.axelor.meta.schema.actions.ActionView.ActionViewBuilder; import com.axelor.rpc.ActionRequest; import com.axelor.rpc.ActionResponse; import com.google.common.base.Strings; import com.google.inject.Singleton; import java.lang.invoke.MethodHandles; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,9 +65,13 @@ public class PaymentVoucherController { PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class); if (Strings.isNullOrEmpty(paymentVoucher.getRef())) { - - response.setValue( + if(paymentVoucher.getOperationTypeSelect() == 9){ + response.setValue( + "ref", Beans.get(SequenceService.class).getSequenceNumber("CashSequence", paymentVoucher.getCompany())); + }else{ + response.setValue( "ref", Beans.get(PaymentVoucherSequenceService.class).getReference(paymentVoucher)); + } } } @@ -94,6 +105,129 @@ public class PaymentVoucherController { } } + public void setPaidAmount(ActionRequest request, ActionResponse response) { + PaymentVoucher paymentVoucherContext = request.getContext().asType(PaymentVoucher.class); + + Map map = new HashMap<>(); + BigDecimal total = BigDecimal.ZERO; + BigDecimal remaining = BigDecimal.ZERO; + if (paymentVoucherContext.getOperationTypeSelect() + == PaymentVoucherRepository.OPERATION_TYPE_CLIENT_SALE_CLIENT_REFUND + || paymentVoucherContext.getOperationTypeSelect() + == PaymentVoucherRepository.OPERATION_TYPE_SUPPLIER_PURCHASE_SUPPLIER_REFUND) { + map = + Beans.get(PaymentVoucherConfirmService.class).processSaleAndRefund(paymentVoucherContext); + for (PayVoucherDueElement each : paymentVoucherContext.getPayVoucherDueElementList()) { + if (each.isSelected()) { + total = + total.add( + each.getMoveLine() + .getDebit() + .subtract(each.getMoveLine().getCredit()) + .subtract(each.getPaidAmount())); + } + } + remaining = paymentVoucherContext.getPaidAmount().subtract(total).abs(); + } else { + for (PayVoucherDueElement each : paymentVoucherContext.getPayVoucherDueElementList()) { + if (each.isSelected()) { + total = total.add(each.getAmountRemaining()); + } + } + } + if (paymentVoucherContext.getPaidAmount().compareTo(BigDecimal.ZERO) == 0 + || paymentVoucherContext.getPaidAmount() == null) { + response.setValue("paidAmount", total.abs()); + } + response.setValue("remainingAmount", remaining); + } + + public void computeRemainingAmount(ActionRequest request, ActionResponse response) { + PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class); + BigDecimal remaining = BigDecimal.ZERO; + BigDecimal totalElementToPay = BigDecimal.ZERO; + + if (paymentVoucher.getPaidAmount().signum() != 0) { + if (paymentVoucher.getPayVoucherElementToPayList() != null + || !paymentVoucher.getPayVoucherElementToPayList().isEmpty()) { + for (PayVoucherElementToPay payVoucherElementToPay : + paymentVoucher.getPayVoucherElementToPayList()) { + if (payVoucherElementToPay != null) { + if (paymentVoucher.getOperationTypeSelect() == 6) { + totalElementToPay = + totalElementToPay.add( + payVoucherElementToPay + .getMoveLine() + .getDebit() + .subtract(payVoucherElementToPay.getMoveLine().getCredit())); + } else { + totalElementToPay = + totalElementToPay.add(payVoucherElementToPay.getAmountToPayCurrency()); + } + } + } + } + remaining = paymentVoucher.getPaidAmount().subtract(totalElementToPay); + } else { + remaining = totalElementToPay; + } + if (remaining.compareTo(BigDecimal.ZERO) < 0) { + remaining = BigDecimal.ZERO; + } + response.setValue("remainingAmount", remaining); + } + + public void confirmRejectView(ActionRequest request, ActionResponse response) { + PaymentVoucher paymentVoucherContext = request.getContext().asType(PaymentVoucher.class); + PaymentVoucher paymentVoucher = + Beans.get(PaymentVoucherRepository.class).find(paymentVoucherContext.getId()); + + ActionViewBuilder confirmView = + ActionView.define("Confirm rejection") + .model(Wizard.class.getName()) + .add("form", "action-payment-voucher-rejection-form") + .param("popup", "true") + .param("show-toolbar", "false") + .param("show-confirm", "false") + .param("popup-save", "false") + .param("forceEdit", "true"); + + confirmView.context("paymentVoucherId", paymentVoucher.getId()); + response.setView(confirmView.map()); + } + + public void rejectPaymentVoucher(ActionRequest request, ActionResponse response) + throws AxelorException { + + int paymentVoucherId = (int) request.getContext().get("paymentVoucherId"); + String rejectionRaison = (String) request.getContext().get("rejectionRaison"); + String rejectionInstance = (String) request.getContext().get("$rejectedInstanceSelect"); + PaymentVoucher paymentVoucher = + Beans.get(PaymentVoucherRepository.class).find((long) paymentVoucherId); + + // PaymentVoucher paymentVoucherCon text2 = + // request.getContext().getParent().asType(PaymentVoucher.class); + logger.debug( + "paymentVoucherId {} rejectionRaison {} paymentVoucher {} rejectionInstance {}", + paymentVoucherId, + rejectionRaison, + paymentVoucher, + rejectionInstance); + + PaymentVoucher paymentVoucher2 =Beans.get(PaymentVoucherConfirmService.class) + .rejectPaymentVoucher(paymentVoucher, rejectionRaison); + + // response.setReload(true); + response.setView( + ActionView.define("PaymentVoucher") + .model(PaymentVoucher.class.getName()) + .add("form", "payment-voucher-cashing-form") + .add("grid", "payment-voucher-grid") + .context("_showRecord", paymentVoucher2.getId().toString()) + .domain("self.id = " + paymentVoucher2.getId()) + .map()); + } + // Reset imputation public void resetImputation(ActionRequest request, ActionResponse response) { @@ -136,7 +270,48 @@ public class PaymentVoucherController { paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(paymentVoucher.getId()); try { - Beans.get(PaymentVoucherConfirmService.class).confirmPaymentVoucher(paymentVoucher); + Beans.get(PaymentVoucherConfirmService.class).confirmPaymentVoucher(paymentVoucher, false); + response.setReload(true); + } catch (Exception e) { + TraceBackService.trace(response, e); + } + } + + // Confirm the payment voucher + public void confirmPaymentVoucherFinal(ActionRequest request, ActionResponse response) { + + PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class); + paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(paymentVoucher.getId()); + + try { + Beans.get(PaymentVoucherConfirmService.class).confirmPaymentVoucher(paymentVoucher, true); + response.setReload(true); + } catch (Exception e) { + TraceBackService.trace(response, e); + } + } + + // Confirm the payment voucher + public void confirmOtherPayment(ActionRequest request, ActionResponse response) { + + PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class); + paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(paymentVoucher.getId()); + + try { + Beans.get(PaymentVoucherConfirmService.class).confirmOtherPayment(paymentVoucher); + response.setReload(true); + } catch (Exception e) { + TraceBackService.trace(response, e); + } + } + + public void confirmCashPayment(ActionRequest request, ActionResponse response) { + + PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class); + paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(paymentVoucher.getId()); + + try { + Beans.get(PaymentVoucherConfirmService.class).confirmCashPayment(paymentVoucher); response.setReload(true); } catch (Exception e) { TraceBackService.trace(response, e); @@ -204,4 +379,87 @@ public class PaymentVoucherController { TraceBackService.trace(response, e); } } + + public void confirmMultipleVoucher(ActionRequest request,ActionResponse response) throws AxelorException { + List voucherList = new ArrayList<>(); + List elementToPays = new ArrayList<>(); + + @SuppressWarnings("unchecked") + List idList = (List) request.getContext().get("_ids"); + + for (Integer id : idList) { + PaymentVoucher paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(id.longValue()); + voucherList.add(paymentVoucher); + elementToPays.addAll(paymentVoucher.getPayVoucherElementToPayList()); + } + Move move = Beans.get(PaymentVoucherConfirmService.class).confirmMultipleVoucher(voucherList, elementToPays,true); + + response.setView( + ActionView.define(I18n.get("Move")) + .model(Move.class.getName()) + .add("grid", "move-grid") + .add("form", "move-form") + .context("_showRecord", String.valueOf(move.getId())) + .map()); + } + + public void getVoucherData(ActionRequest request,ActionResponse response) throws AxelorException { + List voucherList = new ArrayList<>(); + List elementToPays = new ArrayList<>(); + + @SuppressWarnings("unchecked") + List idList = (List) request.getContext().get("_ids"); + + BigDecimal totalVoucher = BigDecimal.ZERO; + BigDecimal totalAmount = BigDecimal.ZERO; + BigDecimal totalImputedAmount = BigDecimal.ZERO; + BigDecimal totalRemainingAmountAfterPayment = BigDecimal.ZERO; + BigDecimal totalAmountRefund = BigDecimal.ZERO; + BigDecimal totalImputedAmountRefund = BigDecimal.ZERO; + BigDecimal totalRemainingAmountAfterPaymentRefund = BigDecimal.ZERO; + + for (Integer id : idList) { + PaymentVoucher paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(id.longValue()); + voucherList.add(paymentVoucher); + elementToPays.addAll(paymentVoucher.getPayVoucherElementToPayList()); + } + + totalVoucher = voucherList.stream().map(t -> t.getPaidAmount()).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + + for (PayVoucherElementToPay elementPay : elementToPays) { + + Invoice invoice = elementPay.getMoveLine().getMove().getInvoice(); + + if( invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_FINANCIAL_REFUNDS + || invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND){ + totalImputedAmountRefund = totalImputedAmount.add(elementPay.getAmountToPay()); + totalRemainingAmountAfterPaymentRefund = totalRemainingAmountAfterPayment.add(elementPay.getRemainingAmountAfterPayment()); + totalAmountRefund = totalAmount.add(elementPay.getTotalAmount()); + }else{ + totalImputedAmount = totalImputedAmount.add(elementPay.getAmountToPay()); + totalRemainingAmountAfterPayment = totalRemainingAmountAfterPayment.add(elementPay.getRemainingAmountAfterPayment()); + totalAmount = totalAmount.add(elementPay.getTotalAmount()); + } + } + + + response.setView( + ActionView.define("Calculation") + .model(Wizard.class.getName()) + .add("form", "account-payment-voucher-calculation-wizard-form") + .param("popup", "true") + .param("show-toolbar", "false") + .param("show-confirm", "false") + .param("width", "800") + .param("popup-save", "false") + .context("_totalVoucher", totalVoucher) + .context("_totalImputedAmount", totalImputedAmount) + .context("_totalRemainingAmountAfterPayment", totalRemainingAmountAfterPayment) + .context("_totalAmount", totalAmount) + .context("_totalImputedAmountRefund", totalImputedAmountRefund) + .context("_totalRemainingAmountAfterPaymentRefund", totalRemainingAmountAfterPaymentRefund) + .context("_totalAmountRefund", totalAmountRefund) + .map()); + + } } diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/csv/script/ImportPaymentVoucher.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/csv/script/ImportPaymentVoucher.java index e957dcc..a243e74 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/csv/script/ImportPaymentVoucher.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/csv/script/ImportPaymentVoucher.java @@ -55,12 +55,12 @@ public class ImportPaymentVoucher { PayVoucherDueElement payVoucherDueElement = paymentVoucherLoadService.createPayVoucherDueElement(moveLineToPay); paymentVoucher.addPayVoucherElementToPayListItem( - paymentVoucherLoadService.createPayVoucherElementToPay(payVoucherDueElement, 1)); + paymentVoucherLoadService.createPayVoucherElementToPay(payVoucherDueElement, 1,paymentVoucher.getRemainingAmount())); } if (paymentVoucher.getStatusSelect() == PaymentVoucherRepository.STATUS_CONFIRMED) { - paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher); + paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher, false); } return paymentVoucher; } catch (Exception e) { diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Account.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Account.xml index c7b2881..32de5b7 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Account.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Account.xml @@ -28,7 +28,9 @@ - + + + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountConfig.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountConfig.xml index 7fd9a7f..88edf55 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountConfig.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountConfig.xml @@ -21,6 +21,7 @@ + @@ -37,11 +38,16 @@ + + + + + @@ -209,6 +215,7 @@ + @@ -310,4 +317,3 @@ - diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountManagement.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountManagement.xml index 7583816..bb46ab0 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountManagement.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountManagement.xml @@ -11,6 +11,7 @@ + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountingReport.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountingReport.xml index 4444723..c794c15 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountingReport.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountingReport.xml @@ -48,6 +48,9 @@ + + + + + + + + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AppAccount.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AppAccount.xml index 70d1d1d..38d3348 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AppAccount.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AppAccount.xml @@ -26,6 +26,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/CashInventory.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/CashInventory.xml new file mode 100644 index 0000000..eb8df5e --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/CashInventory.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/CashInventoryLine.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/CashInventoryLine.xml new file mode 100644 index 0000000..74e71c0 --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/CashInventoryLine.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/ClientBank.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/ClientBank.xml new file mode 100644 index 0000000..47c63de --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/ClientBank.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Invoice.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Invoice.xml index f4d5a12..9226249 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Invoice.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Invoice.xml @@ -145,6 +145,7 @@ + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceLine.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceLine.xml index d623aaf..a127bb0 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceLine.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceLine.xml @@ -86,6 +86,12 @@ public static final int PACK_PRICE_ONLY = 0; public static final int SUBLINE_PRICE_ONLY = 1; ]]> + + + + + + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceTemplate.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceTemplate.xml new file mode 100644 index 0000000..d152552 --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceTemplate.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceTemplateLine.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceTemplateLine.xml new file mode 100644 index 0000000..0d990ae --- /dev/null +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/InvoiceTemplateLine.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Move.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Move.xml index de13c5d..232aa07 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Move.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Move.xml @@ -24,6 +24,7 @@ + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/MoveLine.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/MoveLine.xml index 04a3b2c..a011b7c 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/MoveLine.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/MoveLine.xml @@ -75,7 +75,7 @@ + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/PaymentVoucher.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/PaymentVoucher.xml index b69e550..3582046 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/PaymentVoucher.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/PaymentVoucher.xml @@ -8,20 +8,26 @@ - + - + + + + + + + @@ -36,23 +42,7 @@ - - - + @@ -74,7 +64,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -84,15 +115,31 @@ public static final int STATUS_DRAFT = 1; public static final int STATUS_WAITING_FOR_DEPOSIT_SLIP = 2; public static final int STATUS_CONFIRMED = 3; + public static final int STATUS_REQUESTED = 0; + public static final int STATUS_ACCEPTED = 4; + public static final int STATUS_APPROUVED = 5; + public static final int STATUS_REJECTED = 6; + public static final int STATUS_REFUSED = 7; // OPERATION TYPE SELECT public static final int OPERATION_TYPE_SUPPLIER_PURCHASE = 1; public static final int OPERATION_TYPE_SUPPLIER_REFUND = 2; public static final int OPERATION_TYPE_CLIENT_SALE = 3; public static final int OPERATION_TYPE_CLIENT_REFUND = 4; - + public static final int OPERATION_TYPE_CLIENT_SALE_CLIENT_REFUND = 6; + public static final int OPERATION_TYPE_SUPPLIER_PURCHASE_SUPPLIER_REFUND = 7; + public static final int OTHER = 8; + public static final int CASH = 9; + ]]> + + + + Voucher created + Confirmed + + - + \ No newline at end of file diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Reconcile.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Reconcile.xml index e72e5d0..f167693 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Reconcile.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/Reconcile.xml @@ -12,6 +12,8 @@ + + diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/reports/AccountingReportType1.rptdesign b/modules/axelor-open-suite/axelor-account/src/main/resources/reports/AccountingReportType1.rptdesign index 59584d4..fc18931 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/reports/AccountingReportType1.rptdesign +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/reports/AccountingReportType1.rptdesign @@ -1,6 +1,6 @@ - Eclipse BIRT Designer Version 4.6.0.v201606072122 + Eclipse BIRT Designer Version 4.8.0.v201806261756 odaURL @@ -131,8 +131,9 @@ org.postgresql.Driver - jdbc:postgresql://localhost:5432/axelor-open-suite - axelor + jdbc:postgresql://localhost:5432/bdd_last + postgres + SWpsdj1iQl5oU0dAUFYkLDlqa2hIek8qNzQ= @@ -1979,8 +1980,16 @@ else{

+ #C0C0C0 - + + + 9.5pt + bold + auto + + + 9.5pt @@ -2397,6 +2406,7 @@ else{ 13 1 + #C0C0C0 account @@ -2404,6 +2414,7 @@ else{