temporary branch
This commit is contained in:
49
.vscode/launch.json
vendored
Normal file
49
.vscode/launch.json
vendored
Normal file
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -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
|
||||
}
|
||||
180
PyWhatKit_DB.txt
Normal file
180
PyWhatKit_DB.txt
Normal file
@@ -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
|
||||
--------------------
|
||||
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<String, BigDecimal> computeToTals(CashInventory cashInventory){
|
||||
|
||||
HashMap<String, BigDecimal> map = new HashMap<>();
|
||||
|
||||
List<CashInventoryLine> 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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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<InvoiceLine> 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<InvoiceLine> 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<InvoiceLine> creates() throws AxelorException {
|
||||
|
||||
InvoiceLine invoiceLine = this.createInvoiceLine();
|
||||
invoiceLine.setQty(BigDecimal.ONE);
|
||||
invoiceLine.setPrice(BigDecimal.ZERO);
|
||||
invoiceLine.setPriceDiscounted(BigDecimal.ZERO);
|
||||
|
||||
List<InvoiceLine> invoiceLines = new ArrayList<InvoiceLine>();
|
||||
invoiceLines.add(invoiceLine);
|
||||
|
||||
return invoiceLines;
|
||||
}
|
||||
};
|
||||
|
||||
return invoiceLineGenerator.creates();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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<reconcile> a list reconcile.
|
||||
*/
|
||||
public void addAllAndValidate(ReconcileGroup reconcileGroup, List<Reconcile> reconcileList)
|
||||
throws AxelorException;
|
||||
|
||||
/**
|
||||
* Add the reconcile and its move line to the reconcile group.
|
||||
*
|
||||
|
||||
@@ -201,6 +201,18 @@ public class ReconcileGroupServiceImpl implements ReconcileGroupService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllAndValidate(ReconcileGroup reconcileGroup, List<Reconcile> 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);
|
||||
|
||||
@@ -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<Reconcile> 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(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<MoveLine> moveLineList) throws AxelorException{
|
||||
public void reconcileMoveLinesWithCacheManagement(List<MoveLine> moveLineList)
|
||||
throws AxelorException {
|
||||
|
||||
List<MoveLine> reconciliableCreditMoveLineList = getReconciliableCreditMoveLines(moveLineList);
|
||||
List<MoveLine> reconciliableDebitMoveLineList = getReconciliableDebitMoveLines(moveLineList);
|
||||
|
||||
//pour desactiver le lettrage (Provisoire)
|
||||
BigDecimal totalDebit = BigDecimal.ZERO;
|
||||
BigDecimal totalCredit = BigDecimal.ZERO;
|
||||
// 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)
|
||||
// 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)){
|
||||
// if(totalDebit.equals(totalCredit)){
|
||||
Map<List<Object>, Pair<List<MoveLine>, List<MoveLine>>> moveLineMap = new HashMap<>();
|
||||
|
||||
populateCredit(moveLineMap, reconciliableCreditMoveLineList);
|
||||
|
||||
populateDebit(moveLineMap, reconciliableDebitMoveLineList);
|
||||
|
||||
System.out.println("************************************************");
|
||||
System.out.println(moveLineMap.toString());
|
||||
System.out.println("************************************************");
|
||||
|
||||
Comparator<MoveLine> 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<MoveLine>, List<MoveLine>> 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<MoveLine>, List<MoveLine>> moveLineLists = moveLineMap.get(keys);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<Reconcile> 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) {
|
||||
|
||||
@@ -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<Reconcile> reconciles = new ArrayList<Reconcile>();
|
||||
|
||||
@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);
|
||||
Journal journal;
|
||||
|
||||
Account paymentModeAccount =
|
||||
paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails);
|
||||
|
||||
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<? extends PayVoucherElementToPay> 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<? extends PayVoucherElementToPay> 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<? extends PayVoucherElementToPay> 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<String, BigDecimal> processSaleAndRefund(PaymentVoucher paymentVoucher) {
|
||||
List<? extends PayVoucherDueElement> payVoucherElementToPayList =
|
||||
paymentVoucher.getPayVoucherDueElementList();
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
BigDecimal remaining = BigDecimal.ZERO;
|
||||
Map<String, BigDecimal> 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<String, BigDecimal> processSaleAndRefundTotal(PaymentVoucher paymentVoucher) {
|
||||
List<? extends PayVoucherElementToPay> payVoucherElementToPayList =
|
||||
paymentVoucher.getPayVoucherElementToPayList();
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
BigDecimal remaining = BigDecimal.ZERO;
|
||||
Map<String, BigDecimal> 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<PaymentVoucher> voucherList, List<PayVoucherElementToPay> 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<Long> paymentVoucherIds = new HashSet<Long>();
|
||||
|
||||
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<PaymentVoucher> 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<PaymentVoucher> 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class PaymentVoucherCreateService {
|
||||
|
||||
paymentVoucherRepository.save(paymentVoucher);
|
||||
|
||||
paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher);
|
||||
paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher, true);
|
||||
return paymentVoucher;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<MoveLine> 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<PayVoucherDueElement> dueElements = paymentVoucherContext.getPayVoucherDueElementList();
|
||||
|
||||
for (PayVoucherDueElement payVoucherDueElementContext :
|
||||
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 : 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<PayVoucherDueElement> 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<MoveLine> moveLines = new ArrayList<>();
|
||||
List<PayVoucherElementToPay> payVoucherElementToPayList = paymentVoucher.getPayVoucherElementToPayList();
|
||||
|
||||
for (PayVoucherElementToPay elementToPay : payVoucherElementToPayList) {
|
||||
moveLines.add(elementToPay.getMoveLine());
|
||||
}
|
||||
|
||||
List<PayVoucherElementToPay> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
* <p>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;
|
||||
|
||||
@@ -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<String, BigDecimal> 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<PaymentVoucher> 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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<String, BigDecimal> 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<PaymentVoucher> voucherList = new ArrayList<>();
|
||||
List<PayVoucherElementToPay> elementToPays = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Integer> idList = (List<Integer>) 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<PaymentVoucher> voucherList = new ArrayList<>();
|
||||
List<PayVoucherElementToPay> elementToPays = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Integer> idList = (List<Integer>) 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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -28,7 +28,9 @@
|
||||
<boolean name="analyticDistributionAuthorized" title="Analytic distribution authorized" massUpdate="true"/>
|
||||
<boolean name="isTaxAuthorizedOnMoveLine" title="Tax authorized on move line" massUpdate="true"/>
|
||||
<boolean name="isTaxRequiredOnMoveLine" title="Tax required on move line" massUpdate="true"/>
|
||||
<many-to-many name="batchSet" ref="com.axelor.apps.base.db.Batch" title="Batchs"/>
|
||||
<boolean name="isUsedOnVoucher" title="Used on voucher" massUpdate="true"/>
|
||||
<many-to-many name="batchSet" ref="com.axelor.apps.base.db.Batch" title="Batchs"/>
|
||||
<boolean name="isOriginRequired" title="Is origin required" massUpdate="true"/>
|
||||
|
||||
|
||||
<track>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<many-to-one name="autoMiscOpeJournal" ref="com.axelor.apps.account.db.Journal" title="Auto Misc. Operation Journal"/>
|
||||
<many-to-one name="manualMiscOpeJournal" ref="com.axelor.apps.account.db.Journal" title="Manual Misc. Operation Journal"/>
|
||||
<many-to-one name="reportedBalanceJournal" ref="com.axelor.apps.account.db.Journal" title="Reported Balance Journal"/>
|
||||
<many-to-one name="cashJournal" ref="com.axelor.apps.account.db.Journal" title="Cash Journal"/>
|
||||
|
||||
<many-to-one name="saleJournalType" ref="com.axelor.apps.account.db.JournalType" title="Sales journal type"/>
|
||||
<many-to-one name="purchaseJournalType" ref="com.axelor.apps.account.db.JournalType" title="Purchase journal type"/>
|
||||
@@ -37,11 +38,16 @@
|
||||
<many-to-one name="employeeAccount" ref="com.axelor.apps.account.db.Account" title="Employee account"/>
|
||||
<many-to-one name="irrecoverableAccount" ref="com.axelor.apps.account.db.Account" title="Irrecoverable account"/>
|
||||
<many-to-one name="cashPositionVariationAccount" ref="com.axelor.apps.account.db.Account" title="Cashier Regulation account"/>
|
||||
<many-to-one name="taxAccount" ref="com.axelor.apps.account.db.Account" title="Tax Account"/>
|
||||
<many-to-one name="stampAccount" ref="com.axelor.apps.account.db.Account" title="Stamp Account"/>
|
||||
<many-to-one name="cashPositionVariationAccountPlus" ref="com.axelor.apps.account.db.Account" title="Cashier Regulation account plus"/>
|
||||
<many-to-one name="advancePaymentAccount" ref="com.axelor.apps.account.db.Account" title="Advance Payment Account"/>
|
||||
<many-to-one name="factorDebitAccount" ref="com.axelor.apps.account.db.Account"/>
|
||||
<many-to-one name="factorCreditAccount" ref="com.axelor.apps.account.db.Account"/>
|
||||
<many-to-one name="yearOpeningAccount" ref="com.axelor.apps.account.db.Account" title="Year opening account"/>
|
||||
<many-to-one name="yearClosureAccount" ref="com.axelor.apps.account.db.Account" title="Year closure account"/>
|
||||
<one-to-many name="accountPaymentWithoutInvoice" ref="com.axelor.apps.account.db.Account" title="Account payment without invoice"/>
|
||||
<many-to-one name="cashAccount" ref="com.axelor.apps.account.db.Account" title="Cash account"/>
|
||||
|
||||
|
||||
<!-- Automatic account creation for partners -->
|
||||
@@ -209,6 +215,7 @@
|
||||
<field name="employeeAccount" on="UPDATE"/>
|
||||
<field name="irrecoverableAccount" on="UPDATE"/>
|
||||
<field name="cashPositionVariationAccount" on="UPDATE"/>
|
||||
<field name="cashPositionVariationAccountPlus" on="UPDATE"/>
|
||||
<field name="advancePaymentAccount" on="UPDATE"/>
|
||||
<field name="factorDebitAccount" on="UPDATE"/>
|
||||
<field name="factorCreditAccount" on="UPDATE"/>
|
||||
@@ -310,4 +317,3 @@
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<many-to-one name="saleAccount" ref="com.axelor.apps.account.db.Account" title="Sale account"/>
|
||||
<many-to-one name="cashAccount" ref="com.axelor.apps.account.db.Account" title="Payment account"/>
|
||||
<many-to-one name="stockAccount" ref="com.axelor.apps.account.db.Account" title="Stock account"/>
|
||||
<many-to-one name="consumptionAccount" ref="com.axelor.apps.account.db.Account" title="Consumption account"/>
|
||||
<many-to-one name="purchFixedAssetsAccount" ref="com.axelor.apps.account.db.Account" title="Account of purchase fixed assets"/>
|
||||
|
||||
<many-to-one name="paymentMode" ref="com.axelor.apps.account.db.PaymentMode" title="Payment mode"/>
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
<boolean name="displayNameAccountColumnOnPrinting" title="Display column with accounting name"/>
|
||||
<boolean name="displayMoveLineSequenceOnPrinting" title="Display moveline sequence"/>
|
||||
|
||||
|
||||
<string name="statusSelectAccount" title="Statuses to take into account" />
|
||||
|
||||
<unique-constraint columns="ref,company"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
<many-to-one name="supplierAccount" ref="com.axelor.apps.account.db.Account" title="Supplier account"/>
|
||||
<many-to-one name="employeeAccount" ref="com.axelor.apps.account.db.Account" title="Employee account"/>
|
||||
|
||||
<!-- OTHER PAYMENTS -->
|
||||
<many-to-one name="partnerPaymentAccount" ref="com.axelor.apps.account.db.Account" title="Partner payment account"/>
|
||||
<integer name="diretion" title="Status" readonly="true" selection="iaccount.account.situation.payment.direction" default="1"/>
|
||||
|
||||
|
||||
<!-- PAGE Compte Client -->
|
||||
<decimal name="balanceCustAccount" title="Total balance" readonly="true"/>
|
||||
<decimal name="balanceDueCustAccount" title="Due balance" readonly="true"/>
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
|
||||
<boolean name="activatePassedForPayment" title="Activate passed for payment"/>
|
||||
|
||||
<integer name="supplierCodeSequence" title="Supplier code" />
|
||||
<integer name="clientCodeSequence" title="Client code" />
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="account" package="com.axelor.apps.account.db"/>
|
||||
|
||||
<entity name="CashDenomination" lang="java" cacheable="true">
|
||||
|
||||
<string name="name" title="Name" required="true"/>
|
||||
<string name="code" title="Code" required="true" hashKey="true"/>
|
||||
<integer name="typeSelect" title="Type select" selection="account.cash.denomination.type.select"/>
|
||||
<decimal name="denominationValue" title="Denomination value"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
// TTPE SELECT
|
||||
public static final int BANK_NOTE_TYPE = 1;
|
||||
public static final int COINT_TYPE = 2;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
<track>
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="denominationValue"/>
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="account" package="com.axelor.apps.account.db"/>
|
||||
|
||||
<entity name="CashInventory" lang="java">
|
||||
|
||||
<string name="ref" title="Reference" namecolumn="true" required="false"/>
|
||||
<integer name="statusSelect" title="Status" default="1" readonly="true" selection="account.cash.status.select"/>
|
||||
<integer name="operationTypeSelect" title="Payment type" required="true" selection="account.cash.operation.type.select"/>
|
||||
|
||||
<datetime name="realDate" />
|
||||
<decimal name="theoricalSolde" />
|
||||
<decimal name="physicalSolde" />
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company"/>
|
||||
<string name="amountInWords" title="Amount in words"/>
|
||||
<string name="theoricalSoldeInWords" title="Theorical solde in words"/>
|
||||
<decimal name="gap" title="Gap" />
|
||||
<decimal name="numbeLastCashPiece" title="Number of last cash piece" />
|
||||
|
||||
<many-to-one name="approvedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Approved by"/>
|
||||
<datetime name="approvalDate" title="Approval date" readonly="true"/>
|
||||
|
||||
<many-to-one name="valdiatedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Validated by"/>
|
||||
<datetime name="validattionDate" title="Validation date" readonly="true"/>
|
||||
|
||||
<decimal name="totalCoinsAmount" title="Total coins amount" />
|
||||
<decimal name="totalBankNotesAmount" title="Total bank notes amount" />
|
||||
<decimal name="totalCash" title="Total cash" />
|
||||
|
||||
|
||||
<one-to-many ref="CashInventoryLine" name="cashInventoryLines" title="Cash inventory lines"/>
|
||||
|
||||
<track>
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="denominationValue"/>
|
||||
<field name="denominationQuantity"/>
|
||||
<field name="theoricalSolde"/>
|
||||
<field name="physicalSolde"/>
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="account" package="com.axelor.apps.account.db"/>
|
||||
|
||||
<entity name="CashInventoryLine" lang="java">
|
||||
|
||||
|
||||
<many-to-one name="cashInventory" ref="CashInventory" title="Cash inventory"/>
|
||||
<many-to-one name="cashDenomination" ref="CashDenomination" title="Cash denomination"/>
|
||||
<integer name="cashCount" />
|
||||
<decimal name="totalCashCount" />
|
||||
|
||||
|
||||
|
||||
<track>
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="denominationValue"/>
|
||||
<field name="denominationQuantity"/>
|
||||
<field name="theoricalSolde"/>
|
||||
<field name="physicalSolde"/>
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="base" package="com.axelor.apps.base.db"/>
|
||||
|
||||
<entity name="ClientBank" lang="java">
|
||||
|
||||
<string name="label" namecolumn="true" title="Label" />
|
||||
<string name="ownerName" title="Owner name" max="255"/>
|
||||
<boolean name="active" title="Active" default="true"/>
|
||||
|
||||
|
||||
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -145,6 +145,7 @@
|
||||
|
||||
<!-- is approach -->
|
||||
<boolean name="isInvoiceApproach" title="Facture d'approche" />
|
||||
<boolean name="isImportationPartnerInvoice" title="Partner invoice" />
|
||||
|
||||
<decimal name="stamp" title="stamp" scale="2" precision="20" />
|
||||
<decimal name="fixTax" title="fix Tax" scale="2" precision="20" />
|
||||
|
||||
@@ -87,6 +87,12 @@
|
||||
public static final int SUBLINE_PRICE_ONLY = 1;
|
||||
]]></extra-code>
|
||||
|
||||
|
||||
<track>
|
||||
<field name="qty" />
|
||||
<field name="price" />
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="account" package="com.axelor.apps.account.db"/>
|
||||
|
||||
<entity name="InvoiceTemplate" lang="java" cacheable="true">
|
||||
<string name="name" title="Name" required="true"/>
|
||||
<string name="code" title="Code" required="true"/>
|
||||
<many-to-one name="partner" ref="com.axelor.apps.base.db.Partner" required="true" title="Partner" />
|
||||
|
||||
<!-- <many-to-one name="invoiceTemplateType" ref="MoveTemplateType" title="Type" required="1"/> -->
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company" required="1" />
|
||||
<boolean name="isValid" title="Valid" />
|
||||
<many-to-one name="paymentMode" ref="com.axelor.apps.account.db.PaymentMode" title="Payment mode" />
|
||||
<many-to-one name="paymentCondition" ref="com.axelor.apps.account.db.PaymentCondition" title="Payment condition" />
|
||||
<one-to-many name="moveTemplateLineList" ref="InvoiceTemplateLine" mappedBy="invoiceTemplate" title="Template Invoice Lines"/>
|
||||
|
||||
<date name="endOfValidityDate" title="End of validity date"/>
|
||||
<string name="fullName" namecolumn="true" search="code,name">
|
||||
<![CDATA[
|
||||
return code+" - " + name;
|
||||
]]>
|
||||
</string>
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="account" package="com.axelor.apps.account.db"/>
|
||||
|
||||
<entity name="InvoiceTemplateLine" lang="java" cacheable="true">
|
||||
<many-to-one name="invoiceTemplate" title="Invoice template" ref="InvoiceTemplate" />
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product"/>
|
||||
<string name="productName" title="Product Name"/>
|
||||
<string name="productCode" title="Product Code"/>
|
||||
<boolean name="isValid" title="Valid"/>
|
||||
<decimal name="qty" title="Qty" precision="20" scale="2" default="1"/>
|
||||
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -24,6 +24,7 @@
|
||||
<boolean name="accountingOk" title="Exported" default="false"/>
|
||||
<many-to-one name="accountingReport" ref="com.axelor.apps.account.db.AccountingReport" title="Accounting Export"/>
|
||||
<many-to-one name="paymentVoucher" ref="com.axelor.apps.account.db.PaymentVoucher" title="Payment voucher"/>
|
||||
<one-to-many name="paymentVoucherList" ref="com.axelor.apps.account.db.PaymentVoucher" title="Payment voucher list"/>
|
||||
<many-to-one name="companyCurrency" ref="com.axelor.apps.base.db.Currency" title="Company currency"/>
|
||||
<string name="companyCurrencyCode" title="Company currency code"/>
|
||||
<many-to-one name="currency" ref="com.axelor.apps.base.db.Currency" title="Currency"/>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<string name="name" title="Name" namecolumn="true">
|
||||
<![CDATA[
|
||||
if (move != null && move.getReference() != null){
|
||||
return move.getReference() + "-" + Integer.toString(counter);
|
||||
return move.getReference() + "-" + (counter != null ? Integer.toString(counter) : "0") ;
|
||||
}
|
||||
else {
|
||||
return Integer.toString(counter);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<decimal name="payerQuality" title="Payer quality" readonly="true"/>
|
||||
|
||||
<one-to-many name="accountingSituationList" ref="com.axelor.apps.account.db.AccountingSituation" mappedBy="partner" title="Accounting situation"/>
|
||||
<one-to-many name="accountingManagementList" ref="com.axelor.apps.account.db.AccountManagement" mappedBy="partner" title="Account management"/>
|
||||
|
||||
<string name="invoiceSendingFormatSelect" title="Invoice sending media" selection="invoice.account.condition.invoice.sending.format.select"/>
|
||||
<many-to-one name="inPaymentMode" ref="com.axelor.apps.account.db.PaymentMode" title="In Payment Mode" index="false"/>
|
||||
|
||||
@@ -8,20 +8,26 @@
|
||||
<entity name="PaymentVoucher" sequential="true" lang="java">
|
||||
|
||||
<string name="ref" title="Reference" namecolumn="true" required="false"/>
|
||||
<many-to-one name="partner" title="Partner" ref="com.axelor.apps.base.db.Partner" required="true"/>
|
||||
<many-to-one name="partner" title="Partner" ref="com.axelor.apps.base.db.Partner" required="false"/>
|
||||
<many-to-one name="account" ref="com.axelor.apps.account.db.Account" title="Partner account"/>
|
||||
<many-to-one name="paymentMode" ref="com.axelor.apps.account.db.PaymentMode" title="Payment mode" required="true"/>
|
||||
<many-to-one name="accountOther" ref="com.axelor.apps.account.db.Account" title="Account other"/>
|
||||
<many-to-one name="paymentMode" ref="com.axelor.apps.account.db.PaymentMode" title="Payment mode" required="false"/>
|
||||
<many-to-one name="companyBankDetails" ref="com.axelor.apps.base.db.BankDetails" title="Company bank details"/>
|
||||
<many-to-one name="clientBanks" ref="com.axelor.apps.base.db.ClientBank" title="Client bank details"/>
|
||||
<date name="paymentDate" title="Payment date"/>
|
||||
<decimal name="paidAmount" title="Amount paid" />
|
||||
<many-to-one name="user" column="user_id" ref="com.axelor.auth.db.User" title="User" readonly="true"/>
|
||||
<many-to-one name="moveLine" ref="com.axelor.apps.account.db.MoveLine" title="Overdue moveline" />
|
||||
<many-to-one name="moveLinePay" ref="com.axelor.apps.account.db.MoveLine" title="Pay moveline" />
|
||||
<decimal name="remainingAllocatedAmount" title="Amount Remaining to allocate" />
|
||||
<decimal name="allocatedAmount" title="Allocated amount" />
|
||||
<one-to-many name="payVoucherDueElementList" ref="com.axelor.apps.account.db.PayVoucherDueElement" title="List of invoices/schedule lines with remaining amount to pay" mappedBy="paymentVoucher" />
|
||||
<one-to-many name="payVoucherElementToPayList" ref="com.axelor.apps.account.db.PayVoucherElementToPay" title="List of invoices to pay" mappedBy="paymentVoucher" />
|
||||
<integer name="statusSelect" title="Status" default="1" readonly="true" selection="iaccount.payment.voucher.status.select"/>
|
||||
<integer name="cashStatusSelect" title="Cash status" default="1" readonly="true" selection="iaccount.cash.status.select"/>
|
||||
<integer name="statusTypeSelect" title="Status" default="1" readonly="true" selection="iaccount.payment.voucher.status.type.select"/>
|
||||
<many-to-one name="generatedMove" ref="com.axelor.apps.account.db.Move" title="Generated move" readonly="true"/>
|
||||
<one-to-many name="generatedMoveList" ref="com.axelor.apps.account.db.Move" title="Generated moves" readonly="true"/>
|
||||
<boolean name="hasAutoInput" title="Auto. input." default="false"/>
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company" required="true"/>
|
||||
<string name="bankCardTransactionNumber" title="CC Transaction N°" readonly="true"/>
|
||||
@@ -36,23 +42,7 @@
|
||||
<!-- <integer name="operationTypeSelect" title="Type de saisie paiement" required="true" selection="ipayment.operation.type.select"/> -->
|
||||
<integer name="operationTypeSelect" title="Payment type" required="true" selection="iinvoice.operation.type.select"/>
|
||||
|
||||
<decimal name="remainingAmount" title="Amount remaining to allocate">
|
||||
<![CDATA[
|
||||
BigDecimal totalElementToPay = BigDecimal.ZERO;
|
||||
if (getPaidAmount().signum() != 0) {
|
||||
if (getPayVoucherElementToPayList() != null || !getPayVoucherElementToPayList().isEmpty() ) {
|
||||
for (PayVoucherElementToPay payVoucherElementToPay : getPayVoucherElementToPayList()) {
|
||||
if (payVoucherElementToPay != null) {
|
||||
totalElementToPay = totalElementToPay.add(payVoucherElementToPay.getAmountToPayCurrency());
|
||||
}
|
||||
}
|
||||
}
|
||||
return getPaidAmount().subtract(totalElementToPay);
|
||||
} else {
|
||||
return totalElementToPay;
|
||||
}
|
||||
]]>
|
||||
</decimal>
|
||||
<decimal name="remainingAmount" title="Amount remaining to allocate" />
|
||||
|
||||
<string name="chequeNumber" />
|
||||
<string name="chequeBank" />
|
||||
@@ -75,6 +65,47 @@
|
||||
<many-to-one name="recipientUser" ref="com.axelor.auth.db.User" readonly="true" title="recipient"/>
|
||||
|
||||
|
||||
<date name="invoiceDate" title="invoice Date" />
|
||||
<date name="dueDate" title="Due Date" />
|
||||
<date name="puttingtDate" title="Credit Date" />
|
||||
<!-- creadit date -->
|
||||
<date name="creditDate" title="Credit Date" />
|
||||
<date name="cagexDeadline" title="Cagex deadline" />
|
||||
<!-- date d'enlevement -->
|
||||
<date name="deliveryDate" title="Delivery Date" />
|
||||
<date name="paymentEmissionDate" title="payment emission Date" />
|
||||
|
||||
<boolean name="rejected" default="false" title="Rejected" />
|
||||
<date name="rejectedDate" title="Rejected Date" />
|
||||
<many-to-one name="rejectedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Rejected by"/>
|
||||
<integer name="rejectedInstanceSelect" title="Status" selection="iaccount.payment.voucher.rejection.status.select" />
|
||||
<decimal name="rejectAmountFee" title="Reject Amount Fee"/>
|
||||
<decimal name="amountAfterRejection" title="Amount after rejection"/>
|
||||
<string name="rejectionRaison" large="true"/>
|
||||
|
||||
<integer name="sort" title="Sort" default="1" selection="iaccount.payment.voucher.sort.select"/>
|
||||
|
||||
<!-- <string name="clientBank" title="Client bank" selection="iaccount.payment.voucher.client.bank"/> -->
|
||||
|
||||
<string name="commercialTransactionNumber" title="Commercial Transaction N°" />
|
||||
|
||||
<many-to-one name="originPaymentVoucher" ref="com.axelor.apps.account.db.PaymentVoucher" title="Payment voucher"/>
|
||||
|
||||
<many-to-one name="paymentCondition" ref="com.axelor.apps.account.db.PaymentCondition" title="Payment condition" />
|
||||
|
||||
<date name="approvalDate" title="Approval date" />
|
||||
<many-to-one name="approvedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Approved by"/>
|
||||
|
||||
<date name="refusalDate" title="Refusal date" />
|
||||
<many-to-one name="refusedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Refused by"/>
|
||||
|
||||
<!-- date reception sur service finnance -->
|
||||
<date name="receptionDateInOffice" title="Reception date in office" />
|
||||
|
||||
<many-to-one name="purchaseOrder" ref="com.axelor.apps.purchase.db.PurchaseOrder" title="Purchase Order" />
|
||||
|
||||
<string name="debitCreditSelect" title="Debit/Credit" selection="move.voucher.debit.credit.select"/>
|
||||
|
||||
<unique-constraint columns="ref,company"/>
|
||||
<unique-constraint columns="receiptNo,company"/>
|
||||
|
||||
@@ -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;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
<track>
|
||||
<field name="statusSelect"/>
|
||||
<message if="true" on="CREATE">Voucher created</message>
|
||||
<message if="statusSelect == 3" tag="important">Confirmed</message>
|
||||
</track>
|
||||
|
||||
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -12,6 +12,8 @@
|
||||
<decimal name="amount" title="Amount reconciled" default="0.0" initParam="true"/>
|
||||
<many-to-one name="debitMoveLine" ref="MoveLine" title="Debit line" required="true" initParam="true"/>
|
||||
<many-to-one name="creditMoveLine" ref="MoveLine" title="Credit line" required="true" initParam="true"/>
|
||||
<one-to-many name="debitMoveLineList" ref="MoveLine" title="Debit line list" />
|
||||
<one-to-many name="creditMoveLineList" ref="MoveLine" title="Credit line list" />
|
||||
<integer name="statusSelect" title="Status" default="1" readonly="true" selection="account.reconcile.status.select" initParam="true"/>
|
||||
<date name="reconciliationDate" title="Reconciliation date" readonly="true"/>
|
||||
<!-- Will be fully reconciled if the payment amount is with a range of +/-20 cts compare to the amount remaining to pay -->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
|
||||
<property name="createdBy">Eclipse BIRT Designer Version 4.6.0.v201606072122</property>
|
||||
<property name="createdBy">Eclipse BIRT Designer Version 4.8.0.v201806261756</property>
|
||||
<list-property name="propertyBindings">
|
||||
<structure>
|
||||
<property name="name">odaURL</property>
|
||||
@@ -131,8 +131,9 @@
|
||||
</ex-property>
|
||||
</list-property>
|
||||
<property name="odaDriverClass">org.postgresql.Driver</property>
|
||||
<property name="odaURL">jdbc:postgresql://localhost:5432/axelor-open-suite</property>
|
||||
<property name="odaUser">axelor</property>
|
||||
<property name="odaURL">jdbc:postgresql://localhost:5432/bdd_last</property>
|
||||
<property name="odaUser">postgres</property>
|
||||
<encrypted-property name="odaPassword" encryptionID="base64">SWpsdj1iQl5oU0dAUFYkLDlqa2hIek8qNzQ=</encrypted-property>
|
||||
</oda-data-source>
|
||||
</data-sources>
|
||||
<data-sets>
|
||||
@@ -1979,8 +1980,16 @@ else{
|
||||
</column>
|
||||
<header>
|
||||
<row id="4052">
|
||||
<property name="backgroundColor">#C0C0C0</property>
|
||||
<cell id="4142"/>
|
||||
<cell id="4053"/>
|
||||
<cell id="4053">
|
||||
<text id="4270">
|
||||
<property name="fontSize">9.5pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<property name="contentType">auto</property>
|
||||
<text-property name="content"><![CDATA[Ecriture]]></text-property>
|
||||
</text>
|
||||
</cell>
|
||||
<cell id="4252">
|
||||
<text id="4265">
|
||||
<property name="fontSize">9.5pt</property>
|
||||
@@ -2397,6 +2406,7 @@ else{
|
||||
<property name="colSpan">13</property>
|
||||
<property name="rowSpan">1</property>
|
||||
<data id="4115">
|
||||
<property name="backgroundColor">#C0C0C0</property>
|
||||
<property name="resultSetColumn">account</property>
|
||||
</data>
|
||||
</cell>
|
||||
@@ -2404,6 +2414,7 @@ else{
|
||||
</header>
|
||||
<footer>
|
||||
<row id="4106">
|
||||
<property name="backgroundColor">#C0C0C0</property>
|
||||
<cell id="4145"/>
|
||||
<cell id="4107">
|
||||
<property name="colSpan">7</property>
|
||||
@@ -2465,8 +2476,25 @@ else{
|
||||
<detail>
|
||||
<row id="4067">
|
||||
<method name="onCreate"><![CDATA[vars["PreviousBalance"]=row["balance"]]]></method>
|
||||
<cell id="4144"/>
|
||||
<cell id="4144">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
</cell>
|
||||
<cell id="4068">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4269">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<list-property name="visibility">
|
||||
@@ -2489,6 +2517,14 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4254">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4266">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<property name="textAlign">center</property>
|
||||
@@ -2496,6 +2532,14 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4260">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4267">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<property name="textAlign">center</property>
|
||||
@@ -2503,6 +2547,14 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4070">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4073">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<structure name="dateTimeFormat">
|
||||
@@ -2514,6 +2566,14 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4234">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4239">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<structure name="dateTimeFormat">
|
||||
@@ -2525,6 +2585,14 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4246">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4251">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<property name="textAlign">left</property>
|
||||
@@ -2532,18 +2600,42 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4072">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4071">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<property name="resultSetColumn">move_line_description</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4074">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4075">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<property name="resultSetColumn">partner</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4078">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4079">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<structure name="numberFormat">
|
||||
@@ -2555,6 +2647,14 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4080">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4081">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<structure name="numberFormat">
|
||||
@@ -2566,6 +2666,14 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4150">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4155">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<structure name="numberFormat">
|
||||
@@ -2583,6 +2691,14 @@ else{
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4222">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderLeftStyle">solid</property>
|
||||
<property name="borderLeftWidth">thin</property>
|
||||
<property name="borderRightStyle">solid</property>
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4242">
|
||||
<property name="fontSize">8.5pt</property>
|
||||
<property name="marginLeft">1pt</property>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -71,6 +71,7 @@
|
||||
<panel name="paymentDifferencesPanel" title="Payment differences" colSpan="12">
|
||||
<field name="thresholdDistanceFromRegulation"/>
|
||||
<field name="cashPositionVariationAccount" domain="self.company = :company" grid-view="account-grid" form-view="account-form"/>
|
||||
<field name="cashPositionVariationAccountPlus" domain="self.company = :company" grid-view="account-grid" form-view="account-form"/>
|
||||
</panel>
|
||||
<panel name="authorizeAutoReconcilePanel" title="Authorize auto reconcile" colSpan="12">
|
||||
<field name="autoReconcileOnInvoice"/>
|
||||
|
||||
@@ -27,4 +27,5 @@ public interface IReport {
|
||||
public static final String CLIENT_SITUATION = "ClientSituation.rptdesign";
|
||||
public static final String MESSAGE_PDF = "MessagePDF.rptdesign";
|
||||
public static final String ABC_ANALYSIS = "AbcAnalysis.rptdesign";
|
||||
public static final String MEETING = "PVMeeting.rptdesign";
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
public interface AppBaseService extends AppService {
|
||||
|
||||
public static final int DEFAULT_NB_DECIMAL_DIGITS = 2;
|
||||
public static final int DEFAULT_NB_DECIMAL_DIGITS_SUPPLIER_LINE = 2;
|
||||
|
||||
public AppBase getAppBase();
|
||||
|
||||
|
||||
@@ -166,4 +166,12 @@ public class AppBaseController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@CallMethod
|
||||
public void execWhatsApp2(String username,String message,String url,String id,String enc) throws IOException, ClassNotFoundException {
|
||||
String args[] = { "python", "/Users\\Bachir.souldi.SOPHAL\\Desktop\\dev\\whatsapp_erp\\index.py" , message, url , id };
|
||||
Process p = Runtime.getRuntime().exec(args);
|
||||
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package com.axelor.apps.base.web;
|
||||
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.axelor.apps.base.db.FamilleProduit;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.base.exceptions.IExceptionMessage;
|
||||
@@ -41,6 +42,8 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.axelor.rpc.Context;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class ProductController {
|
||||
@@ -132,4 +135,46 @@ public class ProductController {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void printProductQrCodes(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
try {
|
||||
|
||||
Context context = request.getContext();
|
||||
Long id = 1L;
|
||||
Integer typeSelect = Integer.parseInt(context.get("printingTypeSelect").toString());
|
||||
|
||||
switch (typeSelect) {
|
||||
case 1:
|
||||
id = new Long((Integer) ((Map) context.get("product")).get("id"));
|
||||
break;
|
||||
case 2:
|
||||
id = new Long((Integer) ((Map) request.getContext().get("stockLocation")).get("id"));
|
||||
break;
|
||||
case 3:
|
||||
id = ((FamilleProduit) request.getContext().get("familleProduit")).getId();
|
||||
break;
|
||||
default:
|
||||
id = 0L;
|
||||
break;
|
||||
}
|
||||
String name = I18n.get("QrCode printing");
|
||||
|
||||
String fileLink =
|
||||
ReportFactory.createReport("QrCodePrinting.rptdesign", name + "-${date}")
|
||||
.addParam("Locale", ReportSettings.getPrintingLocale(null))
|
||||
.addParam("typeSelect", typeSelect)
|
||||
.addParam("productId", id)
|
||||
.addParam("stockLocation", id)
|
||||
.addParam("familleProduit",id)
|
||||
.generate()
|
||||
.getFileLink();
|
||||
|
||||
logger.debug("Printing " + name);
|
||||
|
||||
response.setView(ActionView.define(name).add("html", fileLink).map());
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,13 @@
|
||||
<many-to-one name="purchaseTax" ref="com.axelor.apps.account.db.Tax" title="Purchase Tax"/>
|
||||
<many-to-one name="saleTax" ref="com.axelor.apps.account.db.Tax" title="Sale Tax"/>
|
||||
<many-to-one name="tax" ref="com.axelor.apps.account.db.Tax" title="Tax"/>
|
||||
<many-to-one name="partner" ref="com.axelor.apps.base.db.Partner" title="Partner" />
|
||||
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product"/>
|
||||
<many-to-one name="productFamily" ref="com.axelor.apps.base.db.ProductFamily" title="Accounting family"/>
|
||||
|
||||
<finder-method name="findByProduct" using="product"/>
|
||||
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
|
||||
@@ -82,6 +82,9 @@
|
||||
|
||||
<boolean name="enableCheckTcoAccpeted" title="Enable check TCO Accepte" />
|
||||
|
||||
<!-- roq url -->
|
||||
<string name="roqURL" title="Roq URL" />
|
||||
|
||||
<extra-code>
|
||||
<![CDATA[
|
||||
public static final int DISCOUNT_SEPARATE = 1;
|
||||
|
||||
@@ -7,9 +7,12 @@
|
||||
|
||||
<entity name="CompanyDepartment" lang="java">
|
||||
|
||||
<string name="name" title="Name"/>
|
||||
<string name="code" title="Code"/>
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company"/>
|
||||
<string name="name" title="Name"/>
|
||||
<string name="code" title="Code"/>
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company"/>
|
||||
<integer name="departmentLevel" title="Level" />
|
||||
<many-to-one name="parentDepartment" ref="com.axelor.apps.base.db.CompanyDepartment"/>
|
||||
|
||||
|
||||
</entity>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<string name="url" title="URL"/>
|
||||
<string name="subject" required="true" namecolumn="true" title="Subject"/>
|
||||
<string name="description" title="Description" large="true"/>
|
||||
<string name="decisions" title="Decisions" large="true"/>
|
||||
<string name="status" title="Status"/>
|
||||
<datetime name="startDateTime" required="true" title="Start date"/>
|
||||
<datetime name="endDateTime" required="true" title="End date"/>
|
||||
@@ -25,8 +26,11 @@
|
||||
<string name="subjectTeam"/>
|
||||
<integer name="typeSelect" title="Type" selection="icalendar.event.type.select" required="true" />
|
||||
<many-to-one name="user" column="user_id" ref="com.axelor.auth.db.User" title="Assigned to"/>
|
||||
<one-to-many name="companyDepartmentList" title="Company departments" ref="com.axelor.apps.base.db.CompanyDepartment" />
|
||||
|
||||
<finder-method name="findByUid" using="uid" />
|
||||
|
||||
|
||||
<extra-code>
|
||||
<![CDATA[
|
||||
public static final Integer VISIBILITY_PUBLIC = 1;
|
||||
|
||||
@@ -147,6 +147,10 @@
|
||||
<decimal name="stklim" title="Stklim" />
|
||||
<decimal name="ug" title="UG" />
|
||||
|
||||
<boolean name="isDangerousProduct" title="Is dangerous" />
|
||||
|
||||
<finder-method name="findByCode" using="code" cacheable="true" />
|
||||
|
||||
<extra-code>
|
||||
<![CDATA[
|
||||
// PRODUCT TYPE SELECT
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
|
||||
<integer name="stepStatusSelect" selection="base.user.form.step.select" default="0"/>
|
||||
|
||||
<many-to-one name="companyDepartment" ref="com.axelor.apps.base.db.CompanyDepartment" />
|
||||
|
||||
<finder-method name="findByCode" using="code" filter="LOWER(self.code) = LOWER(:code)"/>
|
||||
|
||||
<track>
|
||||
|
||||
@@ -24,19 +24,40 @@ import com.axelor.apps.base.service.user.UserService;
|
||||
import com.axelor.apps.base.test.UserServiceTest.MyModule;
|
||||
import com.axelor.apps.message.module.MessageModule;
|
||||
import com.axelor.apps.tool.module.ToolModule;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.auth.db.repo.UserRepository;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.test.GuiceModules;
|
||||
import com.axelor.test.GuiceRunner;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.persist.Transactional;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
||||
@RunWith(GuiceRunner.class)
|
||||
@GuiceModules({MyModule.class})
|
||||
@GuiceModules({UserServiceTest.MyModule.class})
|
||||
public class UserServiceTest {
|
||||
|
||||
static UserService userService;
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
public static class MyModule extends AxelorModule {
|
||||
|
||||
@@ -55,6 +76,13 @@ public class UserServiceTest {
|
||||
userService = Beans.get(UserService.class);
|
||||
}
|
||||
|
||||
@Inject UserRepository injector;
|
||||
|
||||
|
||||
// public void test() {
|
||||
// assertNotNull(injector.find(1L));
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testMatchPasswordPatternUpperLowerDigit() {
|
||||
Assert.assertTrue(userService.matchPasswordPattern("Axelor123"));
|
||||
@@ -96,4 +124,20 @@ public class UserServiceTest {
|
||||
Assert.assertFalse(userService.matchPasswordPattern("AxelorAxelor"));
|
||||
Assert.assertFalse(userService.matchPasswordPattern("axelor123456"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void findUser() throws AxelorException {
|
||||
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("testUnitManager");
|
||||
EntityManager entityManager = entityManagerFactory.createEntityManager();
|
||||
|
||||
// Student student = new Student("Ramesh", "Fadatare", "rameshfadatare@javaguides.com");
|
||||
// Object partner = entityManager.createNativeQuery("select u from base_partner u where u.id = 1",Partner.class).getSingleResult();
|
||||
|
||||
// log.debug("data *******************************"+ partner.toString());
|
||||
entityManager.close();
|
||||
entityManagerFactory.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
|
||||
<persistence-unit name="testUnit" transaction-type="RESOURCE_LOCAL">
|
||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||
<persistence-unit name="testUnitManager" transaction-type="RESOURCE_LOCAL">
|
||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
|
||||
<properties>
|
||||
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
|
||||
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/axelor-erp" />
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/bdd_last" />
|
||||
|
||||
<property name="javax.persistence.jdbc.user" value="axelor" />
|
||||
<property name="javax.persistence.jdbc.password" value="" />
|
||||
<property name="javax.persistence.jdbc.user" value="postgres" />
|
||||
<property name="javax.persistence.jdbc.password" value="Ijlv=bB^hSG@PV$,9jkhHzO*74" />
|
||||
|
||||
<!--
|
||||
value="create" to build a new database on each run;
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
*/
|
||||
package com.axelor.apps.crm.web;
|
||||
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.axelor.apps.base.report.IReport;
|
||||
import com.axelor.apps.base.service.MapService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.crm.db.Event;
|
||||
import com.axelor.apps.crm.db.EventReminder;
|
||||
import com.axelor.apps.crm.db.Lead;
|
||||
@@ -33,6 +36,7 @@ import com.axelor.apps.crm.service.LeadService;
|
||||
import com.axelor.apps.message.db.EmailAddress;
|
||||
import com.axelor.apps.purchase.db.ImportationFolder;
|
||||
import com.axelor.apps.purchase.db.repo.ImportationFolderRepository;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
import com.axelor.apps.tool.date.DateTool;
|
||||
import com.axelor.apps.tool.date.DurationTool;
|
||||
import com.axelor.auth.AuthUtils;
|
||||
@@ -43,6 +47,7 @@ import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
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.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.common.base.Joiner;
|
||||
@@ -566,4 +571,37 @@ public class EventController {
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
|
||||
public void openRoqApplication(ActionRequest request, ActionResponse response) {
|
||||
|
||||
|
||||
String uri = Beans.get(AppBaseService.class).getAppBase().getRoqURL();
|
||||
|
||||
LOG.debug("link {}",uri+AuthUtils.getUser().getId());
|
||||
|
||||
response.setView(
|
||||
ActionView.define(I18n.get("ROQ"))
|
||||
.model("")
|
||||
.add("html", uri +AuthUtils.getUser().getId())
|
||||
.map());
|
||||
}
|
||||
|
||||
|
||||
public void printMeeting(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
Event event = request.getContext().asType(Event.class);
|
||||
event = Beans.get(EventRepository.class).find(event.getId());
|
||||
|
||||
String eventName = I18n.get("Event");
|
||||
|
||||
String fileLink =
|
||||
ReportFactory.createReport(IReport.MEETING, event.getSubject() + "-${date}")
|
||||
.addParam("Locale", ReportSettings.getPrintingLocale())
|
||||
.addParam("meetingId", event.getId())
|
||||
.generate()
|
||||
.getFileLink();
|
||||
|
||||
|
||||
response.setView(ActionView.define(eventName).add("html", fileLink).map());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="crm" package="com.axelor.apps.crm.db"/>
|
||||
|
||||
<entity name="ActionEvent" lang="java" extends="com.axelor.apps.base.db.ICalendarEvent">
|
||||
|
||||
<!-- Commun -->
|
||||
<datetime name="limitDateT" title="Limit Date"/>
|
||||
|
||||
<long name="duration" title="Duration"/>
|
||||
|
||||
<many-to-one name="eventCategory" ref="com.axelor.apps.crm.db.EventCategory" title="Category"/>
|
||||
|
||||
<string name="relatedToSelect" title="Related to" selection="crm.event.related.to.select"/>
|
||||
<long name="relatedToSelectId"/>
|
||||
<integer name="statusSelect" title="Status" selection="crm.event.status.select"/>
|
||||
|
||||
<many-to-one name="team" ref="com.axelor.team.db.Team" title="Team"/>
|
||||
|
||||
<string name="calendarEventUid" title="UID (Calendar)"/>
|
||||
|
||||
<!-- Call -->
|
||||
<integer name="callTypeSelect" title="Call type" selection="crm.event.call.type.select"/>
|
||||
<many-to-many name="guestList" ref="com.axelor.auth.db.User" title="Guest"/>
|
||||
|
||||
<!-- Task -->
|
||||
<boolean name="isRecurrent" title="Recurrent"/>
|
||||
<many-to-one name="parentEvent" ref="com.axelor.apps.crm.db.Event"/>
|
||||
|
||||
<integer name="prioritySelect" title="Priority" selection="crm.event.priority.select" default="2"/>
|
||||
<!-- roq flags -->
|
||||
<integer name="flag" title="Flag" selection="crm.event.flag.select"/>
|
||||
|
||||
|
||||
<string name="uid" column="calendar_uid" unique="true" hashKey="false" title="UID"/>
|
||||
<string name="url" title="URL"/>
|
||||
<string name="subject" required="true" namecolumn="true" title="Subject"/>
|
||||
<string name="description" title="Description" large="true"/>
|
||||
<string name="status" title="Status"/>
|
||||
<datetime name="startDateTime" required="true" title="Start date"/>
|
||||
<datetime name="endDateTime" required="true" title="End date"/>
|
||||
<boolean name="allDay" title="All day"/>
|
||||
<string name="location" title="Location"/>
|
||||
<string name="geo" title="Geo. coordinates"/>
|
||||
|
||||
<many-to-one name="organizer" ref="com.axelor.apps.base.db.ICalendarUser" title="Organizer"/>
|
||||
<one-to-many name="attendees" ref="com.axelor.apps.base.db.ICalendarUser" title="Attendees" mappedBy="event" orphanRemoval="false"/>
|
||||
|
||||
<integer name="visibilitySelect" title="Visibility" selection="i.cal.event.visibility.select" default="1"/>
|
||||
<integer name="disponibilitySelect" title="Availability" selection="i.cal.event.disponibility.select" default="1"/>
|
||||
<string name="subjectTeam"/>
|
||||
<integer name="typeSelect" title="Type" selection="icalendar.event.type.select" required="true" />
|
||||
<many-to-one name="user" column="user_id" ref="com.axelor.auth.db.User" title="Assigned to"/>
|
||||
<finder-method name="findByUid" using="uid" />
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -31,6 +31,10 @@
|
||||
<!-- Call -->
|
||||
<integer name="callTypeSelect" title="Call type" selection="crm.event.call.type.select"/>
|
||||
|
||||
<many-to-many name="guestList" ref="com.axelor.auth.db.User" title="Guest"/>
|
||||
|
||||
<many-to-many name="presentGuestList" ref="com.axelor.auth.db.User" title="Present guests"/>
|
||||
|
||||
<!-- Task -->
|
||||
<boolean name="isRecurrent" title="Recurrent"/>
|
||||
<many-to-one name="parentEvent" ref="com.axelor.apps.crm.db.Event"/>
|
||||
@@ -40,6 +44,9 @@
|
||||
|
||||
<many-to-one name="recurrenceConfiguration" ref="com.axelor.apps.crm.db.RecurrenceConfiguration"/>
|
||||
|
||||
<many-to-many ref="com.axelor.apps.base.db.CompanyDepartment" name="departmentList" />
|
||||
<many-to-one ref="com.axelor.apps.base.db.CompanyDepartment" name="departmentEmitter" />
|
||||
|
||||
<extra-code>
|
||||
<![CDATA[
|
||||
// TYPE SELECT
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="purchase" package="com.axelor.apps.purchase.db"/>
|
||||
|
||||
<entity name="BookingService" lang="java">
|
||||
<many-to-one name="employee" ref="com.axelor.apps.hr.db.Employee" title="Employee" />
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -23,6 +23,7 @@ import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.base.service.ProductService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.production.db.BillOfMaterial;
|
||||
import com.axelor.apps.production.db.BillOfMaterialConsumption;
|
||||
import com.axelor.apps.production.db.TempBomTree;
|
||||
import com.axelor.apps.production.db.repo.BillOfMaterialRepository;
|
||||
import com.axelor.apps.production.db.repo.TempBomTreeRepository;
|
||||
@@ -49,12 +50,14 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.axelor.apps.production.db.repo.BillOfMaterialConsumptionRepository;
|
||||
|
||||
public class BillOfMaterialServiceImpl implements BillOfMaterialService {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@Inject protected BillOfMaterialRepository billOfMaterialRepo;
|
||||
@Inject protected BillOfMaterialConsumptionRepository billOfMaterialConsumptionRepository;
|
||||
|
||||
@Inject private TempBomTreeRepository tempBomTreeRepo;
|
||||
|
||||
@@ -369,4 +372,24 @@ public class BillOfMaterialServiceImpl implements BillOfMaterialService {
|
||||
|
||||
return newBom;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public BillOfMaterialConsumption createBomConsumptionFromRawMaterial(BillOfMaterial bom) {
|
||||
BillOfMaterialConsumption newBom = new BillOfMaterialConsumption();
|
||||
newBom.setDefineSubBillOfMaterial(false);
|
||||
newBom.setPriority(bom.getPriority());
|
||||
newBom.setProduct(bom.getProduct());
|
||||
newBom.setQty(bom.getQty());
|
||||
newBom.setRealQty(bom.getQty());
|
||||
newBom.setUnit(bom.getUnit());
|
||||
newBom.setName(bom.getName());
|
||||
newBom.setFullName(bom.getFullName());
|
||||
// billOfMaterialConsumptionRepository.save(newBom);
|
||||
|
||||
return newBom;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.Unit;
|
||||
import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.base.service.UnitConversionService;
|
||||
import com.axelor.apps.production.db.BillOfMaterial;
|
||||
import com.axelor.apps.production.db.ManufOrder;
|
||||
import com.axelor.apps.production.db.OperationOrder;
|
||||
@@ -36,20 +35,26 @@ import com.axelor.apps.stock.db.repo.StockLocationLineRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockLocationRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockRulesRepository;
|
||||
import com.axelor.apps.stock.service.StockLocationService;
|
||||
import com.axelor.apps.stock.service.StockLocationServiceImpl;
|
||||
import com.axelor.apps.stock.service.StockRulesService;
|
||||
import com.axelor.apps.supplychain.db.Mrp;
|
||||
import com.axelor.apps.supplychain.db.MrpForecast;
|
||||
import com.axelor.apps.supplychain.db.MrpLine;
|
||||
import com.axelor.apps.supplychain.db.MrpLineOrigin;
|
||||
import com.axelor.apps.supplychain.db.MrpLineSaleAndMargin;
|
||||
import com.axelor.apps.supplychain.db.MrpLineSophal;
|
||||
import com.axelor.apps.supplychain.db.MrpLineType;
|
||||
import com.axelor.apps.supplychain.db.ProductionMasterPlan;
|
||||
import com.axelor.apps.supplychain.db.repo.MrpForecastRepository;
|
||||
import com.axelor.apps.supplychain.db.repo.MrpLineRepository;
|
||||
import com.axelor.apps.supplychain.db.repo.MrpLineSaleAndMarginRepository;
|
||||
import com.axelor.apps.supplychain.db.repo.MrpLineSophalRepository;
|
||||
import com.axelor.apps.supplychain.db.repo.MrpLineTypeRepository;
|
||||
import com.axelor.apps.supplychain.db.repo.MrpRepository;
|
||||
import com.axelor.apps.supplychain.db.repo.ProductionMasterPlanRepository;
|
||||
import com.axelor.apps.supplychain.service.MrpLineService;
|
||||
import com.axelor.apps.supplychain.service.MrpServiceImpl;
|
||||
import com.axelor.apps.supplychain.service.ProductStockLocationServiceImpl;
|
||||
import com.axelor.apps.tool.StringTool;
|
||||
import com.axelor.db.JPA;
|
||||
import com.axelor.exception.AxelorException;
|
||||
@@ -60,11 +65,15 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.mozilla.universalchardet.prober.statemachine.Big5SMModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -450,104 +459,245 @@ public class MrpServiceProductionImpl extends MrpServiceImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createAvailableMrpLineSophal(Mrp mrp) throws AxelorException{
|
||||
public void createAvailableMrpLineSophal(Mrp mrp) throws AxelorException {
|
||||
log.debug("MRP PROD >>>>");
|
||||
super.createAvailableMrpLineSophal(mrp);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void createMrpLineSophal(Mrp mrp, Product product,Unit unit,BigDecimal qty,List<MrpForecast> mrpForecastList, Map<Long, Double> productQty) throws AxelorException{
|
||||
public void createMrpLineSophal(
|
||||
Mrp mrp,
|
||||
Product product,
|
||||
Unit unit,
|
||||
BigDecimal qty,
|
||||
List<MrpForecast> mrpForecastList,
|
||||
Map<Long, Double> productQty)
|
||||
throws AxelorException {
|
||||
|
||||
if(mrp.getIncludeBOM()){
|
||||
|
||||
log.debug("****** FORTHUPPER ******** {} {}",product,qty);
|
||||
|
||||
|
||||
if (mrp.getIncludeBOM()) {
|
||||
|
||||
BillOfMaterial defaultBillOfMaterial = product.getDefaultBillOfMaterial();
|
||||
|
||||
if (defaultBillOfMaterial != null) {
|
||||
|
||||
super.createdProductionMasterPlan(product, mrp, qty, defaultBillOfMaterial.getQty());
|
||||
|
||||
|
||||
for (BillOfMaterial billOfMaterial : defaultBillOfMaterial.getBillOfMaterialSet()) {
|
||||
List<MrpForecast> forecastList = mrpForecastList.stream().filter(t -> t.getProduct() == product).collect(Collectors.toList());
|
||||
List<ProductionMasterPlan> productionMasterPlans = Beans.get(ProductionMasterPlanRepository.class).all().fetchStream()
|
||||
.filter(t -> t.getProduct() == product && t.getMrp() == mrp).collect(Collectors.toList());
|
||||
|
||||
Product subProduct = billOfMaterial.getProduct();
|
||||
Product subProduct = billOfMaterial.getProduct();
|
||||
|
||||
if (this.isMrpProduct(subProduct)) {
|
||||
if (this.isMrpProduct(subProduct)) {
|
||||
|
||||
Double prodQty = productQty.get(subProduct.getId()) == null ? Double.parseDouble("0") : productQty.get(subProduct.getId());
|
||||
BigDecimal reelQty =new BigDecimal(prodQty);
|
||||
Double prodQty = productQty.get(subProduct.getId()) == null
|
||||
? Double.parseDouble("0")
|
||||
: productQty.get(subProduct.getId());
|
||||
|
||||
createMrpLineSophalProd(mrp, subProduct,product, reelQty ,billOfMaterial.getQty(),defaultBillOfMaterial.getQty(),forecastList);
|
||||
BigDecimal reelQty = new BigDecimal(prodQty);
|
||||
|
||||
createMrpLineSophalProd(
|
||||
mrp,
|
||||
subProduct,
|
||||
product,
|
||||
reelQty,
|
||||
billOfMaterial,
|
||||
defaultBillOfMaterial.getQty(),
|
||||
productionMasterPlans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
super.createMrpLineSophal(mrp, product, unit, qty, mrpForecastList, productQty);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void createMrpLineSophalProd(
|
||||
Mrp mrp,
|
||||
Product product,
|
||||
Product parentProduct,
|
||||
BigDecimal qty,
|
||||
BillOfMaterial billOfMaterial,
|
||||
BigDecimal defaultQty,
|
||||
List<ProductionMasterPlan> productionMasterPlans ) throws AxelorException {
|
||||
MrpLineSophal mrpLineSophal = new MrpLineSophal();
|
||||
|
||||
log.debug("****** FORTH ******** {} {}",product,qty);
|
||||
|
||||
|
||||
BigDecimal qtyReqPerBatch = billOfMaterial.getQty();
|
||||
int currentMonth = LocalDate.now().getMonth().getValue();
|
||||
BigDecimal currentProductionPlan = BigDecimal.ZERO;
|
||||
BigDecimal remaining= BigDecimal.ZERO;
|
||||
BigDecimal decreasingQty = qty;
|
||||
BigDecimal totalQtyUsed = BigDecimal.ZERO;
|
||||
BigDecimal futureQty = BigDecimal.ZERO;
|
||||
BigDecimal purchaseQty = BigDecimal.ZERO;
|
||||
|
||||
|
||||
if(mrp.getIncludeFutureQty()){
|
||||
futureQty = Beans.get(StockLocationServiceImpl.class).getFutureQty(product.getId(), mrp.getStockLocation().getCompany().getId(), 0L);
|
||||
decreasingQty = decreasingQty.add(futureQty);
|
||||
}
|
||||
if(mrp.getIncludePurchaseQty()){
|
||||
purchaseQty = Beans.get(ProductStockLocationServiceImpl.class).getPurchaseOrderQty(product, mrp.getStockLocation().getCompany(), null);
|
||||
decreasingQty = decreasingQty.add(purchaseQty);
|
||||
}
|
||||
|
||||
BigDecimal initialQty = decreasingQty;
|
||||
|
||||
for (int index = currentMonth; index < 13; index++) {
|
||||
currentProductionPlan = getCurrentProductionPlan(parentProduct, mrp, index);
|
||||
BigDecimal qtyReqForProd = currentProductionPlan.multiply(qtyReqPerBatch);
|
||||
if(mrp.getIncludeBomWaste()){
|
||||
qtyReqForProd = qtyReqForProd.add(qtyReqForProd.multiply(billOfMaterial.getWasteRate().divide(new BigDecimal("100"),0,RoundingMode.HALF_UP)));
|
||||
}
|
||||
|
||||
totalQtyUsed.add(qtyReqForProd);
|
||||
log.debug("totalQtyUsed**************** {}",totalQtyUsed);
|
||||
|
||||
if(decreasingQty.compareTo(qtyReqForProd) > 0) {
|
||||
remaining = decreasingQty.subtract(qtyReqForProd);
|
||||
decreasingQty = BigDecimal.ZERO;
|
||||
}else{
|
||||
|
||||
remaining = BigDecimal.ZERO;
|
||||
|
||||
decreasingQty = qtyReqForProd.subtract(decreasingQty);
|
||||
|
||||
if(mrp.getIncludeStockRule()){
|
||||
StockRules stockRules = stockRulesService.getStockRules(
|
||||
product,
|
||||
null,
|
||||
StockRulesRepository.TYPE_FUTURE,
|
||||
StockRulesRepository.USE_CASE_USED_FOR_MRP);
|
||||
if(stockRules != null && stockRules.getReOrderQty() != null){
|
||||
decreasingQty = stockRules.getReOrderQty().max(decreasingQty);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
super.createMrpLineSophal(mrp, product,unit, qty, mrpForecastList,productQty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void createMrpLineSophalProd(Mrp mrp,Product product,Product parentProduct,BigDecimal qty,BigDecimal reorderdQty,BigDecimal defaultQty, List<MrpForecast> forecastList){
|
||||
MrpLineSophal mrpLineSophal = new MrpLineSophal();
|
||||
mrpLineSophal.setQty(qty);
|
||||
BigDecimal reelQty = qty;
|
||||
BigDecimal sumQty = BigDecimal.ZERO;
|
||||
for (MrpForecast forecast : forecastList) {
|
||||
switch (index) {
|
||||
case 1:
|
||||
mrpLineSophal.setJanuary(decreasingQty);
|
||||
break;
|
||||
case 2:
|
||||
mrpLineSophal.setFebruary(decreasingQty);
|
||||
break;
|
||||
case 3:
|
||||
mrpLineSophal.setMarch(decreasingQty);
|
||||
break;
|
||||
case 4:
|
||||
mrpLineSophal.setApril(decreasingQty);
|
||||
case 5:
|
||||
mrpLineSophal.setMay(decreasingQty);
|
||||
case 6:
|
||||
mrpLineSophal.setJuin(decreasingQty);
|
||||
break;
|
||||
case 7:
|
||||
mrpLineSophal.setJuly(decreasingQty);
|
||||
break;
|
||||
case 8:
|
||||
mrpLineSophal.setAugust(decreasingQty);
|
||||
break;
|
||||
case 9:
|
||||
mrpLineSophal.setSeptember(decreasingQty);
|
||||
break;
|
||||
case 10:
|
||||
mrpLineSophal.setOctober(decreasingQty);
|
||||
break;
|
||||
case 11:
|
||||
mrpLineSophal.setNovember(decreasingQty);
|
||||
break;
|
||||
case 12:
|
||||
mrpLineSophal.setDecember(decreasingQty);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(remaining.compareTo(BigDecimal.ZERO) > 0){
|
||||
decreasingQty = decreasingQty.add(remaining);
|
||||
}else{
|
||||
decreasingQty = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
if(forecast.getProduct().getId() == parentProduct.getId()){
|
||||
BigDecimal dividedQty = (forecast.getQty().multiply(reorderdQty)).divide(defaultQty);
|
||||
reelQty = reelQty.subtract(dividedQty);
|
||||
sumQty = sumQty.add(dividedQty);
|
||||
BigDecimal displayedQty = reelQty;
|
||||
switch (forecast.getMonthSelect()) {
|
||||
case 1:
|
||||
mrpLineSophal.setJanuary(displayedQty);
|
||||
break;
|
||||
case 2:
|
||||
mrpLineSophal.setFebruary(displayedQty);
|
||||
break;
|
||||
case 3:
|
||||
mrpLineSophal.setMarch(displayedQty);
|
||||
break;
|
||||
case 4:
|
||||
mrpLineSophal.setApril(displayedQty);
|
||||
case 5:
|
||||
mrpLineSophal.setMay(displayedQty);
|
||||
case 6:
|
||||
mrpLineSophal.setJuin(displayedQty);
|
||||
break;
|
||||
case 7:
|
||||
mrpLineSophal.setJuly(displayedQty);
|
||||
break;
|
||||
case 8:
|
||||
mrpLineSophal.setAugust(displayedQty);
|
||||
break;
|
||||
case 9:
|
||||
mrpLineSophal.setSeptember(displayedQty);
|
||||
break;
|
||||
case 10:
|
||||
mrpLineSophal.setOctober(displayedQty);
|
||||
break;
|
||||
case 11:
|
||||
mrpLineSophal.setNovember(displayedQty);
|
||||
break;
|
||||
case 12:
|
||||
mrpLineSophal.setDecember(displayedQty);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mrpLineSophal.setQty(qty);
|
||||
mrpLineSophal.setTotalQtyUsed(totalQtyUsed);
|
||||
mrpLineSophal.setInitialQty(initialQty);
|
||||
mrpLineSophal.setPurchaseOrderQty(purchaseQty);
|
||||
mrpLineSophal.setFutureQty(futureQty);
|
||||
mrpLineSophal.setMrp(mrp);
|
||||
mrpLineSophal.setProduct(product);
|
||||
mrpLineSophal.setUnit(product.getPurchasesUnit());
|
||||
mrpLineSophal.setProductOrigin(parentProduct);
|
||||
|
||||
Stream<MrpForecast> filter = forecastList.stream().filter(t -> t.getProduct().getId() == parentProduct.getId());
|
||||
Long totalForecast = filter.count();
|
||||
|
||||
mrpLineSophal.setSecurityStock(sumQty.divide(new BigDecimal(totalForecast) ,5, RoundingMode.HALF_EVEN));
|
||||
Beans.get(MrpLineSophalRepository.class).save(mrpLineSophal);
|
||||
}
|
||||
|
||||
|
||||
private BigDecimal getCurrentProductionPlan(Product product,Mrp mrp,int monthSelect){
|
||||
|
||||
ProductionMasterPlan productionMasterPlan = Beans.get(ProductionMasterPlanRepository.class).all().fetchStream().filter(t -> t.getProduct() == product && t.getMrp() == mrp).findFirst().orElse(null);
|
||||
|
||||
log.debug("productionMasterPlan >>>>>>>>>>>> {}" , productionMasterPlan);
|
||||
|
||||
if(productionMasterPlan != null){
|
||||
|
||||
switch (monthSelect) {
|
||||
case 1:
|
||||
return productionMasterPlan.getJanuaryBatchQty();
|
||||
|
||||
case 2:
|
||||
return productionMasterPlan.getFebruaryBatchQty();
|
||||
|
||||
case 3:
|
||||
return productionMasterPlan.getMarchBatchQty();
|
||||
|
||||
case 4:
|
||||
return productionMasterPlan.getAprilBatchQty();
|
||||
case 5:
|
||||
return productionMasterPlan.getMayBatchQty();
|
||||
case 6:
|
||||
return productionMasterPlan.getJuinBatchQty();
|
||||
|
||||
case 7:
|
||||
return productionMasterPlan.getJulyBatchQty();
|
||||
|
||||
case 8:
|
||||
return productionMasterPlan.getAugustBatchQty();
|
||||
|
||||
case 9:
|
||||
return productionMasterPlan.getSeptemberBatchQty();
|
||||
|
||||
case 10:
|
||||
return productionMasterPlan.getOctoberBatchQty();
|
||||
|
||||
case 11:
|
||||
return productionMasterPlan.getNovemberBatchQty();
|
||||
|
||||
case 12:
|
||||
return productionMasterPlan.getDecemberBatchQty();
|
||||
default:
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.axelor.apps.production.service;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.axelor.apps.supplychain.db.MrpForecast;
|
||||
|
||||
public class Previous {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String s = null;
|
||||
|
||||
Process p = Runtime.getRuntime().exec("python /Users\\Bachir.souldi.SOPHAL\\Desktop\\dev\\whatsapp_erp\\index.py hello");
|
||||
BufferedReader stdInput = new BufferedReader(new
|
||||
InputStreamReader(p.getInputStream()));
|
||||
|
||||
BufferedReader stdError = new BufferedReader(new
|
||||
InputStreamReader(p.getErrorStream()));
|
||||
|
||||
// read the output from the command
|
||||
System.out.println("Here is the standard output of the command:\n");
|
||||
while ((s = stdInput.readLine()) != null) {
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
// read any errors from the attempted command
|
||||
System.out.println("Here is the standard error of the command (if any):\n");
|
||||
while ((s = stdError.readLine()) != null) {
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -700,11 +700,11 @@ public class CostSheetServiceImpl implements CostSheetService {
|
||||
if ((calculationType == CostSheetRepository.CALCULATION_PARTIAL_END_OF_PRODUCTION
|
||||
|| calculationType == CostSheetRepository.CALCULATION_END_OF_PRODUCTION)
|
||||
&& previousCostSheetDate != null
|
||||
&& !previousCostSheetDate.isBefore(stockMove.getRealDate())) {
|
||||
&& !previousCostSheetDate.isBefore(stockMove.getRealDate().toLocalDate())) {
|
||||
continue;
|
||||
|
||||
} else if (calculationType == CostSheetRepository.CALCULATION_WORK_IN_PROGRESS
|
||||
&& calculationDate.isBefore(stockMove.getRealDate())) {
|
||||
&& calculationDate.isBefore(stockMove.getRealDate().toLocalDate())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.axelor.apps.base.service.UnitConversionService;
|
||||
import com.axelor.apps.base.service.administration.SequenceService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.production.db.BillOfMaterial;
|
||||
import com.axelor.apps.production.db.BillOfMaterialConsumption;
|
||||
import com.axelor.apps.production.db.ManufOrder;
|
||||
import com.axelor.apps.production.db.OperationOrder;
|
||||
import com.axelor.apps.production.db.ProdProcess;
|
||||
@@ -36,6 +37,7 @@ import com.axelor.apps.production.db.ProductionConfig;
|
||||
import com.axelor.apps.production.db.repo.ManufOrderRepository;
|
||||
import com.axelor.apps.production.db.repo.ProdProductRepository;
|
||||
import com.axelor.apps.production.exceptions.IExceptionMessage;
|
||||
import com.axelor.apps.production.service.BillOfMaterialServiceImpl;
|
||||
import com.axelor.apps.production.service.app.AppProductionService;
|
||||
import com.axelor.apps.production.service.config.ProductionConfigService;
|
||||
import com.axelor.apps.production.service.config.StockConfigProductionService;
|
||||
@@ -122,12 +124,14 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
|
||||
Company company = billOfMaterial.getCompany();
|
||||
|
||||
BigDecimal qty = qtyRequested.divide(billOfMaterial.getQty(), 2, RoundingMode.HALF_EVEN);
|
||||
|
||||
// BigDecimal bomQty = billOfMaterial.getQty();
|
||||
// BigDecimal qty = qtyRequested.divide(bomQty, 0, RoundingMode.CEILING).multiply(bomQty);
|
||||
|
||||
ManufOrder manufOrder =
|
||||
this.createManufOrder(
|
||||
product,
|
||||
qty,
|
||||
qtyRequested,
|
||||
priority,
|
||||
IS_TO_INVOICE,
|
||||
company,
|
||||
@@ -139,7 +143,7 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
&& appProductionService.getAppProduction().getAutoPlanManufOrderFromSO()
|
||||
|| originType == ORIGIN_TYPE_MRP
|
||||
|| originType == ORIGIN_TYPE_OTHER) {
|
||||
manufOrder = manufOrderWorkflowService.plan(manufOrder);
|
||||
// manufOrder = manufOrderWorkflowService.plan(manufOrder);
|
||||
}
|
||||
|
||||
return manufOrderRepo.save(manufOrder);
|
||||
@@ -290,10 +294,12 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
}
|
||||
|
||||
if (!manufOrder.getIsConsProOnOperation()) {
|
||||
this.createToConsumeProdProductList(manufOrder);
|
||||
//bachir temp
|
||||
// this.createToConsumeProdProductList(manufOrder);
|
||||
}
|
||||
|
||||
this.createToProduceProdProductList(manufOrder);
|
||||
//bachir temp
|
||||
// this.createToProduceProdProductList(manufOrder);
|
||||
|
||||
return manufOrder;
|
||||
}
|
||||
@@ -322,6 +328,13 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
if(manufOrder.getBillOfMaterial() != null){
|
||||
for (BillOfMaterial bom : manufOrder.getBillOfMaterial().getBillOfMaterialSet()) {
|
||||
BillOfMaterialConsumption newBom = Beans.get(BillOfMaterialServiceImpl.class).createBomConsumptionFromRawMaterial(bom);
|
||||
manufOrder.addBillOfMaterialConsumptionListItem(newBom);
|
||||
}
|
||||
}
|
||||
|
||||
manufOrderRepo.save(manufOrder);
|
||||
|
||||
manufOrder.setPlannedEndDateT(manufOrderWorkflowService.computePlannedEndDateT(manufOrder));
|
||||
|
||||
@@ -101,11 +101,11 @@ public class ManufOrderWorkflowService {
|
||||
}
|
||||
if (!manufOrder.getIsConsProOnOperation()
|
||||
&& CollectionUtils.isEmpty(manufOrder.getToConsumeProdProductList())) {
|
||||
manufOrderService.createToConsumeProdProductList(manufOrder);
|
||||
// manufOrderService.createToConsumeProdProductList(manufOrder);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(manufOrder.getToProduceProdProductList())) {
|
||||
manufOrderService.createToProduceProdProductList(manufOrder);
|
||||
// manufOrderService.createToProduceProdProductList(manufOrder);
|
||||
}
|
||||
|
||||
if (manufOrder.getPlannedStartDateT() == null && manufOrder.getPlannedEndDateT() == null) {
|
||||
@@ -133,7 +133,7 @@ public class ManufOrderWorkflowService {
|
||||
}
|
||||
|
||||
if (!manufOrder.getIsConsProOnOperation()) {
|
||||
manufOrderStockMoveService.createToConsumeStockMove(manufOrder);
|
||||
// manufOrderStockMoveService.createToConsumeStockMove(manufOrder);
|
||||
}
|
||||
|
||||
manufOrderStockMoveService.createToProduceStockMove(manufOrder);
|
||||
@@ -147,13 +147,13 @@ public class ManufOrderWorkflowService {
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void start(ManufOrder manufOrder) throws AxelorException {
|
||||
|
||||
manufOrder.setRealStartDateT(
|
||||
Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
|
||||
// manufOrder.setRealStartDateT(
|
||||
// Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
|
||||
|
||||
int beforeOrAfterConfig = manufOrder.getProdProcess().getStockMoveRealizeOrderSelect();
|
||||
if (beforeOrAfterConfig == ProductionConfigRepository.REALIZE_START) {
|
||||
for (StockMove stockMove : manufOrder.getInStockMoveList()) {
|
||||
manufOrderStockMoveService.finishStockMove(stockMove);
|
||||
// manufOrderStockMoveService.finishStockMove(stockMove);
|
||||
}
|
||||
}
|
||||
manufOrder.setStatusSelect(ManufOrderRepository.STATUS_IN_PROGRESS);
|
||||
@@ -234,8 +234,8 @@ public class ManufOrderWorkflowService {
|
||||
}
|
||||
|
||||
manufOrderStockMoveService.finish(manufOrder);
|
||||
manufOrder.setRealEndDateT(
|
||||
Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
|
||||
// manufOrder.setRealEndDateT(
|
||||
// Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
|
||||
manufOrder.setStatusSelect(ManufOrderRepository.STATUS_FINISHED);
|
||||
manufOrder.setEndTimeDifference(
|
||||
new BigDecimal(
|
||||
|
||||
@@ -83,19 +83,19 @@ public class OperationOrderWorkflowService {
|
||||
Beans.get(OperationOrderService.class).createToConsumeProdProductList(operationOrder);
|
||||
}
|
||||
|
||||
operationOrder.setPlannedStartDateT(this.getLastOperationOrder(operationOrder));
|
||||
// operationOrder.setPlannedStartDateT(this.getLastOperationOrder(operationOrder));
|
||||
|
||||
operationOrder.setPlannedEndDateT(this.computePlannedEndDateT(operationOrder));
|
||||
// operationOrder.setPlannedEndDateT(this.computePlannedEndDateT(operationOrder));
|
||||
|
||||
operationOrder.setPlannedDuration(
|
||||
DurationTool.getSecondsDuration(
|
||||
Duration.between(
|
||||
operationOrder.getPlannedStartDateT(), operationOrder.getPlannedEndDateT())));
|
||||
// operationOrder.setPlannedDuration(
|
||||
// DurationTool.getSecondsDuration(
|
||||
// Duration.between(
|
||||
// operationOrder.getPlannedStartDateT(), operationOrder.getPlannedEndDateT())));
|
||||
|
||||
ManufOrder manufOrder = operationOrder.getManufOrder();
|
||||
if (manufOrder == null || manufOrder.getIsConsProOnOperation()) {
|
||||
operationOrderStockMoveService.createToConsumeStockMove(operationOrder);
|
||||
}
|
||||
// ManufOrder manufOrder = operationOrder.getManufOrder();
|
||||
// if (manufOrder == null || manufOrder.getIsConsProOnOperation()) {
|
||||
// operationOrderStockMoveService.createToConsumeStockMove(operationOrder);
|
||||
// }
|
||||
|
||||
operationOrder.setStatusSelect(OperationOrderRepository.STATUS_PLANNED);
|
||||
|
||||
@@ -195,26 +195,26 @@ public class OperationOrderWorkflowService {
|
||||
public void start(OperationOrder operationOrder) throws AxelorException {
|
||||
if (operationOrder.getStatusSelect() != OperationOrderRepository.STATUS_IN_PROGRESS) {
|
||||
operationOrder.setStatusSelect(OperationOrderRepository.STATUS_IN_PROGRESS);
|
||||
operationOrder.setRealStartDateT(appProductionService.getTodayDateTime().toLocalDateTime());
|
||||
// operationOrder.setRealStartDateT(appProductionService.getTodayDateTime().toLocalDateTime());
|
||||
|
||||
startOperationOrderDuration(operationOrder);
|
||||
// startOperationOrderDuration(operationOrder);
|
||||
|
||||
if (operationOrder.getManufOrder() != null) {
|
||||
int beforeOrAfterConfig =
|
||||
operationOrder.getManufOrder().getProdProcess().getStockMoveRealizeOrderSelect();
|
||||
if (beforeOrAfterConfig == ProductionConfigRepository.REALIZE_START) {
|
||||
for (StockMove stockMove : operationOrder.getInStockMoveList()) {
|
||||
Beans.get(ManufOrderStockMoveService.class).finishStockMove(stockMove);
|
||||
}
|
||||
// if (operationOrder.getManufOrder() != null) {
|
||||
// int beforeOrAfterConfig =
|
||||
// operationOrder.getManufOrder().getProdProcess().getStockMoveRealizeOrderSelect();
|
||||
// if (beforeOrAfterConfig == ProductionConfigRepository.REALIZE_START) {
|
||||
// for (StockMove stockMove : operationOrder.getInStockMoveList()) {
|
||||
// Beans.get(ManufOrderStockMoveService.class).finishStockMove(stockMove);
|
||||
// }
|
||||
|
||||
StockMove newStockMove =
|
||||
operationOrderStockMoveService._createToConsumeStockMove(
|
||||
operationOrder, operationOrder.getManufOrder().getCompany());
|
||||
newStockMove.setStockMoveLineList(new ArrayList<>());
|
||||
Beans.get(StockMoveService.class).plan(newStockMove);
|
||||
operationOrder.addInStockMoveListItem(newStockMove);
|
||||
}
|
||||
}
|
||||
// StockMove newStockMove =
|
||||
// operationOrderStockMoveService._createToConsumeStockMove(
|
||||
// operationOrder, operationOrder.getManufOrder().getCompany());
|
||||
// newStockMove.setStockMoveLineList(new ArrayList<>());
|
||||
// Beans.get(StockMoveService.class).plan(newStockMove);
|
||||
// operationOrder.addInStockMoveListItem(newStockMove);
|
||||
// }
|
||||
// }
|
||||
operationOrderRepo.save(operationOrder);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ public class OperationOrderWorkflowService {
|
||||
public void pause(OperationOrder operationOrder) {
|
||||
operationOrder.setStatusSelect(OperationOrderRepository.STATUS_STANDBY);
|
||||
|
||||
stopOperationOrderDuration(operationOrder);
|
||||
// stopOperationOrderDuration(operationOrder);
|
||||
|
||||
operationOrderRepo.save(operationOrder);
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class OperationOrderWorkflowService {
|
||||
public void resume(OperationOrder operationOrder) {
|
||||
operationOrder.setStatusSelect(OperationOrderRepository.STATUS_IN_PROGRESS);
|
||||
|
||||
startOperationOrderDuration(operationOrder);
|
||||
// startOperationOrderDuration(operationOrder);
|
||||
|
||||
operationOrderRepo.save(operationOrder);
|
||||
}
|
||||
@@ -261,11 +261,11 @@ public class OperationOrderWorkflowService {
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void finish(OperationOrder operationOrder) throws AxelorException {
|
||||
operationOrder.setStatusSelect(OperationOrderRepository.STATUS_FINISHED);
|
||||
operationOrder.setRealEndDateT(appProductionService.getTodayDateTime().toLocalDateTime());
|
||||
// operationOrder.setRealEndDateT(appProductionService.getTodayDateTime().toLocalDateTime());
|
||||
|
||||
stopOperationOrderDuration(operationOrder);
|
||||
// stopOperationOrderDuration(operationOrder);
|
||||
|
||||
operationOrderStockMoveService.finish(operationOrder);
|
||||
// operationOrderStockMoveService.finish(operationOrder);
|
||||
operationOrderRepo.save(operationOrder);
|
||||
}
|
||||
|
||||
@@ -286,14 +286,14 @@ public class OperationOrderWorkflowService {
|
||||
operationOrder.setStatusSelect(OperationOrderRepository.STATUS_CANCELED);
|
||||
|
||||
if (oldStatus == OperationOrderRepository.STATUS_IN_PROGRESS) {
|
||||
stopOperationOrderDuration(operationOrder);
|
||||
// stopOperationOrderDuration(operationOrder);
|
||||
}
|
||||
if (operationOrder.getConsumedStockMoveLineList() != null) {
|
||||
operationOrder
|
||||
.getConsumedStockMoveLineList()
|
||||
.forEach(stockMoveLine -> stockMoveLine.setConsumedOperationOrder(null));
|
||||
// operationOrder
|
||||
// .getConsumedStockMoveLineList()
|
||||
// .forEach(stockMoveLine -> stockMoveLine.setConsumedOperationOrder(null));
|
||||
}
|
||||
operationOrderStockMoveService.cancel(operationOrder);
|
||||
// operationOrderStockMoveService.cancel(operationOrder);
|
||||
|
||||
operationOrderRepo.save(operationOrder);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -126,24 +127,33 @@ public class ProductionOrderServiceImpl implements ProductionOrderService {
|
||||
int originType)
|
||||
throws AxelorException {
|
||||
|
||||
ManufOrder manufOrder =
|
||||
manufOrderService.generateManufOrder(
|
||||
product,
|
||||
qtyRequested,
|
||||
ManufOrderService.DEFAULT_PRIORITY,
|
||||
ManufOrderService.IS_TO_INVOICE,
|
||||
billOfMaterial,
|
||||
startDate,
|
||||
endDate,
|
||||
originType);
|
||||
|
||||
if (manufOrder != null) {
|
||||
if (saleOrder != null) {
|
||||
manufOrder.setSaleOrder(saleOrder);
|
||||
manufOrder.setClientPartner(saleOrder.getClientPartner());
|
||||
BigDecimal bomQty = billOfMaterial.getQty();
|
||||
BigDecimal manufCount = qtyRequested.divide(bomQty, 0, RoundingMode.CEILING);
|
||||
|
||||
|
||||
for (int index = 0; index < manufCount.intValue(); index++) {
|
||||
ManufOrder manufOrder =
|
||||
manufOrderService.generateManufOrder(
|
||||
product,
|
||||
bomQty,
|
||||
ManufOrderService.DEFAULT_PRIORITY,
|
||||
ManufOrderService.IS_TO_INVOICE,
|
||||
billOfMaterial,
|
||||
startDate,
|
||||
endDate,
|
||||
originType);
|
||||
|
||||
if (manufOrder != null) {
|
||||
if (saleOrder != null) {
|
||||
manufOrder.setSaleOrder(saleOrder);
|
||||
manufOrder.setClientPartner(saleOrder.getClientPartner());
|
||||
}
|
||||
productionOrder.addManufOrderListItem(manufOrder);
|
||||
}
|
||||
productionOrder.addManufOrderListItem(manufOrder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return productionOrderRepo.save(productionOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +173,110 @@ public class ManufOrderController {
|
||||
}
|
||||
}
|
||||
|
||||
public void startF(ActionRequest request, ActionResponse response) {
|
||||
|
||||
try {
|
||||
Context context = request.getContext();
|
||||
List<ManufOrder> manufOrders = new ArrayList<>();
|
||||
if (context.get("id") != null) {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
manufOrders.add(Beans.get(ManufOrderRepository.class).find(manufOrderId));
|
||||
} else if (context.get("_ids") != null) {
|
||||
manufOrders =
|
||||
Beans.get(ManufOrderRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1",
|
||||
context.get("_ids"))
|
||||
.fetch();
|
||||
}
|
||||
for (ManufOrder manufOrder : manufOrders) {
|
||||
Beans.get(ManufOrderWorkflowService.class).start(manufOrder);
|
||||
}
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseF(ActionRequest request, ActionResponse response) {
|
||||
|
||||
try {
|
||||
Context context = request.getContext();
|
||||
List<ManufOrder> manufOrders = new ArrayList<>();
|
||||
if (context.get("id") != null) {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
manufOrders.add(Beans.get(ManufOrderRepository.class).find(manufOrderId));
|
||||
} else if (context.get("_ids") != null) {
|
||||
manufOrders =
|
||||
Beans.get(ManufOrderRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1",
|
||||
context.get("_ids"))
|
||||
.fetch();
|
||||
}
|
||||
for (ManufOrder manufOrder : manufOrders) {
|
||||
Beans.get(ManufOrderWorkflowService.class).pause(manufOrder);
|
||||
}
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void resumeF(ActionRequest request, ActionResponse response) {
|
||||
|
||||
try {
|
||||
Context context = request.getContext();
|
||||
List<ManufOrder> manufOrders = new ArrayList<>();
|
||||
if (context.get("id") != null) {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
manufOrders.add(Beans.get(ManufOrderRepository.class).find(manufOrderId));
|
||||
} else if (context.get("_ids") != null) {
|
||||
manufOrders =
|
||||
Beans.get(ManufOrderRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1",
|
||||
context.get("_ids"))
|
||||
.fetch();
|
||||
}
|
||||
for (ManufOrder manufOrder : manufOrders) {
|
||||
Beans.get(ManufOrderWorkflowService.class).resume(manufOrder);
|
||||
}
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void finishF(ActionRequest request, ActionResponse response) {
|
||||
|
||||
try {
|
||||
Context context = request.getContext();
|
||||
List<ManufOrder> manufOrders = new ArrayList<>();
|
||||
if (context.get("id") != null) {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
manufOrders.add(Beans.get(ManufOrderRepository.class).find(manufOrderId));
|
||||
} else if (context.get("_ids") != null) {
|
||||
manufOrders =
|
||||
Beans.get(ManufOrderRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1",
|
||||
context.get("_ids"))
|
||||
.fetch();
|
||||
}
|
||||
for (ManufOrder manufOrder : manufOrders) {
|
||||
Beans.get(ManufOrderWorkflowService.class).finish(manufOrder);
|
||||
}
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from manuf order form on clicking realize button. Call {@link
|
||||
* ManufOrderStockMoveService#consumeInStockMoves(ManufOrder)} to consume material used in manuf
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="production" package="com.axelor.apps.production.db"/>
|
||||
|
||||
<entity name="BillOfMaterialConsumption" lang="java">
|
||||
|
||||
<string name="name" title="Label"/>
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" required="true"/>
|
||||
<decimal name="qty" title="Qty" precision="20" scale="10"/>
|
||||
<decimal name="realQty" title="Real qty" precision="20" scale="10"/>
|
||||
<integer name="priority" title="Priority"/>
|
||||
<boolean name="defineSubBillOfMaterial" title="Define sub bill of material"/>
|
||||
<many-to-one name="unit" ref="com.axelor.apps.base.db.Unit" title="Unit"/>
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company"/>
|
||||
|
||||
<string name="fullName" namecolumn="true" title="Label"/>
|
||||
|
||||
<string name="note" large="true"/>
|
||||
|
||||
<track>
|
||||
<field name="name"/>
|
||||
<field name="product"/>
|
||||
<field name="qty"/>
|
||||
<field name="realQty"/>
|
||||
<field name="note"/>
|
||||
</track>
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="production" package="com.axelor.apps.production.db"/>
|
||||
|
||||
<entity name="DocumentationManufOrder" lang="java">
|
||||
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -64,6 +64,17 @@
|
||||
<many-to-one name="cancelReason" title="Cancel reason" ref="com.axelor.apps.base.db.CancelReason"/>
|
||||
<string name="cancelReasonStr" title="Cancel Reason" large="true"/>
|
||||
|
||||
<many-to-one name="trackingNumber" ref="com.axelor.apps.stock.db.TrackingNumber" title="Tracking Nbr."/>
|
||||
|
||||
<many-to-one name="conformityCertificateFile" ref="com.axelor.meta.db.MetaFile" title="Conformity certificate file" />
|
||||
<string name="noteconformityCertificateFile" large="true" multiline="true" title="Conformity certificate file note"/>
|
||||
|
||||
<integer name="progress" title="Progress %" min="0" max="100" />
|
||||
|
||||
<integer name="stypeSelect" title="Typeselect" selection="production.manuf.order.stypeselect" />
|
||||
|
||||
<one-to-many name="billOfMaterialConsumptionList" title="Bom consumption list" ref="com.axelor.apps.production.db.BillOfMaterialConsumption" />
|
||||
|
||||
<unique-constraint columns="manufOrderSeq,company"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
<many-to-one name="manufOrder" ref="com.axelor.apps.production.db.ManufOrder" title="Manufacturing order" initParam="true"/>
|
||||
|
||||
<!-- <decimal name="qty" title="Quantity"/> -->
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" />
|
||||
<decimal name="qty" title="Quantity"/>
|
||||
|
||||
<many-to-one name="workCenter" ref="com.axelor.apps.production.db.WorkCenter" title="Work center" initParam="true"/>
|
||||
<many-to-one name="machineWorkCenter" ref="com.axelor.apps.production.db.WorkCenter" title="Machine" initParam="true"/>
|
||||
@@ -55,6 +56,8 @@
|
||||
|
||||
<many-to-one name="barCode" ref="com.axelor.meta.db.MetaFile" title="Barcode" readonly="true"/>
|
||||
|
||||
<integer name="orderByState"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
// STATUS SELECT
|
||||
public static final int STATUS_DRAFT = 1;
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<one-to-many name="toConsumeProdProductList" ref="com.axelor.apps.production.db.ProdProduct" mappedBy="toConsumeProdProcessLine" title="Products to consume"/>
|
||||
<one-to-many name="objectDescriptionList" ref="com.axelor.apps.production.db.ObjectDescription" mappedBy="prodProcessLine" title="Descriptions"/>
|
||||
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" />
|
||||
<decimal name="qty" title="Quantity"/>
|
||||
|
||||
<track>
|
||||
<field name="prodProcess"/>
|
||||
<field name="workCenter"/>
|
||||
@@ -34,6 +37,8 @@
|
||||
<field name="outsourcing"/>
|
||||
<field name="optional"/>
|
||||
<field name="stockLocation"/>
|
||||
<field name="product"/>
|
||||
<field name="qty"/>
|
||||
</track>
|
||||
</entity>
|
||||
</domain-models>
|
||||
|
||||
@@ -29,19 +29,23 @@ import com.axelor.apps.project.exception.IExceptionMessage;
|
||||
import com.axelor.apps.project.translation.ITranslation;
|
||||
import com.axelor.auth.AuthUtils;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.common.ObjectUtils;
|
||||
import com.axelor.db.JPA;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.team.db.TeamTask;
|
||||
import com.axelor.team.db.repo.TeamTaskRepository;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.persistence.TypedQuery;
|
||||
@@ -207,12 +211,25 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
projectRepository.save(project);
|
||||
|
||||
Set<TaskTemplate> taskTemplateSet = projectTemplate.getTaskTemplateSet();
|
||||
if (ObjectUtils.isEmpty(taskTemplateSet)) {
|
||||
return project;
|
||||
}
|
||||
List<TaskTemplate> taskTemplateList = new ArrayList<TaskTemplate>(taskTemplateSet);
|
||||
Collections.sort(
|
||||
taskTemplateList,
|
||||
new Comparator<TaskTemplate>() {
|
||||
|
||||
if (taskTemplateSet != null) {
|
||||
Iterator<TaskTemplate> taskTemplateItr = taskTemplateSet.iterator();
|
||||
@Override
|
||||
public int compare(TaskTemplate taskTemplatet1, TaskTemplate taskTemplate2) {
|
||||
return taskTemplatet1.getParentTaskTemplate() == null || taskTemplate2 == null
|
||||
? 1
|
||||
: taskTemplatet1.getParentTaskTemplate().equals(taskTemplate2) ? -1 : 1;
|
||||
}
|
||||
});
|
||||
|
||||
while (taskTemplateItr.hasNext()) {
|
||||
createTask(taskTemplateItr.next(), project);
|
||||
if (taskTemplateList != null) {
|
||||
for (TaskTemplate taskTemplate : taskTemplateList) {
|
||||
createTask(taskTemplate, project, taskTemplateSet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,12 +238,67 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
}
|
||||
|
||||
public TeamTask createTask(TaskTemplate taskTemplate, Project project) {
|
||||
System.out.println("***********No parent*******************");
|
||||
System.out.println(project.getId());
|
||||
TeamTask task =
|
||||
teamTaskProjectService.create(
|
||||
taskTemplate.getName(), project, taskTemplate.getAssignedTo());
|
||||
task.setDescription(taskTemplate.getDescription());
|
||||
task.setTaskTemplate(taskTemplate);
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
public TeamTask createTask(
|
||||
TaskTemplate taskTemplate, TaskTemplate parentTaskTemplate, Project project) {
|
||||
|
||||
System.out.println("***********parent*******************");
|
||||
System.out.println(project.getId());
|
||||
TeamTask task =
|
||||
teamTaskProjectService.create(
|
||||
taskTemplate.getName(), project, taskTemplate.getAssignedTo());
|
||||
|
||||
TeamTask parent =
|
||||
Beans.get(TeamTaskRepository.class)
|
||||
.all()
|
||||
.fetch()
|
||||
.stream()
|
||||
.filter(
|
||||
t -> {
|
||||
return t.getProject().getId() == project.getId()
|
||||
&& t.getTaskTemplate().getId() == parentTaskTemplate.getId();
|
||||
})
|
||||
.findFirst()
|
||||
.get();
|
||||
|
||||
task.setDescription(taskTemplate.getDescription());
|
||||
task.setTaskTemplate(taskTemplate);
|
||||
task.setParentTask(parent);
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
public TeamTask createTask(
|
||||
TaskTemplate taskTemplate, Project project, Set<TaskTemplate> taskTemplateSet) {
|
||||
|
||||
if (!ObjectUtils.isEmpty(project.getTeamTaskList())) {
|
||||
for (TeamTask projectTask : project.getTeamTaskList()) {
|
||||
if (projectTask.getName().equals(taskTemplate.getName())) {
|
||||
return projectTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
TeamTask task =
|
||||
teamTaskProjectService.create(
|
||||
taskTemplate.getName(), project, taskTemplate.getAssignedTo());
|
||||
task.setDescription(taskTemplate.getDescription());
|
||||
|
||||
TaskTemplate parentTaskTemplate = taskTemplate.getParentTaskTemplate();
|
||||
|
||||
if (parentTaskTemplate != null && taskTemplateSet.contains(parentTaskTemplate)) {
|
||||
task.setParentTask(this.createTask(parentTaskTemplate, project, taskTemplateSet));
|
||||
return task;
|
||||
}
|
||||
return task;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<decimal name="quantity" title="Quantity"/>
|
||||
<decimal name="unitPrice" title="Unit price" />
|
||||
<many-to-one name="currency" ref="com.axelor.apps.base.db.Currency" title="Currency" index="false"/>
|
||||
<many-to-one name="taskTemplate" title="Task Template" ref="com.axelor.apps.project.db.TaskTemplate" />
|
||||
|
||||
<!-- Gantt view fields -->
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<entity name="Wiki">
|
||||
<string name="title"/>
|
||||
<string name="content" large="true"/>
|
||||
<boolean name="isImport" title="Is import" default="false" />
|
||||
<many-to-one name="project" ref="com.axelor.apps.project.db.Project" title="Project"/>
|
||||
<many-to-one name="projectTemplate" ref="com.axelor.apps.project.db.ProjectTemplate" title="Project template"/>
|
||||
</entity>
|
||||
|
||||
@@ -45,6 +45,8 @@ public interface IExceptionMessage {
|
||||
"The company is required and must be the same for all purchase orders" /*)*/;
|
||||
public static final String PURCHASE_ORDER_MERGE_ERROR_TRADING_NAME = /*$$(*/
|
||||
"The trading name must be the same for all purchase orders" /*)*/;
|
||||
public static final String PURCHASE_ORDER_MERGE_ERROR_STATUS_SELECT = /*$$(*/
|
||||
"The status select name must be the same for all purchase orders" /*)*/;
|
||||
|
||||
/** Blocking supplier */
|
||||
String SUPPLIER_BLOCKED = /*$$(*/ "This supplier is blocked:" /*)*/;
|
||||
@@ -70,8 +72,6 @@ public interface IExceptionMessage {
|
||||
"There is no sequence set for the purchase requests for the company %s" /*)*/;
|
||||
public static final String PURCHASE_REQUEST_MISSING_SUPPLIER_USER = /*$$(*/
|
||||
"Please enter supplier for following purchase request : %s" /*)*/;
|
||||
public static final String TCO = /*$$(*/
|
||||
"CTO not validated for products : %s" /*)*/;
|
||||
public static final String NO_TCO = /*$$(*/
|
||||
"CTO not present for products : %s" /*)*/;
|
||||
public static final String TCO = /*$$(*/ "CTO not validated for products : %s" /*)*/;
|
||||
public static final String NO_TCO = /*$$(*/ "CTO not present for products : %s" /*)*/;
|
||||
}
|
||||
|
||||
@@ -21,4 +21,5 @@ public interface IReport {
|
||||
|
||||
public static final String PURCHASE_ORDER = "PurchaseOrder.rptdesign";
|
||||
public static final String PURCHASE_REQUEST = "PurchaseRequest.rptdesign";
|
||||
public static final String COST_PRICE_SHEET = "CostPriceSheet.rptdesign";
|
||||
}
|
||||
|
||||
@@ -1,94 +1,117 @@
|
||||
package com.axelor.apps.purchase.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
|
||||
import com.axelor.apps.base.db.Currency;
|
||||
import com.axelor.apps.base.db.repo.CurrencyRepository;
|
||||
import com.axelor.apps.base.service.CurrencyConversionService;
|
||||
import com.axelor.apps.base.service.CurrencyService;
|
||||
import com.axelor.apps.base.service.administration.SequenceService;
|
||||
import com.axelor.apps.purchase.db.ImportationFolder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrderLine;
|
||||
import com.axelor.apps.purchase.db.repo.ImportationFolderRepository;
|
||||
import com.axelor.apps.purchase.db.repo.PurchaseOrderLineRepository;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import wslite.json.JSONException;
|
||||
|
||||
import com.axelor.inject.Beans;
|
||||
|
||||
|
||||
public class ImportationFolderServiceImpl implements ImportationFolderService {
|
||||
|
||||
@Inject
|
||||
protected ImportationFolderRepository importationFolderRepository;
|
||||
@Inject protected ImportationFolderRepository importationFolderRepository;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void draftImportationFolder(ImportationFolder importationFolder) {
|
||||
// TODO Auto-generated method stub
|
||||
// importationFolder.setStatusSelect(ImportationFolderRepository.STATUS_DRAFT);
|
||||
@Override
|
||||
@Transactional
|
||||
public void draftImportationFolder(ImportationFolder importationFolder) {
|
||||
// TODO Auto-generated method stub
|
||||
// importationFolder.setStatusSelect(ImportationFolderRepository.STATUS_DRAFT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void openImportationFolder(ImportationFolder importationFolder) throws AxelorException {
|
||||
// importationFolder.setStatusSelect(ImportationFolderRepository.STATUS_OPEND);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void closeImportationFolder(ImportationFolder importationFolder) {
|
||||
// importationFolder.setStatusSelect(ImportationFolderRepository.STATUS_CLOSED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void cancelImportationFolder(ImportationFolder importationFolder) {
|
||||
// importationFolder.setStatusSelect(ImportationFolderRepository.STATUS_CANCELED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void calculateSum(List<PurchaseOrder> purchaseOrders, ImportationFolder importationFolder)
|
||||
throws MalformedURLException, JSONException, AxelorException {
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrders) {
|
||||
if (purchaseOrder.getCurrency().getId() == 148 || purchaseOrder.getCurrency().getId() == 46) {
|
||||
Currency currency =
|
||||
Beans.get(CurrencyRepository.class).find(purchaseOrder.getCurrency().getId());
|
||||
Currency currencyDzd = Beans.get(CurrencyRepository.class).findByCode("DZD");
|
||||
BigDecimal currencyAmount =
|
||||
Beans.get(CurrencyService.class).getCurrencyConversionRate(currency, currencyDzd);
|
||||
|
||||
currencyAmount = currencyAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
BigDecimal finalAmount = purchaseOrder.getExTaxTotal().multiply(currencyAmount);
|
||||
BigDecimal finalTaxAmount = purchaseOrder.getTaxTotal().multiply(currencyAmount);
|
||||
BigDecimal finalTotalAmount = purchaseOrder.getInTaxTotal().multiply(currencyAmount);
|
||||
|
||||
amount = amount.add(finalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
taxAmount = taxAmount.add(finalTaxAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
totalAmount = totalAmount.add(finalTotalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
} else {
|
||||
amount = amount.add(purchaseOrder.getExTaxTotal());
|
||||
taxAmount = taxAmount.add(purchaseOrder.getTaxTotal());
|
||||
totalAmount = totalAmount.add(purchaseOrder.getInTaxTotal());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void openImportationFolder(ImportationFolder importationFolder) throws AxelorException {
|
||||
// importationFolder.setStatusSelect(ImportationFolderRepository.STATUS_OPEND);
|
||||
importationFolder.setAmount(amount);
|
||||
importationFolder.setTaxAmount(taxAmount);
|
||||
importationFolder.setTotalAmount(totalAmount);
|
||||
|
||||
importationFolderRepository.save(importationFolder);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void calculateAvgPrice(List<PurchaseOrderLine> purchaseOrderLines, ImportationFolder importationFolder)
|
||||
throws MalformedURLException, JSONException, AxelorException {
|
||||
|
||||
|
||||
for (PurchaseOrderLine purchaseOrderLine : purchaseOrderLines) {
|
||||
|
||||
purchaseOrderLine.setPrice(purchaseOrderLine.getPrice().multiply(importationFolder.getCurrencyRate()));
|
||||
|
||||
BigDecimal qty = purchaseOrderLine.getQty();
|
||||
purchaseOrderLine.setQty(purchaseOrderLine.getReceivedQty());
|
||||
Map<String, BigDecimal> map = Beans.get(PurchaseOrderLineService.class).compute(purchaseOrderLine, purchaseOrderLine.getPurchaseOrder());
|
||||
purchaseOrderLine.setExTaxTotal(map.get("exTaxTotal"));
|
||||
purchaseOrderLine.setInTaxTotal(map.get("inTaxTotal"));
|
||||
purchaseOrderLine.setQty(qty);
|
||||
Beans.get(PurchaseOrderLineRepository.class).save(purchaseOrderLine);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void closeImportationFolder(ImportationFolder importationFolder) {
|
||||
// importationFolder.setStatusSelect(ImportationFolderRepository.STATUS_CLOSED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void cancelImportationFolder(ImportationFolder importationFolder) {
|
||||
// importationFolder.setStatusSelect(ImportationFolderRepository.STATUS_CANCELED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void calculateSum(List<PurchaseOrder> purchaseOrders,ImportationFolder importationFolder) throws MalformedURLException, JSONException, AxelorException {
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
importationFolderRepository.save(importationFolder);
|
||||
}
|
||||
|
||||
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrders) {
|
||||
if(purchaseOrder.getCurrency().getId() == 148 || purchaseOrder.getCurrency().getId() == 46){
|
||||
Currency currency = Beans.get(CurrencyRepository.class).find(purchaseOrder.getCurrency().getId());
|
||||
Currency currencyDzd = Beans.get(CurrencyRepository.class).findByCode("DZD");
|
||||
BigDecimal currencyAmount = Beans.get(CurrencyService.class).getCurrencyConversionRate(currency, currencyDzd);
|
||||
|
||||
currencyAmount = currencyAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
BigDecimal finalAmount = purchaseOrder.getExTaxTotal().multiply(currencyAmount);
|
||||
BigDecimal finalTaxAmount = purchaseOrder.getTaxTotal().multiply(currencyAmount);
|
||||
BigDecimal finalTotalAmount = purchaseOrder.getInTaxTotal().multiply(currencyAmount);
|
||||
|
||||
amount = amount.add(finalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
taxAmount = taxAmount.add(finalTaxAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
totalAmount = totalAmount.add(finalTotalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
}else{
|
||||
amount = amount.add(purchaseOrder.getExTaxTotal());
|
||||
taxAmount = taxAmount.add(purchaseOrder.getTaxTotal());
|
||||
totalAmount = totalAmount.add(purchaseOrder.getInTaxTotal());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
importationFolder.setAmount(amount);
|
||||
importationFolder.setTaxAmount(taxAmount);
|
||||
importationFolder.setTotalAmount(totalAmount);
|
||||
|
||||
importationFolderRepository.save(importationFolder);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class PurchaseOrderLineServiceImpl implements PurchaseOrderLineService {
|
||||
BigDecimal amount =
|
||||
quantity
|
||||
.multiply(price)
|
||||
.setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_EVEN);
|
||||
.setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS_SUPPLIER_LINE, RoundingMode.HALF_EVEN);
|
||||
|
||||
LOG.debug(
|
||||
"Calcul du montant HT avec une quantité de {} pour {} : {}",
|
||||
@@ -457,7 +457,7 @@ public class PurchaseOrderLineServiceImpl implements PurchaseOrderLineService {
|
||||
purchaseOrder.getCompany().getCurrency(),
|
||||
exTaxTotal,
|
||||
purchaseOrder.getOrderDate())
|
||||
.setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP);
|
||||
.setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS_SUPPLIER_LINE, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.axelor.apps.purchase.service;
|
||||
|
||||
import com.axelor.apps.base.db.CancelReason;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Currency;
|
||||
import com.axelor.apps.base.db.Partner;
|
||||
@@ -27,12 +28,10 @@ import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import com.axelor.apps.base.db.CancelReason;
|
||||
import wslite.json.JSONException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import wslite.json.JSONException;
|
||||
|
||||
public interface PurchaseOrderService {
|
||||
|
||||
@@ -77,6 +76,7 @@ public interface PurchaseOrderService {
|
||||
LocalDate deliveryDate,
|
||||
String internalReference,
|
||||
String externalReference,
|
||||
String notes,
|
||||
LocalDate orderDate,
|
||||
PriceList priceList,
|
||||
Partner supplierPartner,
|
||||
@@ -108,17 +108,22 @@ public interface PurchaseOrderService {
|
||||
|
||||
public void draftPurchaseOrder(PurchaseOrder purchaseOrder);
|
||||
|
||||
public void validatePurchaseOrder(PurchaseOrder purchaseOrder) throws AxelorException, MalformedURLException, JSONException;
|
||||
public void validatePurchaseOrder(PurchaseOrder purchaseOrder)
|
||||
throws AxelorException, MalformedURLException, JSONException;
|
||||
|
||||
public void checkTcoToApprove(PurchaseOrder purchaseOrder) throws AxelorException;
|
||||
|
||||
public void finishPurchaseOrder(PurchaseOrder purchaseOrder);
|
||||
public void finishPurchaseOrder(PurchaseOrder purchaseOrder, String cancelReasonStr);
|
||||
|
||||
public void setStandByPurchaseOrder(PurchaseOrder purchaseOrder, String standByReasonStr);
|
||||
|
||||
public void cancelPurchaseOrder(PurchaseOrder purchaseOrder);
|
||||
|
||||
public void cancelReasonPurchaseOrder(PurchaseOrder purchaseOrder, CancelReason cancelReason, String cancelReasonStr);
|
||||
public void cancelReasonPurchaseOrder(
|
||||
PurchaseOrder purchaseOrder, CancelReason cancelReason, String cancelReasonStr);
|
||||
|
||||
public void calculateSum(List<PurchaseOrder> purchaseOrders,ImportationFolder importationFolder) throws AxelorException;
|
||||
public void calculateSum(List<PurchaseOrder> purchaseOrders, ImportationFolder importationFolder)
|
||||
throws AxelorException;
|
||||
|
||||
void setPurchaseOrderBarCodeSeq(PurchaseOrder purchaseOrder) throws AxelorException;
|
||||
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
package com.axelor.apps.purchase.service;
|
||||
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.axelor.apps.account.db.TaxLine;
|
||||
import com.axelor.apps.account.db.repo.TaxLineRepository;
|
||||
import com.axelor.apps.base.db.Blocking;
|
||||
import com.axelor.apps.base.db.CancelReason;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Currency;
|
||||
import com.axelor.apps.base.db.Partner;
|
||||
@@ -26,11 +29,14 @@ import com.axelor.apps.base.db.PriceList;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.TradingName;
|
||||
import com.axelor.apps.base.db.Unit;
|
||||
import com.axelor.apps.base.db.Wizard;
|
||||
import com.axelor.apps.base.db.repo.BlockingRepository;
|
||||
import com.axelor.apps.base.db.repo.CurrencyRepository;
|
||||
import com.axelor.apps.base.db.repo.PartnerRepository;
|
||||
import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.base.db.repo.SequenceRepository;
|
||||
import com.axelor.apps.base.db.repo.UnitRepository;
|
||||
import com.axelor.apps.base.service.BarcodeGeneratorService;
|
||||
import com.axelor.apps.base.service.BlockingService;
|
||||
import com.axelor.apps.base.service.CurrencyService;
|
||||
import com.axelor.apps.base.service.ProductService;
|
||||
@@ -38,32 +44,39 @@ import com.axelor.apps.base.service.ShippingCoefService;
|
||||
import com.axelor.apps.base.service.TradingNameService;
|
||||
import com.axelor.apps.base.service.UnitConversionService;
|
||||
import com.axelor.apps.base.service.administration.SequenceService;
|
||||
import com.axelor.apps.base.service.BarcodeGeneratorService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.purchase.db.ImportationFolder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrderLine;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrderLineTax;
|
||||
import com.axelor.apps.purchase.db.PurchaseRequest;
|
||||
import com.axelor.apps.purchase.db.repo.ImportationFolderRepository;
|
||||
import com.axelor.apps.purchase.db.repo.PurchaseOrderRepository;
|
||||
import com.axelor.apps.purchase.db.repo.PurchaseOrderLineRepository;
|
||||
import com.axelor.apps.purchase.db.repo.PurchaseOrderRepository;
|
||||
import com.axelor.apps.purchase.db.repo.PurchaseRequestRepository;
|
||||
import com.axelor.apps.purchase.exception.IExceptionMessage;
|
||||
import com.axelor.apps.purchase.report.IReport;
|
||||
import com.axelor.apps.purchase.service.app.AppPurchaseService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
import com.axelor.auth.AuthUtils;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.db.JPA;
|
||||
import com.axelor.dms.db.DMSFile;
|
||||
import com.axelor.dms.db.repo.DMSFileRepository;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.meta.MetaFiles;
|
||||
import com.axelor.meta.db.MetaFile;
|
||||
import com.axelor.meta.db.repo.MetaAttachmentRepository;
|
||||
import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.meta.schema.actions.ActionView.ActionViewBuilder;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import com.axelor.apps.base.db.CancelReason;
|
||||
import wslite.json.JSONException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
@@ -73,11 +86,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import javax.validation.ValidationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import wslite.json.JSONException;
|
||||
|
||||
public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
|
||||
@@ -98,6 +110,12 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
@Inject protected AppBaseService appBaseService;
|
||||
@Inject private MetaFiles metaFiles;
|
||||
|
||||
@Inject private PurchaseRequestRepository purchaseRequestRepo;
|
||||
|
||||
@Inject private MetaAttachmentRepository metaAttachmentRepository;
|
||||
|
||||
@Inject private DMSFileRepository dmsFileRepository;
|
||||
|
||||
@Override
|
||||
public PurchaseOrder _computePurchaseOrderLines(PurchaseOrder purchaseOrder)
|
||||
throws AxelorException {
|
||||
@@ -185,7 +203,13 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
purchaseOrder.getTaxTotal().add(purchaseOrderLineVat.getTaxTotal()));
|
||||
}
|
||||
|
||||
purchaseOrder.setInTaxTotal(purchaseOrder.getExTaxTotal().add(purchaseOrder.getTaxTotal().add(purchaseOrder.getStamp().add(purchaseOrder.getFixTax()))));
|
||||
purchaseOrder.setInTaxTotal(
|
||||
purchaseOrder
|
||||
.getExTaxTotal()
|
||||
.add(
|
||||
purchaseOrder
|
||||
.getTaxTotal()
|
||||
.add(purchaseOrder.getStamp().add(purchaseOrder.getFixTax()))));
|
||||
|
||||
logger.debug(
|
||||
"Montant de la facture: HTT = {}, HT = {}, TVA = {}, TTC = {}",
|
||||
@@ -218,6 +242,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
LocalDate deliveryDate,
|
||||
String internalReference,
|
||||
String externalReference,
|
||||
String notes,
|
||||
LocalDate orderDate,
|
||||
PriceList priceList,
|
||||
Partner supplierPartner,
|
||||
@@ -236,6 +261,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
purchaseOrder.setDeliveryDate(deliveryDate);
|
||||
purchaseOrder.setInternalReference(internalReference);
|
||||
purchaseOrder.setExternalReference(externalReference);
|
||||
purchaseOrder.setNotes(notes);
|
||||
purchaseOrder.setOrderDate(orderDate);
|
||||
purchaseOrder.setPriceList(priceList);
|
||||
purchaseOrder.setTradingName(tradingName);
|
||||
@@ -310,7 +336,11 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
|
||||
Boolean checkTcoEnabled = Beans.get(AppBaseService.class).getAppBase().getEnableCheckTco();
|
||||
|
||||
if(checkTcoEnabled){
|
||||
if (checkTcoEnabled
|
||||
&& !appPurchaseService
|
||||
.getAppPurchase()
|
||||
.getUsersExludedFromTco()
|
||||
.contains(AuthUtils.getUser())) {
|
||||
this.checkTcoToApprove(purchaseOrder);
|
||||
}
|
||||
|
||||
@@ -353,11 +383,18 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
|
||||
String numSeq = "";
|
||||
String externalRef = "";
|
||||
String description = "";
|
||||
int statusSelect = 1;
|
||||
|
||||
for (PurchaseOrder purchaseOrderLocal : purchaseOrderList) {
|
||||
if (!numSeq.isEmpty()) {
|
||||
numSeq += "-";
|
||||
}
|
||||
numSeq += purchaseOrderLocal.getPurchaseOrderSeq();
|
||||
numSeq +=
|
||||
purchaseOrderLocal.getPurchaseOrderSeq()
|
||||
+ (purchaseOrderLocal.getInternalReference() == null
|
||||
? ""
|
||||
: purchaseOrderLocal.getInternalReference() + "-");
|
||||
|
||||
if (!externalRef.isEmpty()) {
|
||||
externalRef += "|";
|
||||
@@ -365,6 +402,10 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
if (purchaseOrderLocal.getExternalReference() != null) {
|
||||
externalRef += purchaseOrderLocal.getExternalReference();
|
||||
}
|
||||
if (purchaseOrderLocal.getNotes() != null) {
|
||||
description += purchaseOrderLocal.getNotes() + " ";
|
||||
}
|
||||
statusSelect = purchaseOrderLocal.getStatusSelect();
|
||||
}
|
||||
|
||||
PurchaseOrder purchaseOrderMerged =
|
||||
@@ -376,6 +417,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
null,
|
||||
numSeq,
|
||||
externalRef,
|
||||
description,
|
||||
LocalDate.now(),
|
||||
priceList,
|
||||
supplierPartner,
|
||||
@@ -385,13 +427,43 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
|
||||
this.computePurchaseOrder(purchaseOrderMerged);
|
||||
|
||||
purchaseOrderMerged.setStatusSelect(statusSelect);
|
||||
|
||||
purchaseOrderRepo.save(purchaseOrderMerged);
|
||||
|
||||
this.attachAttachment(purchaseOrderList, purchaseOrderMerged);
|
||||
|
||||
this.removeOldPurchaseOrders(purchaseOrderList);
|
||||
|
||||
return purchaseOrderMerged;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void attachAttachment(List<PurchaseOrder> ancientPOs, PurchaseOrder newPO) {
|
||||
// start attachement heritage
|
||||
DMSFile dmsP = new DMSFile();
|
||||
dmsP.setFileName(newPO.getPurchaseOrderSeq());
|
||||
dmsP.setRelatedId(newPO.getId());
|
||||
dmsP.setIsDirectory(true);
|
||||
dmsP.setParent(dmsFileRepository.find(Long.parseLong("1")));
|
||||
dmsP.setRelatedModel(newPO.getClass().getCanonicalName());
|
||||
DMSFile dmsFileP = dmsFileRepository.save(dmsP);
|
||||
|
||||
for (PurchaseOrder purchaseOrder : ancientPOs) {
|
||||
List<DMSFile> dmsFiles =
|
||||
dmsFileRepository
|
||||
.all()
|
||||
.filter("self.relatedId = ?1 and self.isDirectory = false", purchaseOrder.getId())
|
||||
.fetch();
|
||||
|
||||
for (DMSFile dmsFile : dmsFiles) {
|
||||
dmsFile.setParent(dmsFileP);
|
||||
dmsFile.setRelatedId(newPO.getId());
|
||||
dmsFileRepository.save(dmsFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attachment of all purchase order lines to new purchase order
|
||||
public void attachToNewPurchaseOrder(
|
||||
List<PurchaseOrder> purchaseOrderList, PurchaseOrder purchaseOrderMerged) {
|
||||
@@ -405,10 +477,30 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void attachPurchaseRequestToNewOrder(
|
||||
Set<PurchaseRequest> purchaseRequestSet,
|
||||
PurchaseOrder purchaseOrderMerged,
|
||||
List<PurchaseOrder> purchaseOrderList) {
|
||||
for (PurchaseRequest purchaseRequest : purchaseRequestSet) {
|
||||
|
||||
List<Long> ids =
|
||||
purchaseOrderList.stream().map(PurchaseOrder::getId).collect(Collectors.toList());
|
||||
Set<PurchaseOrder> purchaseOrders = purchaseRequest.getPurchaseOrderSet();
|
||||
purchaseRequest.getPurchaseOrderSet().removeIf(t -> ids.contains(t.getId()));
|
||||
purchaseOrders.add(purchaseOrderMerged);
|
||||
purchaseRequest.setPurchaseOrderSet(purchaseOrders);
|
||||
Beans.get(PurchaseRequestRepository.class).save(purchaseRequest);
|
||||
}
|
||||
purchaseOrderMerged.setPurchaseRequestSet(purchaseRequestSet);
|
||||
}
|
||||
|
||||
// Remove old purchase orders after merge
|
||||
public void removeOldPurchaseOrders(List<PurchaseOrder> purchaseOrderList) {
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrderList) {
|
||||
purchaseOrderRepo.remove(purchaseOrder);
|
||||
// purchaseOrderRepo.remove(purchaseOrder);
|
||||
purchaseOrder.setArchived(true);
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,10 +571,16 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void validatePurchaseOrder(PurchaseOrder purchaseOrder) throws AxelorException, MalformedURLException, JSONException {
|
||||
Boolean checkTcoAcceptedEnabled = Beans.get(AppBaseService.class).getAppBase().getEnableCheckTcoAccpeted();
|
||||
|
||||
if(checkTcoAcceptedEnabled){
|
||||
public void validatePurchaseOrder(PurchaseOrder purchaseOrder)
|
||||
throws AxelorException, MalformedURLException, JSONException {
|
||||
Boolean checkTcoAcceptedEnabled =
|
||||
Beans.get(AppBaseService.class).getAppBase().getEnableCheckTcoAccpeted();
|
||||
// && appPurchaseService.getAppPurchase().getUsersExludedFromTcoList()
|
||||
if (checkTcoAcceptedEnabled
|
||||
&& !appPurchaseService
|
||||
.getAppPurchase()
|
||||
.getUsersExludedFromTco()
|
||||
.contains(AuthUtils.getUser())) {
|
||||
checkAllTco(purchaseOrder);
|
||||
}
|
||||
computePurchaseOrder(purchaseOrder);
|
||||
@@ -495,17 +593,48 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
|
||||
updateCostPrice(purchaseOrder);
|
||||
|
||||
if(purchaseOrder.getImportationFolder() != null){
|
||||
List<PurchaseOrder> purchaseOrders = purchaseOrder.getImportationFolder().getPurchaseOrderList();
|
||||
if (purchaseOrder.getImportationFolder() != null) {
|
||||
List<PurchaseOrder> purchaseOrders =
|
||||
purchaseOrder.getImportationFolder().getPurchaseOrderList();
|
||||
ImportationFolder importationFolder = purchaseOrder.getImportationFolder();
|
||||
calculateSum(purchaseOrders, importationFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void addFareToImportationFolder(PurchaseOrder purchaseOrder,BigDecimal amount) throws AxelorException, MalformedURLException, JSONException {
|
||||
|
||||
Product product = Beans.get(ProductRepository.class).find(new Long("8931"));
|
||||
Unit unit = Beans.get(UnitRepository.class).find(new Long("4"));
|
||||
TaxLine taxLine = Beans.get(TaxLineRepository.class).find(new Long("27"));
|
||||
|
||||
PurchaseOrderLine purchaseOrderLine = Beans.get(PurchaseOrderLineService.class)
|
||||
.createPurchaseOrderLine(
|
||||
purchaseOrder,
|
||||
product,
|
||||
product.getName(),
|
||||
"",
|
||||
BigDecimal.ONE,
|
||||
unit
|
||||
);
|
||||
purchaseOrderLine.setPrice(amount);
|
||||
purchaseOrderLine.setPriceDiscounted(amount);
|
||||
purchaseOrderLine.setExTaxTotal(amount);
|
||||
purchaseOrderLine.setInTaxTotal(amount);
|
||||
purchaseOrderLine.setCompanyExTaxTotal(amount);
|
||||
purchaseOrderLine.setCompanyInTaxTotal(amount);
|
||||
purchaseOrderLine.setTaxLine(taxLine);
|
||||
purchaseOrder.addPurchaseOrderLineListItem(purchaseOrderLine);
|
||||
|
||||
validatePurchaseOrder(purchaseOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void finishPurchaseOrder(PurchaseOrder purchaseOrder) {
|
||||
public void finishPurchaseOrder(PurchaseOrder purchaseOrder, String cancelReasonStr) {
|
||||
purchaseOrder.setStatusSelect(PurchaseOrderRepository.STATUS_FINISHED);
|
||||
purchaseOrder.setFinishReasonStr(cancelReasonStr);
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
}
|
||||
|
||||
@@ -517,163 +646,19 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void calculateSum(List<PurchaseOrder> purchaseOrders,ImportationFolder importationFolder) throws AxelorException {
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
|
||||
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrders) {
|
||||
if(purchaseOrder.getCurrency().getId() == 148 || purchaseOrder.getCurrency().getId() == 46){
|
||||
Currency currency = Beans.get(CurrencyRepository.class).find(purchaseOrder.getCurrency().getId());
|
||||
Currency currencyDzd = Beans.get(CurrencyRepository.class).findByCode("DZD");
|
||||
BigDecimal currencyAmount = Beans.get(CurrencyService.class).getCurrencyConversionRate(currency, currencyDzd);
|
||||
|
||||
currencyAmount = currencyAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
BigDecimal finalAmount = purchaseOrder.getExTaxTotal().multiply(currencyAmount);
|
||||
BigDecimal finalTaxAmount = purchaseOrder.getTaxTotal().multiply(currencyAmount);
|
||||
BigDecimal finalTotalAmount = purchaseOrder.getInTaxTotal().multiply(currencyAmount);
|
||||
|
||||
amount = amount.add(finalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
taxAmount = taxAmount.add(finalTaxAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
totalAmount = totalAmount.add(finalTotalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
}else{
|
||||
amount = amount.add(purchaseOrder.getExTaxTotal());
|
||||
taxAmount = taxAmount.add(purchaseOrder.getTaxTotal());
|
||||
totalAmount = totalAmount.add(purchaseOrder.getInTaxTotal());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
importationFolder.setAmount(amount);
|
||||
importationFolder.setTaxAmount(taxAmount);
|
||||
importationFolder.setTotalAmount(totalAmount);
|
||||
|
||||
importationFolderRepo.save(importationFolder);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void cancelReasonPurchaseOrder(
|
||||
PurchaseOrder purchaseOrder, CancelReason cancelReason, String cancelReasonStr){
|
||||
|
||||
purchaseOrder.setStatusSelect(PurchaseOrderRepository.STATUS_CANCELED);
|
||||
purchaseOrder.setCancelReason(cancelReason);
|
||||
if (Strings.isNullOrEmpty(cancelReasonStr)) {
|
||||
purchaseOrder.setCancelReasonStr(cancelReason.getName());
|
||||
} else {
|
||||
purchaseOrder.setCancelReasonStr(cancelReasonStr);
|
||||
}
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
}
|
||||
|
||||
|
||||
public void checkAllTco(PurchaseOrder purchaseOrder) throws AxelorException{
|
||||
/*vérifier si tous les tco sont validées */
|
||||
PurchaseOrderLineService purchaseOrderLineService = Beans.get(PurchaseOrderLineService.class);
|
||||
javax.persistence.Query dateQuery =
|
||||
com.axelor
|
||||
.db
|
||||
.JPA
|
||||
.em()
|
||||
.createNativeQuery(
|
||||
"SELECT a.id FROM purchase_purchase_order_line as a "+
|
||||
"left join public.suppliermanagement_purchase_order_supplier_line as b on a.id = b.purchase_order_line "+
|
||||
"where a.purchase_order = "+purchaseOrder.getId()+" and b.state_select = 3 and ( a.archived is not true or b.archived is not true ) "+
|
||||
"group by a.id , b.state_select ");
|
||||
List<BigInteger> purchaseOrdeLineAccepted = dateQuery.getResultList();
|
||||
|
||||
javax.persistence.Query dateQueryTow =
|
||||
com.axelor
|
||||
.db
|
||||
.JPA
|
||||
.em()
|
||||
.createNativeQuery(
|
||||
"SELECT a.id FROM purchase_purchase_order_line as a "+
|
||||
"left join public.suppliermanagement_purchase_order_supplier_line as b on a.id = b.purchase_order_line "+
|
||||
"where a.purchase_order = "+purchaseOrder.getId()+" and ( a.archived is not true or b.archived is not true ) "+
|
||||
"group by a.id");
|
||||
List<BigInteger> purchaseOrdeLineAll = dateQueryTow.getResultList();
|
||||
|
||||
// subtracting Lists
|
||||
Set<BigInteger> purchaseOrdeLineIdsDiff = purchaseOrdeLineAll.stream()
|
||||
.filter(item -> !purchaseOrdeLineAccepted.contains(item))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<String> Products = new ArrayList<>();
|
||||
for (BigInteger id : purchaseOrdeLineIdsDiff) {
|
||||
PurchaseOrderLine purchaseOrderLine = Beans.get(PurchaseOrderLineRepository.class).find(id.longValue());
|
||||
Products.add(purchaseOrderLine.getProductName());
|
||||
}
|
||||
|
||||
if(purchaseOrdeLineAccepted.size() != purchaseOrdeLineAll.size()){
|
||||
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.TCO),
|
||||
Products);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void checkTcoToApprove(PurchaseOrder purchaseOrder) throws AxelorException{
|
||||
/*vérifier si tous les tco sont validées */
|
||||
javax.persistence.Query dateQuery =
|
||||
com.axelor
|
||||
.db
|
||||
.JPA
|
||||
.em()
|
||||
.createNativeQuery("SELECT A.product "+
|
||||
"FROM PURCHASE_PURCHASE_ORDER_LINE AS A "+
|
||||
"LEFT JOIN PUBLIC.SUPPLIERMANAGEMENT_PURCHASE_ORDER_SUPPLIER_LINE AS B "+
|
||||
"ON A.ID = B.PURCHASE_ORDER_LINE "+
|
||||
"WHERE A.PURCHASE_ORDER = "+purchaseOrder.getId()+" AND (A.ARCHIVED IS NOT TRUE OR B.ARCHIVED IS NOT TRUE) and B.ID is null "+
|
||||
"GROUP BY A.ID, B.ID");
|
||||
List<BigInteger> productsResult = dateQuery.getResultList();
|
||||
|
||||
|
||||
List<String> products = new ArrayList<>();
|
||||
for (BigInteger id : productsResult) {
|
||||
Product product = Beans.get(ProductRepository.class).find(id.longValue());
|
||||
products.add(product.getFullName());
|
||||
}
|
||||
|
||||
if(products.size() > 0){
|
||||
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.NO_TCO),products);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
public ImportationFolder generateImportationFolder(PurchaseOrder purchaseOrder) throws AxelorException {
|
||||
ImportationFolder importationFolder = new ImportationFolder();
|
||||
List<PurchaseOrder> purchaseOrders = new ArrayList<PurchaseOrder>();
|
||||
purchaseOrders.add(purchaseOrder);
|
||||
importationFolder.setPurchaseOrderList(purchaseOrders);
|
||||
importationFolder.setCurrency(purchaseOrder.getCurrency());
|
||||
importationFolder.setProgress(10);
|
||||
importationFolder.setSupplierPartner(purchaseOrder.getSupplierPartner());
|
||||
|
||||
|
||||
public void calculateSum(List<PurchaseOrder> purchaseOrders, ImportationFolder importationFolder)
|
||||
throws AxelorException {
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
|
||||
|
||||
|
||||
if(purchaseOrder.getCurrency().getId() != 41){
|
||||
Currency currency = Beans.get(CurrencyRepository.class).find(purchaseOrder.getCurrency().getId());
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrders) {
|
||||
if (purchaseOrder.getCurrency().getId() == 148 || purchaseOrder.getCurrency().getId() == 46) {
|
||||
Currency currency =
|
||||
Beans.get(CurrencyRepository.class).find(purchaseOrder.getCurrency().getId());
|
||||
Currency currencyDzd = Beans.get(CurrencyRepository.class).findByCode("DZD");
|
||||
BigDecimal currencyAmount = Beans.get(CurrencyService.class).getCurrencyConversionRate(currency, currencyDzd);
|
||||
BigDecimal currencyAmount =
|
||||
Beans.get(CurrencyService.class).getCurrencyConversionRate(currency, currencyDzd);
|
||||
|
||||
currencyAmount = currencyAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
@@ -685,12 +670,170 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
taxAmount = taxAmount.add(finalTaxAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
totalAmount = totalAmount.add(finalTotalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
amount = amount.add(purchaseOrder.getExTaxTotal());
|
||||
taxAmount = taxAmount.add(purchaseOrder.getTaxTotal());
|
||||
totalAmount = totalAmount.add(purchaseOrder.getInTaxTotal());
|
||||
}
|
||||
}
|
||||
|
||||
importationFolder.setAmount(amount);
|
||||
importationFolder.setTaxAmount(taxAmount);
|
||||
importationFolder.setTotalAmount(totalAmount);
|
||||
|
||||
importationFolderRepo.save(importationFolder);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setStandByPurchaseOrder(PurchaseOrder purchaseOrder, String standByReasonStr) {
|
||||
|
||||
purchaseOrder.setStatusSelect(PurchaseOrderRepository.STATUS_STANDBY);
|
||||
purchaseOrder.setStandbyRaison(standByReasonStr);
|
||||
purchaseOrder.setStandbyByUser(AuthUtils.getUser());
|
||||
purchaseOrder.setStandbyDate(Beans.get(AppBaseService.class).getTodayDate());
|
||||
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void cancelReasonPurchaseOrder(
|
||||
PurchaseOrder purchaseOrder, CancelReason cancelReason, String cancelReasonStr) {
|
||||
|
||||
purchaseOrder.setStatusSelect(PurchaseOrderRepository.STATUS_CANCELED);
|
||||
purchaseOrder.setCancelReason(cancelReason);
|
||||
if (Strings.isNullOrEmpty(cancelReasonStr)) {
|
||||
purchaseOrder.setCancelReasonStr(cancelReason.getName());
|
||||
} else {
|
||||
purchaseOrder.setCancelReasonStr(cancelReasonStr);
|
||||
}
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
}
|
||||
|
||||
public void checkAllTco(PurchaseOrder purchaseOrder) throws AxelorException {
|
||||
/*vérifier si tous les tco sont validées */
|
||||
PurchaseOrderLineService purchaseOrderLineService = Beans.get(PurchaseOrderLineService.class);
|
||||
javax.persistence.Query dateQuery =
|
||||
com.axelor
|
||||
.db
|
||||
.JPA
|
||||
.em()
|
||||
.createNativeQuery(
|
||||
"SELECT a.id FROM purchase_purchase_order_line as a "
|
||||
+ "left join public.suppliermanagement_purchase_order_supplier_line as b on a.id = b.purchase_order_line "
|
||||
+ "where a.purchase_order = "
|
||||
+ purchaseOrder.getId()
|
||||
+ " and ((b.state_select = 3 and b.currency = 41) or (b.state_select = 7 and b.currency != 41)) and ( a.archived is not true or b.archived is not true ) "
|
||||
+ "group by a.id , b.state_select ");
|
||||
List<BigInteger> purchaseOrdeLineAccepted = dateQuery.getResultList();
|
||||
|
||||
javax.persistence.Query dateQueryTow =
|
||||
com.axelor
|
||||
.db
|
||||
.JPA
|
||||
.em()
|
||||
.createNativeQuery(
|
||||
"SELECT a.id FROM purchase_purchase_order_line as a "
|
||||
+ "left join public.suppliermanagement_purchase_order_supplier_line as b on a.id = b.purchase_order_line "
|
||||
+ "where a.purchase_order = "
|
||||
+ purchaseOrder.getId()
|
||||
+ " and ( a.archived is not true or b.archived is not true ) "
|
||||
+ "group by a.id");
|
||||
List<BigInteger> purchaseOrdeLineAll = dateQueryTow.getResultList();
|
||||
|
||||
// subtracting Lists
|
||||
Set<BigInteger> purchaseOrdeLineIdsDiff =
|
||||
purchaseOrdeLineAll
|
||||
.stream()
|
||||
.filter(item -> !purchaseOrdeLineAccepted.contains(item))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<String> Products = new ArrayList<>();
|
||||
for (BigInteger id : purchaseOrdeLineIdsDiff) {
|
||||
PurchaseOrderLine purchaseOrderLine =
|
||||
Beans.get(PurchaseOrderLineRepository.class).find(id.longValue());
|
||||
Products.add(purchaseOrderLine.getProductName());
|
||||
}
|
||||
|
||||
if (purchaseOrdeLineAccepted.size() != purchaseOrdeLineAll.size()) {
|
||||
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.TCO),
|
||||
Products);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkTcoToApprove(PurchaseOrder purchaseOrder) throws AxelorException {
|
||||
/*vérifier si tous les tco sont validées */
|
||||
javax.persistence.Query dateQuery =
|
||||
com.axelor
|
||||
.db
|
||||
.JPA
|
||||
.em()
|
||||
.createNativeQuery(
|
||||
"SELECT A.product "
|
||||
+ "FROM PURCHASE_PURCHASE_ORDER_LINE AS A "
|
||||
+ "LEFT JOIN PUBLIC.SUPPLIERMANAGEMENT_PURCHASE_ORDER_SUPPLIER_LINE AS B "
|
||||
+ "ON A.ID = B.PURCHASE_ORDER_LINE "
|
||||
+ "WHERE A.PURCHASE_ORDER = "
|
||||
+ purchaseOrder.getId()
|
||||
+ " AND (A.ARCHIVED IS NOT TRUE OR B.ARCHIVED IS NOT TRUE) and B.ID is null "
|
||||
+ "GROUP BY A.ID, B.ID");
|
||||
List<BigInteger> productsResult = dateQuery.getResultList();
|
||||
|
||||
List<String> products = new ArrayList<>();
|
||||
for (BigInteger id : productsResult) {
|
||||
Product product = Beans.get(ProductRepository.class).find(id.longValue());
|
||||
products.add(product.getFullName());
|
||||
}
|
||||
|
||||
if (products.size() > 0) {
|
||||
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.NO_TCO),
|
||||
products);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ImportationFolder generateImportationFolder(PurchaseOrder purchaseOrder)
|
||||
throws AxelorException {
|
||||
ImportationFolder importationFolder = new ImportationFolder();
|
||||
List<PurchaseOrder> purchaseOrders = new ArrayList<PurchaseOrder>();
|
||||
purchaseOrders.add(purchaseOrder);
|
||||
importationFolder.setPurchaseOrderList(purchaseOrders);
|
||||
importationFolder.setCurrency(purchaseOrder.getCurrency());
|
||||
importationFolder.setProgress(10);
|
||||
importationFolder.setSupplierPartner(purchaseOrder.getSupplierPartner());
|
||||
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
|
||||
if (purchaseOrder.getCurrency().getId() != 41) {
|
||||
Currency currency =
|
||||
Beans.get(CurrencyRepository.class).find(purchaseOrder.getCurrency().getId());
|
||||
Currency currencyDzd = Beans.get(CurrencyRepository.class).findByCode("DZD");
|
||||
BigDecimal currencyAmount =
|
||||
Beans.get(CurrencyService.class).getCurrencyConversionRate(currency, currencyDzd);
|
||||
|
||||
currencyAmount = currencyAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
BigDecimal finalAmount = purchaseOrder.getExTaxTotal().multiply(currencyAmount);
|
||||
BigDecimal finalTaxAmount = purchaseOrder.getTaxTotal().multiply(currencyAmount);
|
||||
BigDecimal finalTotalAmount = purchaseOrder.getInTaxTotal().multiply(currencyAmount);
|
||||
|
||||
amount = amount.add(finalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
taxAmount = taxAmount.add(finalTaxAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
totalAmount = totalAmount.add(finalTotalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
} else {
|
||||
amount = amount.add(purchaseOrder.getExTaxTotal());
|
||||
taxAmount = taxAmount.add(purchaseOrder.getTaxTotal());
|
||||
totalAmount = totalAmount.add(purchaseOrder.getInTaxTotal());
|
||||
}
|
||||
|
||||
importationFolder.setAmount(amount);
|
||||
importationFolder.setTaxAmount(taxAmount);
|
||||
@@ -704,7 +847,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setPurchaseOrderBarCodeSeq(PurchaseOrder purchaseOrder) throws AxelorException{
|
||||
public void setPurchaseOrderBarCodeSeq(PurchaseOrder purchaseOrder) throws AxelorException {
|
||||
|
||||
if (purchaseOrder.getBarCodeSeq() == null
|
||||
&& purchaseOrder.getStatusSelect() != PurchaseOrderRepository.STATUS_DRAFT) {
|
||||
@@ -712,16 +855,17 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
boolean addPadding = false;
|
||||
InputStream inStream = null;
|
||||
|
||||
inStream =
|
||||
barcodeGeneratorService.createBarCode(
|
||||
inStream =
|
||||
barcodeGeneratorService.createBarCode(
|
||||
purchaseOrder.getPurchaseOrderSeq(),
|
||||
appBaseService.getAppBase().getBarcodeTypeConfigPurchaseOrderSeq(),
|
||||
addPadding);
|
||||
appBaseService.getAppBase().getBarcodeTypeConfigPurchaseOrderSeq(),
|
||||
addPadding);
|
||||
|
||||
if (inStream != null) {
|
||||
MetaFile barcodeFile =
|
||||
metaFiles.upload(inStream, String.format("PurchaseOrderSeqBarCode%d.png",purchaseOrder.getId()));
|
||||
purchaseOrder.setBarCodeSeq(barcodeFile);
|
||||
metaFiles.upload(
|
||||
inStream, String.format("PurchaseOrderSeqBarCode%d.png", purchaseOrder.getId()));
|
||||
purchaseOrder.setBarCodeSeq(barcodeFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -729,14 +873,11 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
throw new ValidationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void createPurchaseOrderBarCodeSeq(PurchaseOrder purchaseOrder) throws AxelorException{
|
||||
public void createPurchaseOrderBarCodeSeq(PurchaseOrder purchaseOrder) throws AxelorException {
|
||||
this.setPurchaseOrderBarCodeSeq(purchaseOrder);
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.apps.purchase.db.PurchaseRequest;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public interface PurchaseRequestService {
|
||||
@@ -29,7 +30,8 @@ public interface PurchaseRequestService {
|
||||
|
||||
public void acceptRequest(List<PurchaseRequest> purchaseRequests);
|
||||
|
||||
public void purchaseRequestsAssignedToUser(List<Long> requestIds, User user);
|
||||
public void purchaseRequestsAssignedToUser(
|
||||
List<Long> requestIds, HashSet<User> user, Boolean canDuplicatePO, int limitPo);
|
||||
|
||||
public List<PurchaseOrder> generatePo(
|
||||
List<PurchaseRequest> purchaseRequests, Boolean groupBySupplier, Boolean groupByProduct)
|
||||
|
||||
@@ -91,25 +91,25 @@ public class PurchaseRequestServiceImpl implements PurchaseRequestService {
|
||||
purchaseOrder = purchaseOrderMap.get(key);
|
||||
} else {
|
||||
purchaseOrder = createPurchaseOrder(purchaseRequest);
|
||||
// SOPHAL
|
||||
setProjectPurchaseOrder(purchaseOrder, purchaseRequest);
|
||||
// SOPHAL
|
||||
setProjectPurchaseOrder(purchaseOrder, purchaseRequest);
|
||||
purchaseOrder.setNotes(purchaseRequest.getDescription());
|
||||
// sophal set purchase request
|
||||
// purchaseOrder.setPurchaseRequest(purchaseRequest.getId());
|
||||
// purchaseOrder.setPurchaseRequest(purchaseRequest.getId());
|
||||
// sophal
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
// SOPHAL
|
||||
// SOPHAL
|
||||
key = key == null ? purchaseRequest.getId().toString() : key;
|
||||
purchaseOrderMap.put(key, purchaseOrder);
|
||||
}
|
||||
|
||||
if (purchaseOrder == null) {
|
||||
purchaseOrder = createPurchaseOrder(purchaseRequest);
|
||||
// SOPHAL
|
||||
setProjectPurchaseOrder(purchaseOrder, purchaseRequest);
|
||||
// SOPHAL
|
||||
setProjectPurchaseOrder(purchaseOrder, purchaseRequest);
|
||||
purchaseOrder.setNotes(purchaseRequest.getDescription());
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
// SOPHAL
|
||||
// SOPHAL
|
||||
}
|
||||
|
||||
for (PurchaseRequestLine purchaseRequestLine : purchaseRequest.getPurchaseRequestLineList()) {
|
||||
@@ -142,8 +142,9 @@ public class PurchaseRequestServiceImpl implements PurchaseRequestService {
|
||||
purchaseOrderRepo.save(purchaseOrder);
|
||||
Set<PurchaseOrder> hash_Set = new HashSet<PurchaseOrder>();
|
||||
hash_Set.add(purchaseOrder);
|
||||
purchaseRequest.setPurchaseOrderSet(hash_Set);
|
||||
purchaseRequest.addPurchaseOrderSetItem(purchaseOrder);
|
||||
purchaseRequest.setAssignedToUser(AuthUtils.getUser());
|
||||
purchaseRequest.addBuyer(AuthUtils.getUser());
|
||||
purchaseRequestRepo.save(purchaseRequest);
|
||||
}
|
||||
List<PurchaseOrder> purchaseOrders =
|
||||
@@ -177,6 +178,7 @@ public class PurchaseRequestServiceImpl implements PurchaseRequestService {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"", // notes
|
||||
LocalDate.now(),
|
||||
null,
|
||||
purchaseRequest.getSupplierUser(),
|
||||
@@ -216,12 +218,16 @@ public class PurchaseRequestServiceImpl implements PurchaseRequestService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void purchaseRequestsAssignedToUser(List<Long> requestIds, User user) {
|
||||
public void purchaseRequestsAssignedToUser(
|
||||
List<Long> requestIds, HashSet<User> users, Boolean canDuplicatePO, int limitPo) {
|
||||
|
||||
for (int i = 0; i < requestIds.size(); i++) {
|
||||
long requestId = ((Number) requestIds.get(i)).longValue();
|
||||
PurchaseRequest purchaseRequest = purchaseRequestRepo.find(requestId);
|
||||
purchaseRequest.setAssignedToUser(user);
|
||||
// purchaseRequest.setAssignedToUser(user);
|
||||
purchaseRequest.setBuyers(users.stream().collect(Collectors.toSet()));
|
||||
purchaseRequest.setLimitPo(limitPo);
|
||||
purchaseRequest.setCanDuplicatePo(canDuplicatePO);
|
||||
purchaseRequestRepo.save(purchaseRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.axelor.apps.purchase.service.print;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.axelor.apps.base.exceptions.IExceptionMessage;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.purchase.db.ImportationFolder;
|
||||
import com.axelor.apps.purchase.report.IReport;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
|
||||
import com.axelor.apps.tool.ModelTool;
|
||||
import com.axelor.apps.tool.ThrowConsumer;
|
||||
import com.axelor.apps.tool.file.PdfTool;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
|
||||
public class ImportationFolderPrintService {
|
||||
|
||||
public String printCostPriceSheet(ImportationFolder importationFolder, String formatPdf)
|
||||
throws AxelorException {
|
||||
|
||||
String fileName = getImportationFolderName(false, formatPdf);
|
||||
|
||||
return PdfTool.getFileLinkFromPdfFile(print(importationFolder, formatPdf), fileName);
|
||||
}
|
||||
|
||||
public String printImportationfolders(List<Long> ids) throws IOException {
|
||||
List<File> importationFolders = new ArrayList<>();
|
||||
ModelTool.apply(
|
||||
ImportationFolder.class,
|
||||
ids,
|
||||
new ThrowConsumer<ImportationFolder>() {
|
||||
|
||||
|
||||
public void accept(ImportationFolder importationFolder) throws Exception {
|
||||
importationFolders.add(print(importationFolder, ReportSettings.FORMAT_PDF));
|
||||
}
|
||||
});
|
||||
String fileName = getImportationFolderName(true, ReportSettings.FORMAT_PDF);
|
||||
return PdfTool.mergePdfToFileLink(importationFolders, fileName);
|
||||
}
|
||||
|
||||
public File print(ImportationFolder importationFolder, String formatPdf) throws AxelorException {
|
||||
ReportSettings reportSettings = prepareReportSettings(importationFolder, formatPdf);
|
||||
return reportSettings.generate().getFile();
|
||||
}
|
||||
|
||||
public ReportSettings prepareReportSettings(ImportationFolder importationFolder, String formatPdf)
|
||||
throws AxelorException {
|
||||
if (importationFolder.getPrintingSettings() == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD,
|
||||
String.format(
|
||||
I18n.get(IExceptionMessage.UNIT_CONVERSION_2),
|
||||
importationFolder.getName()),
|
||||
importationFolder);
|
||||
}
|
||||
String locale = ReportSettings.getPrintingLocale(null);
|
||||
String title = getFileName(importationFolder);
|
||||
ReportSettings reportSetting =
|
||||
ReportFactory.createReport(IReport.COST_PRICE_SHEET, title + " - ${date}");
|
||||
|
||||
|
||||
return reportSetting
|
||||
.addParam("importationFolderId", importationFolder.getId())
|
||||
.addParam("Locale", locale)
|
||||
.addParam("HeaderHeight", importationFolder.getPrintingSettings().getPdfHeaderHeight())
|
||||
.addParam("FooterHeight", importationFolder.getPrintingSettings().getPdfFooterHeight())
|
||||
.addFormat(formatPdf);
|
||||
}
|
||||
|
||||
protected String getImportationFolderName(boolean plural, String formatPdf) {
|
||||
return I18n.get(plural ? "Importation folders" : "Importation folder")
|
||||
+ " - "
|
||||
+ Beans.get(AppBaseService.class).getTodayDate().format(DateTimeFormatter.BASIC_ISO_DATE)
|
||||
+ "."
|
||||
+ formatPdf;
|
||||
}
|
||||
|
||||
public String getFileName(ImportationFolder importationFolder) {
|
||||
return I18n.get("Importation folder")
|
||||
+ " "
|
||||
+ importationFolder.getName();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,8 @@ public interface PurchaseRequestPrintService {
|
||||
*/
|
||||
String printPurchaseRequests(List<Long> ids) throws IOException;
|
||||
|
||||
String printPurchaseRequest(PurchaseRequest purchaseRequest, String formatPdf) throws AxelorException;
|
||||
String printPurchaseRequest(PurchaseRequest purchaseRequest, String formatPdf)
|
||||
throws AxelorException;
|
||||
|
||||
String getFileName(PurchaseRequest purchaseRequest);
|
||||
}
|
||||
|
||||
@@ -1,75 +1,69 @@
|
||||
package com.axelor.apps.purchase.web;
|
||||
|
||||
import com.axelor.apps.message.service.MailAccountService;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import com.axelor.apps.message.service.MailAccountService;
|
||||
|
||||
import javax.json.JsonObject;
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
public class EmailUtil {
|
||||
|
||||
/**
|
||||
* Utility method to send simple HTML email
|
||||
* @param session
|
||||
* @param toEmail
|
||||
* @param subject
|
||||
* @param body
|
||||
*/
|
||||
public static void sendEmail(MailAccountService mailAccountService, String toEmail, String subject, String body){
|
||||
System.out.println("TLSEmail Start");
|
||||
Properties props = new Properties();
|
||||
/**
|
||||
* Utility method to send simple HTML email
|
||||
*
|
||||
* @param session
|
||||
* @param toEmail
|
||||
* @param subject
|
||||
* @param body
|
||||
*/
|
||||
public static void sendEmail(
|
||||
MailAccountService mailAccountService, String toEmail, String subject, String body) {
|
||||
System.out.println("TLSEmail Start");
|
||||
Properties props = new Properties();
|
||||
|
||||
final String fromEmail = mailAccountService.getDefaultSender().getLogin().toString();
|
||||
final String password = mailAccountService.getDefaultSender().getPassword().toString();
|
||||
props.put("mail.smtp.host", mailAccountService.getDefaultSender().getHost());
|
||||
props.put("mail.smtp.port", mailAccountService.getDefaultSender().getPort());
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
|
||||
final String fromEmail = mailAccountService.getDefaultSender().getLogin().toString();
|
||||
final String password = mailAccountService.getDefaultSender().getPassword().toString();
|
||||
props.put("mail.smtp.host", mailAccountService.getDefaultSender().getHost());
|
||||
props.put("mail.smtp.port", mailAccountService.getDefaultSender().getPort());
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
|
||||
Authenticator auth = new Authenticator() {
|
||||
Authenticator auth =
|
||||
new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(fromEmail, password);
|
||||
}
|
||||
};
|
||||
Session session = Session.getInstance(props, auth);
|
||||
try
|
||||
{
|
||||
MimeMessage msg = new MimeMessage(session);
|
||||
//set message headers
|
||||
msg.addHeader("Content-type", "text/HTML; charset=UTF-8");
|
||||
msg.addHeader("format", "flowed");
|
||||
msg.addHeader("Content-Transfer-Encoding", "8bit");
|
||||
Session session = Session.getInstance(props, auth);
|
||||
try {
|
||||
MimeMessage msg = new MimeMessage(session);
|
||||
// set message headers
|
||||
msg.addHeader("Content-type", "text/HTML; charset=UTF-8");
|
||||
msg.addHeader("format", "flowed");
|
||||
msg.addHeader("Content-Transfer-Encoding", "8bit");
|
||||
|
||||
msg.setFrom(new InternetAddress(fromEmail, "ERP SOPHAL"));
|
||||
msg.setFrom(new InternetAddress(fromEmail, "ERP SOPHAL"));
|
||||
|
||||
msg.setReplyTo(InternetAddress.parse(fromEmail, false));
|
||||
msg.setReplyTo(InternetAddress.parse(fromEmail, false));
|
||||
|
||||
msg.setSubject(subject, "UTF-8");
|
||||
msg.setSubject(subject, "UTF-8");
|
||||
|
||||
msg.setText(body, "UTF-8");
|
||||
msg.setContent(body, "text/html; charset=utf-8");
|
||||
|
||||
msg.setSentDate(new Date());
|
||||
msg.setSentDate(new Date());
|
||||
|
||||
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail, false));
|
||||
System.out.println("Message is ready");
|
||||
Transport.send(msg);
|
||||
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail, false));
|
||||
System.out.println("Message is ready");
|
||||
Transport.send(msg);
|
||||
|
||||
System.out.println("EMail Sent Successfully!!");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("EMail Sent Successfully!!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.axelor.apps.purchase.web;
|
||||
|
||||
import com.axelor.apps.base.db.Currency;
|
||||
import com.axelor.apps.base.db.repo.CurrencyRepository;
|
||||
import com.axelor.apps.base.service.CurrencyConversionService;
|
||||
import com.axelor.apps.purchase.db.ImportationFolder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrderLine;
|
||||
import com.axelor.apps.purchase.db.repo.ImportationFolderRepository;
|
||||
import com.axelor.apps.purchase.service.ImportationFolderService;
|
||||
import com.axelor.apps.purchase.service.ImportationFolderServiceImpl;
|
||||
@@ -13,45 +11,54 @@ import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.inject.Singleton;
|
||||
import wslite.json.JSONException;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
import wslite.json.JSONException;
|
||||
|
||||
@Singleton
|
||||
public class ImportationFolderController {
|
||||
public void draftImportationFolder(ActionRequest request, ActionResponse response) {
|
||||
ImportationFolder importationFolder = request.getContext().asType(ImportationFolder.class);
|
||||
Beans.get(ImportationFolderService.class).draftImportationFolder(importationFolder);
|
||||
}
|
||||
public void draftImportationFolder(ActionRequest request, ActionResponse response) {
|
||||
ImportationFolder importationFolder = request.getContext().asType(ImportationFolder.class);
|
||||
Beans.get(ImportationFolderService.class).draftImportationFolder(importationFolder);
|
||||
}
|
||||
|
||||
public void openImportationFolder(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
ImportationFolder importationFolder = request.getContext().asType(ImportationFolder.class);
|
||||
Beans.get(ImportationFolderService.class).openImportationFolder(importationFolder);
|
||||
}
|
||||
public void openImportationFolder(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
ImportationFolder importationFolder = request.getContext().asType(ImportationFolder.class);
|
||||
Beans.get(ImportationFolderService.class).openImportationFolder(importationFolder);
|
||||
}
|
||||
|
||||
public void closeImportationFolder(ActionRequest request, ActionResponse response) {
|
||||
ImportationFolder importationFolder = request.getContext().asType(ImportationFolder.class);
|
||||
Beans.get(ImportationFolderService.class).closeImportationFolder(importationFolder);
|
||||
}
|
||||
public void closeImportationFolder(ActionRequest request, ActionResponse response) {
|
||||
ImportationFolder importationFolder = request.getContext().asType(ImportationFolder.class);
|
||||
Beans.get(ImportationFolderService.class).closeImportationFolder(importationFolder);
|
||||
}
|
||||
|
||||
public void cancelImportationFolder(ActionRequest request, ActionResponse response) {
|
||||
ImportationFolder importationFolder = request.getContext().asType(ImportationFolder.class);
|
||||
Beans.get(ImportationFolderService.class).cancelImportationFolder(importationFolder);
|
||||
}
|
||||
public void cancelImportationFolder(ActionRequest request, ActionResponse response) {
|
||||
ImportationFolder importationFolder = request.getContext().asType(ImportationFolder.class);
|
||||
Beans.get(ImportationFolderService.class).cancelImportationFolder(importationFolder);
|
||||
}
|
||||
|
||||
public void calculateSum(ActionRequest request, ActionResponse response)
|
||||
throws MalformedURLException, JSONException, AxelorException {
|
||||
public void calculateSum(ActionRequest request, ActionResponse response)
|
||||
throws MalformedURLException, JSONException, AxelorException {
|
||||
|
||||
ImportationFolder iimportationFolder = (ImportationFolder) request.getContext().asType(ImportationFolder.class);
|
||||
ImportationFolder importationFolder = Beans.get(ImportationFolderRepository.class)
|
||||
.find(iimportationFolder.getId());
|
||||
List<PurchaseOrder> purchaseOrders = importationFolder.getPurchaseOrderList();
|
||||
ImportationFolder iimportationFolder =
|
||||
(ImportationFolder) request.getContext().asType(ImportationFolder.class);
|
||||
ImportationFolder importationFolder =
|
||||
Beans.get(ImportationFolderRepository.class).find(iimportationFolder.getId());
|
||||
List<PurchaseOrder> purchaseOrders = importationFolder.getPurchaseOrderList();
|
||||
|
||||
Beans.get(ImportationFolderServiceImpl.class).calculateSum(purchaseOrders, importationFolder);
|
||||
}
|
||||
|
||||
Beans.get(ImportationFolderServiceImpl.class).calculateSum(purchaseOrders,
|
||||
importationFolder);
|
||||
public void calculateAvgPrice(ActionRequest request, ActionResponse response)
|
||||
throws MalformedURLException, JSONException, AxelorException {
|
||||
|
||||
}
|
||||
ImportationFolder iimportationFolder =
|
||||
(ImportationFolder) request.getContext().asType(ImportationFolder.class);
|
||||
ImportationFolder importationFolder =
|
||||
Beans.get(ImportationFolderRepository.class).find(iimportationFolder.getId());
|
||||
List<PurchaseOrderLine> purchaseOrderLines = importationFolder.getPurchaseOrderLineList();
|
||||
|
||||
Beans.get(ImportationFolderServiceImpl.class).calculateAvgPrice(purchaseOrderLines, importationFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.axelor.apps.base.service.TradingNameService;
|
||||
import com.axelor.apps.purchase.db.ImportationFolder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.apps.purchase.db.PurchaseRequest;
|
||||
import com.axelor.apps.purchase.db.repo.ImportationFolderRepository;
|
||||
import com.axelor.apps.purchase.db.repo.PurchaseOrderRepository;
|
||||
import com.axelor.apps.purchase.db.repo.PurchaseRequestRepository;
|
||||
import com.axelor.apps.purchase.exception.IExceptionMessage;
|
||||
@@ -62,13 +61,18 @@ import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
import wslite.json.JSONException;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -115,6 +119,14 @@ public class PurchaseOrderController {
|
||||
"supplierPartner", Beans.get(PurchaseOrderService.class).validateSupplier(purchaseOrder));
|
||||
}
|
||||
|
||||
public void setStandByPurchaseOrder(ActionRequest request, ActionResponse response) {
|
||||
|
||||
String raison = (String) request.getContext().get("standbyRaison");
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
Beans.get(PurchaseOrderService.class).setStandByPurchaseOrder(purchaseOrder, raison);
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from grid or form purchase order view, print selected purchase order.
|
||||
*
|
||||
@@ -229,6 +241,8 @@ public class PurchaseOrderController {
|
||||
boolean existPriceListDiff = false;
|
||||
PurchaseOrder purchaseOrderTemp;
|
||||
boolean allTradingNamesAreNull = true;
|
||||
boolean eqStatusSelect = true;
|
||||
int statusSelect = -1;
|
||||
int count = 1;
|
||||
for (Long purchaseOrderId : purchaseOrderIdList) {
|
||||
purchaseOrderTemp = JPA.em().find(PurchaseOrder.class, purchaseOrderId);
|
||||
@@ -241,8 +255,12 @@ public class PurchaseOrderController {
|
||||
commonPriceList = purchaseOrderTemp.getPriceList();
|
||||
commonTradingName = purchaseOrderTemp.getTradingName();
|
||||
allTradingNamesAreNull = commonTradingName == null;
|
||||
statusSelect = purchaseOrderTemp.getStatusSelect();
|
||||
|
||||
} else {
|
||||
if (purchaseOrderTemp.getStatusSelect() != statusSelect) {
|
||||
eqStatusSelect = false;
|
||||
}
|
||||
if (commonCurrency != null && !commonCurrency.equals(purchaseOrderTemp.getCurrency())) {
|
||||
commonCurrency = null;
|
||||
}
|
||||
@@ -289,6 +307,9 @@ public class PurchaseOrderController {
|
||||
if (commonTradingName == null && !allTradingNamesAreNull) {
|
||||
fieldErrors.append(I18n.get(IExceptionMessage.PURCHASE_ORDER_MERGE_ERROR_TRADING_NAME));
|
||||
}
|
||||
if (!eqStatusSelect) {
|
||||
fieldErrors.append(I18n.get(IExceptionMessage.PURCHASE_ORDER_MERGE_ERROR_STATUS_SELECT));
|
||||
}
|
||||
|
||||
if (fieldErrors.length() > 0) {
|
||||
response.setFlash(fieldErrors.toString());
|
||||
@@ -397,6 +418,7 @@ public class PurchaseOrderController {
|
||||
try {
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
|
||||
|
||||
Beans.get(PurchaseOrderService.class).validatePurchaseOrder(purchaseOrder);
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
@@ -404,6 +426,74 @@ public class PurchaseOrderController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void showFare(ActionRequest request, ActionResponse response) {
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
|
||||
|
||||
if(purchaseOrder.getImportationType() == 2 ){
|
||||
|
||||
ActionViewBuilder confirmView =
|
||||
ActionView.define("Confirm rejection")
|
||||
.model(Wizard.class.getName())
|
||||
.add("form", "amount-to-pay-fare-form")
|
||||
.param("popup", "true")
|
||||
.param("show-toolbar", "false")
|
||||
.param("show-confirm", "false")
|
||||
.param("popup-save", "false")
|
||||
.param("forceEdit", "true");
|
||||
|
||||
confirmView.context("purchaseOrderId", purchaseOrder.getId());
|
||||
response.setView(confirmView.map());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void validateImportationPurchaseOrder(ActionRequest request, ActionResponse response) throws AxelorException, MalformedURLException, JSONException {
|
||||
|
||||
if(request.getContext().get("val") == null){
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD,
|
||||
I18n.get(IExceptionMessage.NO_PURCHASE_ORDER_SELECTED_FOR_PRINTING));
|
||||
}
|
||||
|
||||
BigDecimal val = new BigDecimal(request.getContext().get("val").toString());
|
||||
BigDecimal purchaseOrderId = new BigDecimal(request.getContext().get("purchaseOrderId").toString());
|
||||
|
||||
PurchaseOrder purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(new Long(purchaseOrderId.toString()));
|
||||
|
||||
Beans.get(PurchaseOrderServiceImpl.class).addFareToImportationFolder(purchaseOrder, val);
|
||||
|
||||
ImportationFolder importationFolder =
|
||||
Beans.get(PurchaseOrderServiceImpl.class).generateImportationFolder(purchaseOrder);
|
||||
|
||||
// Beans.get(PurchaseOrderRepository.class).save(purchaseOrder);
|
||||
|
||||
response.setView(
|
||||
ActionView.define("Importation folder")
|
||||
.model(ImportationFolder.class.getName())
|
||||
.add("grid", "importation-folder-grid")
|
||||
.add("form", "importation-folder-form")
|
||||
.param("forceEdit", "true")
|
||||
.domain("self.id = " + importationFolder.getId())
|
||||
.map());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void validateFromFare(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
|
||||
BigDecimal purchaseOrderId = new BigDecimal(request.getContext().get("purchaseOrderId").toString());
|
||||
PurchaseOrder purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(new Long(purchaseOrderId.toString()));
|
||||
Beans.get(PurchaseOrderService.class).validatePurchaseOrder(purchaseOrder);
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void cancel(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
@@ -510,7 +600,8 @@ public class PurchaseOrderController {
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
|
||||
|
||||
Beans.get(PurchaseOrderService.class).finishPurchaseOrder(purchaseOrder);
|
||||
Beans.get(PurchaseOrderService.class)
|
||||
.finishPurchaseOrder(purchaseOrder, purchaseOrder.getCancelReasonStr());
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
@@ -547,17 +638,17 @@ public class PurchaseOrderController {
|
||||
}
|
||||
|
||||
public void cancelReasonPurchaseOrder(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
Beans.get(PurchaseOrderService.class)
|
||||
.cancelReasonPurchaseOrder(
|
||||
Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId()),
|
||||
purchaseOrder.getCancelReason(),
|
||||
purchaseOrder.getCancelReasonStr());
|
||||
try {
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
Beans.get(PurchaseOrderService.class)
|
||||
.cancelReasonPurchaseOrder(
|
||||
Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId()),
|
||||
purchaseOrder.getCancelReason(),
|
||||
purchaseOrder.getCancelReasonStr());
|
||||
|
||||
response.setFlash(I18n.get("The purchase order was canceled"));
|
||||
response.setCanClose(true);
|
||||
} catch (Exception e) {
|
||||
response.setFlash(I18n.get("The purchase order was canceled"));
|
||||
response.setCanClose(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
@@ -566,71 +657,76 @@ public class PurchaseOrderController {
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
public void showPurchaseRequest(ActionRequest request, ActionResponse response){
|
||||
PurchaseOrder purchaseOrder = Beans.get(PurchaseOrderRepository.class)
|
||||
.find(request.getContext().asType(PurchaseOrder.class).getId());
|
||||
public void showPurchaseRequest(ActionRequest request, ActionResponse response) {
|
||||
PurchaseOrder purchaseOrder =
|
||||
Beans.get(PurchaseOrderRepository.class)
|
||||
.find(request.getContext().asType(PurchaseOrder.class).getId());
|
||||
|
||||
List<PurchaseRequest> purchaseRequests = Beans.get(PurchaseRequestRepository.class).all().fetch();
|
||||
List<PurchaseRequest> purchaseRequests =
|
||||
Beans.get(PurchaseRequestRepository.class).all().fetch();
|
||||
List<Long> tempPurchaseRequest = new ArrayList<>();
|
||||
|
||||
for (PurchaseRequest purchaseRequest : purchaseRequests) {
|
||||
List<PurchaseOrder> pOrder = purchaseRequest.getPurchaseOrderSet().stream().filter((po) -> po.getId() == purchaseOrder.getId()).collect(Collectors.toList());
|
||||
if(pOrder.size() > 0){
|
||||
List<PurchaseOrder> pOrder =
|
||||
purchaseRequest
|
||||
.getPurchaseOrderSet()
|
||||
.stream()
|
||||
.filter((po) -> po.getId() == purchaseOrder.getId())
|
||||
.collect(Collectors.toList());
|
||||
if (pOrder.size() > 0) {
|
||||
tempPurchaseRequest.add(purchaseRequest.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
response.setView(
|
||||
ActionView.define("Purchase requests")
|
||||
.model(PurchaseRequest.class.getName())
|
||||
.add("grid", "purchase-request-grid")
|
||||
.add("form", "purchase-request-form")
|
||||
.param("show-toolbar", "false")
|
||||
.param("show-confirm", "false")
|
||||
.param("popup-save", "false")
|
||||
.param("popup", "false")
|
||||
.context("_ids", tempPurchaseRequest)
|
||||
.domain("self.id in (" + Joiner.on(",").join(tempPurchaseRequest) + ")")
|
||||
.map());
|
||||
|
||||
|
||||
ActionView.define("Purchase requests")
|
||||
.model(PurchaseRequest.class.getName())
|
||||
.add("grid", "purchase-request-grid")
|
||||
.add("form", "purchase-request-form")
|
||||
.param("show-toolbar", "false")
|
||||
.param("show-confirm", "false")
|
||||
.param("popup-save", "false")
|
||||
.param("popup", "false")
|
||||
.context("_ids", tempPurchaseRequest)
|
||||
.domain("self.id in (" + Joiner.on(",").join(tempPurchaseRequest) + ")")
|
||||
.map());
|
||||
}
|
||||
|
||||
public void generateImportationFolder(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
public void generateImportationFolder(ActionRequest request,ActionResponse response) throws AxelorException {
|
||||
PurchaseOrder purchaseOrder =
|
||||
Beans.get(PurchaseOrderRepository.class)
|
||||
.find(request.getContext().asType(PurchaseOrder.class).getId());
|
||||
|
||||
PurchaseOrder purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(request.getContext().asType(PurchaseOrder.class).getId());
|
||||
// if (purchaseOrder.getImportationType() == 2 && purchaseOrder.getCurrency().getId() != 41){
|
||||
|
||||
if(purchaseOrder.getImportationType() == 2){
|
||||
// ImportationFolder importationFolder =
|
||||
// Beans.get(PurchaseOrderServiceImpl.class).generateImportationFolder(purchaseOrder);
|
||||
|
||||
ImportationFolder importationFolder = Beans.get(PurchaseOrderServiceImpl.class).generateImportationFolder(purchaseOrder);
|
||||
// purchaseOrder.setImportationFolder(importationFolder);
|
||||
|
||||
purchaseOrder.setImportationFolder(importationFolder);
|
||||
// // Beans.get(PurchaseOrderRepository.class).save(purchaseOrder);
|
||||
|
||||
// Beans.get(PurchaseOrderRepository.class).save(purchaseOrder);
|
||||
// response.setView(
|
||||
// ActionView.define("Importation folder")
|
||||
// .model(ImportationFolder.class.getName())
|
||||
// .add("grid", "importation-folder-grid")
|
||||
// .add("form", "importation-folder-form")
|
||||
// .param("forceEdit", "true")
|
||||
// .domain("self.id = " + importationFolder.getId())
|
||||
// .map());
|
||||
// }
|
||||
}
|
||||
|
||||
response.setView(
|
||||
ActionView.define("Importation folder")
|
||||
.model(ImportationFolder.class.getName())
|
||||
.add("grid", "importation-folder-grid")
|
||||
.add("form", "importation-folder-form")
|
||||
.param("forceEdit", "true")
|
||||
.domain("self.id = " + importationFolder.getId())
|
||||
.map());
|
||||
|
||||
}
|
||||
public void createPurchaseOrderBarCodeSeq(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
|
||||
Beans.get(PurchaseOrderService.class).createPurchaseOrderBarCodeSeq(purchaseOrder);
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
|
||||
public void createPurchaseOrderBarCodeSeq(ActionRequest request, ActionResponse response){
|
||||
try {
|
||||
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
|
||||
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
|
||||
Beans.get(PurchaseOrderService.class).createPurchaseOrderBarCodeSeq(purchaseOrder);
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user