First commit (wating to add alerts in budget)
This commit is contained in:
@@ -17,6 +17,9 @@ dependencies {
|
||||
compile project(":modules:axelor-purchase")
|
||||
compile 'xalan:xalan:2.7.2'
|
||||
|
||||
testImplementation 'org.mockito:mockito-core:4.8.0' // Or latest version
|
||||
|
||||
|
||||
compile group: 'jdom', name: 'jdom', version: '1.1'
|
||||
compile group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '2.5.0'
|
||||
compile "org.bouncycastle:bcprov-jdk15on:1.62"
|
||||
|
||||
@@ -797,4 +797,8 @@ public interface IExceptionMessage {
|
||||
|
||||
static final String CLOSE_NO_REPORTED_BALANCE_DATE = /*$$(*/
|
||||
"Please set a reported balance date on fiscal year" /*)*/;
|
||||
|
||||
|
||||
String CASH_INVENTORY_MISSING_SEQUENCE = /*$$(*/
|
||||
"There is no configured sequence for cash inventory" /*)*/;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
package com.axelor.apps.account.service;
|
||||
|
||||
import com.axelor.apps.account.db.CashInventory;
|
||||
import com.axelor.apps.account.db.CashInventoryLine;
|
||||
import com.axelor.apps.account.db.CashRegister;
|
||||
import com.axelor.apps.account.db.repo.CashDenominationRepository;
|
||||
import com.axelor.apps.account.db.repo.CashInventoryRepository;
|
||||
import com.axelor.apps.account.db.repo.CashRegisterRepository;
|
||||
import com.axelor.apps.account.exception.IExceptionMessage;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.service.administration.SequenceService;
|
||||
import com.axelor.auth.AuthUtils;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -7,75 +23,128 @@ 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);
|
||||
private SequenceService sequenceService;
|
||||
|
||||
@Inject
|
||||
public CashInventoryService(SequenceService sequenceService) {
|
||||
this.sequenceService = sequenceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the theorical solde in words for a new cash inventory.
|
||||
*
|
||||
* @return the theorical solde in words as a BigDecimal
|
||||
*/
|
||||
public BigDecimal initThetoricalSolde() {
|
||||
CashRegisterRepository casRegisterRepository = Beans.get(CashRegisterRepository.class);
|
||||
CashRegister cashRegister = casRegisterRepository.all().order("-createdOn").fetchOne();
|
||||
BigDecimal theoricalSolde = BigDecimal.ZERO;
|
||||
if (cashRegister == null) {
|
||||
theoricalSolde = BigDecimal.ZERO;
|
||||
} else {
|
||||
theoricalSolde = cashRegister.getTheoricalSolde();
|
||||
}
|
||||
return theoricalSolde;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the totals for the cash inventory, including total bank notes, total
|
||||
* coins, physical
|
||||
* solde, and gap.
|
||||
*
|
||||
* @param cashInventory The cash inventory to compute totals for.
|
||||
* @return A map containing the computed totals.
|
||||
*/
|
||||
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);
|
||||
|
||||
public Map<String, BigDecimal> computeToTals(CashInventory cashInventory){
|
||||
map.put("totalCoinsAmount", totalCoins);
|
||||
map.put("totalBankNotesAmount", totalBankNotes);
|
||||
map.put("totalCash", totalBankNotes);
|
||||
map.put("physicalSolde", physicalSolde);
|
||||
map.put("gap", gap);
|
||||
|
||||
HashMap<String, BigDecimal> map = new HashMap<>();
|
||||
return map;
|
||||
}
|
||||
|
||||
List<CashInventoryLine> cashInventoryLines = cashInventory.getCashInventoryLines();
|
||||
|
||||
BigDecimal theoricalSolde = cashInventory.getTheoricalSolde();
|
||||
public String getCashInventorySequence(CashInventory cashInventory) throws AxelorException {
|
||||
Integer operationTypeSelect = cashInventory.getOperationTypeSelect();
|
||||
Company company = cashInventory.getCompany();
|
||||
String sequence = null;
|
||||
|
||||
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;
|
||||
|
||||
if (operationTypeSelect != null) {
|
||||
switch (operationTypeSelect) {
|
||||
case 1: // Cash inventory daily
|
||||
sequence = "CASH_INVENTORY_DAILY";
|
||||
break;
|
||||
case 2: // Cash inventory monthly
|
||||
sequence = "CASH_INVENTORY_MONTHLY";
|
||||
break;
|
||||
case 3: // Cash inventory annual
|
||||
sequence = "CASH_INVENTORY_ANNUAL";
|
||||
break;
|
||||
default:
|
||||
sequence = "CASH_INVENTORY";
|
||||
// Default case for other operation types
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sequence = "CASH_INVENTORY";
|
||||
}
|
||||
|
||||
|
||||
|
||||
String ref = sequenceService.getSequenceNumber(sequence, company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.CASH_INVENTORY_MISSING_SEQUENCE),
|
||||
company.getName());
|
||||
} else {
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void approveCashInventory(CashInventory cashInventory) {
|
||||
CashRegisterRepository casRegisterRepository = Beans.get(CashRegisterRepository.class);
|
||||
CashRegister cashRegister = casRegisterRepository.all().order("-createdOn").fetchOne();
|
||||
// cashRegister.setTheoricalSolde(cashInventory.getPhysicalSolde());
|
||||
cashRegister.setPhysicalSolde(cashInventory.getPhysicalSolde());
|
||||
cashInventory.setValdiatedByUser(AuthUtils.getUser());
|
||||
cashInventory.setValidattionDate(LocalDateTime.now());
|
||||
cashInventory.setStatusSelect(3);
|
||||
Beans.get(CashInventoryRepository.class).save(cashInventory);
|
||||
casRegisterRepository.save(cashRegister);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
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;
|
||||
@@ -16,21 +10,22 @@ 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;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InvoiceTemplateService {
|
||||
|
||||
@Transactional
|
||||
public Invoice generateInvoiceFromTemplate(InvoiceTemplate invoiceTemplate) throws AxelorException {
|
||||
public Invoice generateInvoiceFromTemplate(InvoiceTemplate invoiceTemplate)
|
||||
throws AxelorException {
|
||||
|
||||
Partner partner = invoiceTemplate.getPartner();
|
||||
Company company = invoiceTemplate.getCompany();
|
||||
InvoiceGenerator invoiceGenerator =
|
||||
InvoiceGenerator invoiceGenerator =
|
||||
new InvoiceGenerator(
|
||||
InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE,
|
||||
company,
|
||||
@@ -56,26 +51,23 @@ public class InvoiceTemplateService {
|
||||
|
||||
List<InvoiceLine> invoiceLineList = new ArrayList<>();
|
||||
|
||||
|
||||
Invoice invoice = invoiceGenerator.generate();
|
||||
|
||||
int priority = 0;
|
||||
for (InvoiceTemplateLine invoiceTemplateLine : invoiceTemplate.getMoveTemplateLineList()) {
|
||||
invoiceLineList.addAll(createInvoiceLine(invoice, invoiceTemplateLine, priority));
|
||||
priority++;
|
||||
invoiceLineList.addAll(createInvoiceLine(invoice, invoiceTemplateLine, priority));
|
||||
priority++;
|
||||
}
|
||||
invoiceGenerator.populate(invoice, invoiceLineList);
|
||||
|
||||
Invoice returnInvoiced = Beans.get(InvoiceRepository.class).save(invoice);
|
||||
|
||||
return returnInvoiced;
|
||||
|
||||
Invoice returnInvoiced = Beans.get(InvoiceRepository.class).save(invoice);
|
||||
|
||||
return returnInvoiced;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected List<InvoiceLine> createInvoiceLine(
|
||||
Invoice invoice, InvoiceTemplateLine invoiceTemplateLine, int priority) throws AxelorException {
|
||||
protected List<InvoiceLine> createInvoiceLine(
|
||||
Invoice invoice, InvoiceTemplateLine invoiceTemplateLine, int priority)
|
||||
throws AxelorException {
|
||||
|
||||
Product product = invoiceTemplateLine.getProduct();
|
||||
|
||||
@@ -117,7 +109,4 @@ public class InvoiceTemplateService {
|
||||
|
||||
return invoiceLineGenerator.creates();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,10 @@ public interface ReconcileService {
|
||||
public Reconcile confirmReconcile(Reconcile reconcile, boolean updateInvoicePayments)
|
||||
throws AxelorException;
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public Reconcile confirmPaymentVoucherReconcile(
|
||||
Reconcile reconcile, boolean updateInvoicePayments) throws AxelorException;
|
||||
|
||||
public void reconcilePreconditions(Reconcile reconcile) throws AxelorException;
|
||||
|
||||
public void updatePartnerAccountingSituation(Reconcile reconcile) throws AxelorException;
|
||||
|
||||
@@ -430,6 +430,30 @@ public class ReconcileServiceImpl implements ReconcileService {
|
||||
Beans.get(ReconcileGroupService.class).remove(reconcile);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void unreconcile2(Reconcile reconcile) throws AxelorException {
|
||||
|
||||
log.debug("unreconcile : reconcile : {}", reconcile);
|
||||
|
||||
MoveLine debitMoveLine = reconcile.getDebitMoveLine();
|
||||
MoveLine creditMoveLine = reconcile.getCreditMoveLine();
|
||||
|
||||
// Change the state
|
||||
reconcile.setStatusSelect(ReconcileRepository.STATUS_CANCELED);
|
||||
// Add the reconciled amount to the reconciled amount in the move line
|
||||
creditMoveLine.setAmountPaid(creditMoveLine.getAmountPaid().subtract(reconcile.getAmount()));
|
||||
debitMoveLine.setAmountPaid(debitMoveLine.getAmountPaid().subtract(reconcile.getAmount()));
|
||||
reconcileRepository.save(reconcile);
|
||||
|
||||
// Update amount remaining on invoice or refund
|
||||
this.updatePartnerAccountingSituation(reconcile);
|
||||
this.updateInvoiceCompanyInTaxTotalRemaining(reconcile);
|
||||
this.updateInvoicePaymentsCanceled(reconcile);
|
||||
this.reverseTaxPaymentMoveLines(reconcile);
|
||||
// Update reconcile group
|
||||
// Beans.get(ReconcileGroupService.class).remove(reconcile);
|
||||
}
|
||||
|
||||
protected void reverseTaxPaymentMoveLines(Reconcile reconcile) throws AxelorException {
|
||||
Move debitMove = reconcile.getDebitMoveLine().getMove();
|
||||
Move creditMove = reconcile.getCreditMoveLine().getMove();
|
||||
@@ -556,4 +580,41 @@ public class ReconcileServiceImpl implements ReconcileService {
|
||||
}
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reconcile confirmPaymentVoucherReconcile(
|
||||
Reconcile reconcile, boolean updateInvoicePayments) throws AxelorException {
|
||||
this.reconcilePreconditions(reconcile);
|
||||
|
||||
MoveLine debitMoveLine = reconcile.getDebitMoveLine();
|
||||
MoveLine creditMoveLine = reconcile.getCreditMoveLine();
|
||||
|
||||
// Add the reconciled amount to the reconciled amount in the move line
|
||||
creditMoveLine.setAmountPaid(creditMoveLine.getAmountPaid().add(reconcile.getAmount()));
|
||||
debitMoveLine.setAmountPaid(debitMoveLine.getAmountPaid().add(reconcile.getAmount()));
|
||||
|
||||
reconcile = reconcileRepository.save(reconcile);
|
||||
|
||||
reconcile.setStatusSelect(ReconcileRepository.STATUS_CONFIRMED);
|
||||
|
||||
if (reconcile.getCanBeZeroBalanceOk()) {
|
||||
// Alors nous utilisons la règle de gestion consitant à imputer l'écart sur un compte
|
||||
// transitoire si le seuil est respecté
|
||||
canBeZeroBalance(reconcile);
|
||||
}
|
||||
|
||||
reconcile.setReconciliationDate(LocalDate.now());
|
||||
|
||||
reconcileSequenceService.setSequence(reconcile);
|
||||
|
||||
this.updatePartnerAccountingSituation(reconcile);
|
||||
this.updateInvoiceCompanyInTaxTotalRemaining(reconcile);
|
||||
this.udpatePaymentTax(reconcile);
|
||||
if (updateInvoicePayments) {
|
||||
this.updateInvoicePayments(reconcile);
|
||||
}
|
||||
this.addToReconcileGroup(reconcile);
|
||||
|
||||
return reconcileRepository.save(reconcile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,11 +486,13 @@ public class MoveLineService {
|
||||
moveLineId++,
|
||||
origin,
|
||||
invoiceLine.getProductName());
|
||||
|
||||
moveLine.setAnalyticDistributionTemplate(invoiceLine.getAnalyticDistributionTemplate());
|
||||
if(invoiceLine.getAnalyticDistributionTemplate() != null)
|
||||
moveLine.setAnalyticDistributionTemplate(invoiceLine.getAnalyticDistributionTemplate());
|
||||
if (invoiceLine.getAnalyticMoveLineList() != null
|
||||
&& !invoiceLine.getAnalyticMoveLineList().isEmpty()) {
|
||||
for (AnalyticMoveLine invoiceAnalyticMoveLine : invoiceLine.getAnalyticMoveLineList()) {
|
||||
System.out.println("-----------------invoiceAnalyticMoveLine.getAccount().getName()----------------------------");
|
||||
System.out.println(invoiceAnalyticMoveLine.getAccount());
|
||||
AnalyticMoveLine analyticMoveLine =
|
||||
analyticMoveLineRepository.copy(invoiceAnalyticMoveLine, false);
|
||||
analyticMoveLine.setTypeSelect(AnalyticMoveLineRepository.STATUS_REAL_ACCOUNTING);
|
||||
|
||||
@@ -185,11 +185,20 @@ public class MoveServiceImpl implements MoveService {
|
||||
isPurchase,
|
||||
isDebitCustomer));
|
||||
|
||||
log.debug("Saving account move..............");
|
||||
|
||||
moveRepository.save(move);
|
||||
|
||||
log.debug("saved account move..............");
|
||||
|
||||
|
||||
invoice.setMove(move);
|
||||
|
||||
invoice.setCompanyInTaxTotalRemaining(moveToolService.getInTaxTotalRemaining(invoice));
|
||||
|
||||
log.debug("loading account move.............. {}",move);
|
||||
|
||||
|
||||
moveValidateService.validate(move);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,9 @@ 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().setScale(2,BigDecimal.ROUND_HALF_EVEN));
|
||||
creditTotalRemaining =
|
||||
creditTotalRemaining.add(
|
||||
creditMoveLine.getAmountRemaining().setScale(2, BigDecimal.ROUND_HALF_EVEN));
|
||||
}
|
||||
for (MoveLine debitMoveLine : debitMoveLines) {
|
||||
|
||||
@@ -136,7 +138,9 @@ 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().setScale(2,BigDecimal.ROUND_HALF_EVEN));
|
||||
debitTotalRemaining =
|
||||
debitTotalRemaining.add(
|
||||
debitMoveLine.getAmountRemaining().setScale(2, BigDecimal.ROUND_HALF_EVEN));
|
||||
}
|
||||
|
||||
for (MoveLine creditMoveLine : creditMoveLines) {
|
||||
@@ -148,7 +152,10 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
&& (creditMoveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) == 1)) {
|
||||
try {
|
||||
createReconcile(
|
||||
debitMoveLine, creditMoveLine, debitTotalRemaining.setScale(4), creditTotalRemaining.setScale(4));
|
||||
debitMoveLine,
|
||||
creditMoveLine,
|
||||
debitTotalRemaining.setScale(4),
|
||||
creditTotalRemaining.setScale(4));
|
||||
} catch (Exception e) {
|
||||
if (dontThrow) {
|
||||
TraceBackService.trace(e);
|
||||
|
||||
@@ -19,6 +19,7 @@ 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.CashRegister;
|
||||
import com.axelor.apps.account.db.Invoice;
|
||||
import com.axelor.apps.account.db.Journal;
|
||||
import com.axelor.apps.account.db.Move;
|
||||
@@ -28,15 +29,13 @@ 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.CashRegisterRepository;
|
||||
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;
|
||||
@@ -49,7 +48,6 @@ 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;
|
||||
@@ -66,7 +64,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -131,26 +128,25 @@ public class PaymentVoucherConfirmService {
|
||||
Company company = paymentVoucher.getCompany();
|
||||
BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails();
|
||||
Journal journal;
|
||||
|
||||
|
||||
if (paymentVoucher.getPaymentMode().getId() == 12 || paymentVoucher.getPaymentMode().getId() == 23) {
|
||||
if(paymentVoucher.getPartner().getAccountingManagementList().size() == 0){
|
||||
|
||||
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{
|
||||
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);
|
||||
} else {
|
||||
journal = paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails);
|
||||
Account paymentModeAccount =
|
||||
paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails);
|
||||
paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails);
|
||||
|
||||
paymentVoucherControlService.checkPaymentVoucherField(
|
||||
paymentVoucher, company, paymentModeAccount, journal);
|
||||
paymentVoucherControlService.checkPaymentVoucherField(
|
||||
paymentVoucher, company, paymentModeAccount, journal);
|
||||
}
|
||||
|
||||
if (paymentVoucher.getRemainingAmount().compareTo(BigDecimal.ZERO) > 0
|
||||
@@ -176,7 +172,9 @@ public class PaymentVoucherConfirmService {
|
||||
if (!isConfirmed && paymentVoucher.getGeneratedMoveList().size() == 0) {
|
||||
createMoveAndConfirm(paymentVoucher);
|
||||
}
|
||||
if ((paymentVoucher.getPaymentMode().getId() == 12 || paymentVoucher.getPaymentMode().getId() == 23) && isConfirmed) {
|
||||
if ((paymentVoucher.getPaymentMode().getId() == 12
|
||||
|| paymentVoucher.getPaymentMode().getId() == 23)
|
||||
&& isConfirmed) {
|
||||
confirmBankMove(paymentVoucher);
|
||||
}
|
||||
}
|
||||
@@ -210,22 +208,22 @@ public class PaymentVoucherConfirmService {
|
||||
PaymentMode paymentMode = paymentVoucher.getPaymentMode();
|
||||
Company company = paymentVoucher.getCompany();
|
||||
BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails();
|
||||
Journal journal;
|
||||
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) {
|
||||
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);
|
||||
} 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
|
||||
@@ -283,7 +281,7 @@ public class PaymentVoucherConfirmService {
|
||||
|
||||
MoveLine moveLineInvoices = null;
|
||||
|
||||
if(paymentVoucher.getOperationTypeSelect() == 6){
|
||||
if (paymentVoucher.getOperationTypeSelect() == 6) {
|
||||
|
||||
moveLineInvoices =
|
||||
moveLineService.createMoveLine(
|
||||
@@ -296,67 +294,65 @@ public class PaymentVoucherConfirmService {
|
||||
moveLineNo++,
|
||||
paymentVoucher.getRef(),
|
||||
null);
|
||||
paidLineTotal = paymentVoucher.getPaidAmount();
|
||||
paidLineTotal = paymentVoucher.getPaidAmount();
|
||||
|
||||
move.getMoveLineList().add(moveLineInvoices);
|
||||
move.getMoveLineList().add(moveLineInvoices);
|
||||
|
||||
}else{
|
||||
} 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());
|
||||
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);
|
||||
BigDecimal amountToPay = payVoucherElementToPay.getAmountToPayCurrency();
|
||||
log.debug(">>>> PV amountToPay : {}", amountToPay);
|
||||
|
||||
Invoice invoice = payVoucherElementToPay.getMoveLine().getMove().getInvoice();
|
||||
isDebitToPay = paymentVoucherToolService.isDebitToPay(invoice);
|
||||
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);
|
||||
boolean isRefundInvoice = false;
|
||||
if (invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND) {
|
||||
isRefundInvoice = true;
|
||||
}
|
||||
|
||||
paidLineTotal = paidLineTotal.add(amountToPay);
|
||||
log.debug("heyyyyyyyyyyyyyyyyy : {}", isRefundInvoice);
|
||||
|
||||
log.debug("amountToPay >>>>>>>>>>> {}", amountToPay);
|
||||
if (amountToPay.compareTo(BigDecimal.ZERO) > 0 || isRefundInvoice) {
|
||||
|
||||
this.payMoveLine(
|
||||
move,
|
||||
moveLineNo++,
|
||||
payerPartner,
|
||||
moveLineToPay,
|
||||
amountToPay,
|
||||
amountToPay,
|
||||
// isRefundInvoice ? amountToPay : payVoucherElementToPay.getAmountToPayCurrency(),
|
||||
payVoucherElementToPay,
|
||||
isDebitToPay,
|
||||
paymentDate);
|
||||
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);
|
||||
@@ -477,9 +473,9 @@ public class PaymentVoucherConfirmService {
|
||||
// LocalDate paymentDate = paymentVoucher.getPaymentDate();
|
||||
LocalDate paymentDate = paymentVoucher.getPaymentEmissionDate();
|
||||
LocalDate paymentDateEchance = paymentVoucher.getDueDate();
|
||||
|
||||
if(paymentVoucher.getSort() == 3){
|
||||
paymentDateEchance = paymentVoucher.getCreditDate();
|
||||
|
||||
if (paymentVoucher.getSort() == 3) {
|
||||
paymentDateEchance = paymentVoucher.getCreditDate();
|
||||
}
|
||||
|
||||
boolean scheduleToBePaid = false;
|
||||
@@ -556,9 +552,9 @@ public class PaymentVoucherConfirmService {
|
||||
// LocalDate paymentDate = paymentVoucher.getPaymentDate();
|
||||
LocalDate paymentDate = paymentVoucher.getPaymentEmissionDate();
|
||||
LocalDate paymentDateEchance = paymentVoucher.getDueDate();
|
||||
|
||||
if(paymentVoucher.getSort() == 3){
|
||||
paymentDateEchance = paymentVoucher.getCreditDate();
|
||||
|
||||
if (paymentVoucher.getSort() == 3) {
|
||||
paymentDateEchance = paymentVoucher.getCreditDate();
|
||||
}
|
||||
|
||||
boolean scheduleToBePaid = false;
|
||||
@@ -576,7 +572,7 @@ public class PaymentVoucherConfirmService {
|
||||
paymentDate,
|
||||
paymentMode,
|
||||
MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC);
|
||||
|
||||
|
||||
move.setPaymentVoucher(paymentVoucher);
|
||||
|
||||
List<? extends PayVoucherElementToPay> payVoucherElementToPayList =
|
||||
@@ -586,15 +582,20 @@ public class PaymentVoucherConfirmService {
|
||||
|
||||
Account accountToPay = null;
|
||||
|
||||
if(paymentModeAccount.getIsOriginRequired()){
|
||||
if (paymentModeAccount.getIsOriginRequired()) {
|
||||
MoveLine moveLineToPay = payVoucherElementToPayList.get(0).getMoveLine();
|
||||
|
||||
if(moveLineToPay.getCredit().compareTo(BigDecimal.ZERO) > 0){
|
||||
|
||||
if (moveLineToPay.getCredit().compareTo(BigDecimal.ZERO) > 0) {
|
||||
isDebitToPay = true;
|
||||
}
|
||||
accountToPay = moveLineToPay.getAccount();
|
||||
}else{
|
||||
accountToPay = paymentVoucher.getPartner().getAccountingSituationList().get(0).getPartnerPaymentAccount();
|
||||
} else {
|
||||
accountToPay =
|
||||
paymentVoucher
|
||||
.getPartner()
|
||||
.getAccountingSituationList()
|
||||
.get(0)
|
||||
.getPartnerPaymentAccount();
|
||||
}
|
||||
|
||||
BigDecimal paidAmount = paymentVoucher.getPaidAmount();
|
||||
@@ -631,14 +632,18 @@ public class PaymentVoucherConfirmService {
|
||||
moveService.getMoveValidateService().validate(move);
|
||||
paymentVoucher.setGeneratedMove(move);
|
||||
paymentVoucher.addGeneratedMoveListItem(move);
|
||||
paymentVoucher.setConfirmationDate(LocalDate.now());
|
||||
paymentVoucher.setConfirmedByUser(AuthUtils.getUser());
|
||||
|
||||
if (isDebitToPay) {
|
||||
reconcileService.balanceCredit(moveLine);
|
||||
}
|
||||
if(paymentVoucher.getPartner().getId() == 2040L){
|
||||
this.updateCashRegisterTheoricalSolde(paymentVoucher, isDebitToPay,paidAmount);
|
||||
}
|
||||
// Beans.get(PaymentVoucherLoadService.class).updateVoucher(paymentVoucher);
|
||||
}
|
||||
|
||||
|
||||
public void deleteUnPaidLines(PaymentVoucher paymentVoucher) {
|
||||
|
||||
if (paymentVoucher.getPayVoucherElementToPayList() == null) {
|
||||
@@ -750,13 +755,13 @@ public class PaymentVoucherConfirmService {
|
||||
|
||||
BigDecimal amountInCompanyCurrency = moveLine.getDebit().add(moveLine.getCredit());
|
||||
|
||||
Reconcile reconcile =
|
||||
reconcileService.createReconcile(moveLineToPay, moveLine, amountToPayReel, true);
|
||||
reconciles.add(reconcile);
|
||||
if (reconcile != null) {
|
||||
log.debug("Reconcile : : : {}", reconcile);
|
||||
reconcileService.confirmReconcile(reconcile, true);
|
||||
}
|
||||
// Reconcile reconcile =
|
||||
// reconcileService.createReconcile(moveLineToPay, moveLine, amountToPayReel, true);
|
||||
// reconciles.add(reconcile);
|
||||
// if (reconcile != null) {
|
||||
// log.debug("Reconcile : : : {}", reconcile);
|
||||
// reconcileService.confirmPaymentVoucherReconcile(reconcile, true);
|
||||
// // }
|
||||
return moveLine;
|
||||
}
|
||||
|
||||
@@ -865,7 +870,9 @@ public class PaymentVoucherConfirmService {
|
||||
log.debug("Rejecting move : : : {} **********", move);
|
||||
|
||||
try {
|
||||
Move reverseMove = Beans.get(MoveServiceImpl.class).generateReverse(move, false, false, true, LocalDate.now());
|
||||
Move reverseMove =
|
||||
Beans.get(MoveServiceImpl.class)
|
||||
.generateReverse(move, false, false, true, LocalDate.now());
|
||||
paymentVoucher2.addGeneratedMoveListItem(reverseMove);
|
||||
// moveCancelService.cancel(move);
|
||||
} catch (AxelorException e) {
|
||||
@@ -880,119 +887,128 @@ public class PaymentVoucherConfirmService {
|
||||
}
|
||||
|
||||
@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(
|
||||
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"
|
||||
);
|
||||
"Not the same operation type");
|
||||
}
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
totalAmount = voucherList.stream().map(PaymentVoucher::getPaidAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
||||
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();
|
||||
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);
|
||||
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();
|
||||
}
|
||||
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 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());
|
||||
|
||||
// move.addPaymentVoucherListItem(paymentVoucher);
|
||||
// paymentVoucher.setGeneratedMove(move);
|
||||
paymentVoucher.setConfirmedByUser(AuthUtils.getUser());
|
||||
paymentVoucher.setConfirmationDate(LocalDate.now());
|
||||
boolean isDebitToPay = paymentVoucherToolService.isDebitToPay(paymentVoucher);
|
||||
int moveLineNo = 0;
|
||||
|
||||
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);
|
||||
|
||||
MoveLine moveLineAll =
|
||||
moveLineService.createMoveLine(
|
||||
move,
|
||||
payerPartner,
|
||||
paymentModeAccount,
|
||||
totalAmount,
|
||||
isDebitToPay,
|
||||
paymentDate,
|
||||
moveLineNo++,
|
||||
paymentVoucher.getRef(),
|
||||
null);
|
||||
move.getMoveLineList().add(moveLineAll);
|
||||
Set<Long> paymentVoucherIds = new HashSet<Long>();
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean voucherAlreadyInMove(List<PaymentVoucher> voucherList) {
|
||||
if(voucherList != null){
|
||||
if (voucherList != null) {
|
||||
for (PaymentVoucher voucher : voucherList) {
|
||||
if(voucher.getGeneratedMoveList().size() > 0){
|
||||
if (voucher.getGeneratedMoveList().size() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1000,11 +1016,20 @@ public class PaymentVoucherConfirmService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Cash mvt
|
||||
|
||||
/**
|
||||
* Confirm cash payment voucher and create move.
|
||||
*
|
||||
* @param paymentVoucher
|
||||
* @throws AxelorException
|
||||
*/
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void confirmCashPayment(PaymentVoucher paymentVoucher) throws AxelorException {
|
||||
if(paymentVoucher.getGeneratedMoveList().size() > 0){
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_INCONSISTENCY,
|
||||
"Already ventilated.");
|
||||
}
|
||||
PaymentMode paymentMode = paymentVoucher.getPaymentMode();
|
||||
Company company = paymentVoucher.getCompany();
|
||||
AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(company);
|
||||
@@ -1012,11 +1037,9 @@ public class PaymentVoucherConfirmService {
|
||||
Journal journal = accountConfig.getCashJournal();
|
||||
// LocalDate paymentDate = paymentVoucher.getPaymentDate();
|
||||
LocalDate paymentDate = paymentVoucher.getPaymentEmissionDate();
|
||||
|
||||
|
||||
|
||||
boolean scheduleToBePaid = false;
|
||||
Account paymentModeAccount = paymentVoucher.getPartner().getAccountingSituationList().get(0).getPartnerPaymentAccount();
|
||||
Account paymentModeAccount =
|
||||
paymentVoucher.getCashAccountConfig().getAccount();
|
||||
|
||||
Move move =
|
||||
moveService
|
||||
@@ -1034,15 +1057,10 @@ public class PaymentVoucherConfirmService {
|
||||
|
||||
Boolean isDebitToPay = false;
|
||||
|
||||
if(Integer.parseInt(paymentVoucher.getDebitCreditSelect()) == 1){
|
||||
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();
|
||||
@@ -1059,7 +1077,7 @@ public class PaymentVoucherConfirmService {
|
||||
paymentDate,
|
||||
moveLineNo++,
|
||||
paymentVoucher.getRef(),
|
||||
null);
|
||||
paymentVoucher.getLabel());
|
||||
|
||||
MoveLine moveLine =
|
||||
moveLineService.createMoveLine(
|
||||
@@ -1071,21 +1089,125 @@ public class PaymentVoucherConfirmService {
|
||||
paymentDate,
|
||||
moveLineNo++,
|
||||
paymentVoucher.getRef(),
|
||||
null);
|
||||
paymentVoucher.getLabel());
|
||||
|
||||
move.getMoveLineList().add(moveLine);
|
||||
move.getMoveLineList().add(moveLine2);
|
||||
|
||||
String label = paymentVoucher.getLabel() != null ? paymentVoucher.getLabel() : "";
|
||||
String fullName = (paymentVoucher.getRecipientPartner() != null && paymentVoucher.getRecipientPartner().getFullName() != null)
|
||||
? paymentVoucher.getRecipientPartner().getFullName()
|
||||
: "";
|
||||
|
||||
String description = label +" "+ fullName;
|
||||
|
||||
moveLine.setDescription(description);
|
||||
moveLine2.setDescription(description);
|
||||
|
||||
moveService.getMoveValidateService().validate(move);
|
||||
paymentVoucher.setGeneratedMove(move);
|
||||
paymentVoucher.addGeneratedMoveListItem(move);
|
||||
|
||||
// confirmed is ventilation equivalent
|
||||
paymentVoucher.setConfirmedByUser(AuthUtils.getUser());
|
||||
paymentVoucher.setConfirmationDate(LocalDate.now());
|
||||
|
||||
if (isDebitToPay) {
|
||||
reconcileService.balanceCredit(moveLine);
|
||||
}
|
||||
// updateCashRegisterTheoricalSolde(paymentVoucher, isDebitToPay,paidAmount);
|
||||
// Beans.get(PaymentVoucherLoadService.class).updateVoucher(paymentVoucher);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void updateCashRegisterTheoricalSolde(PaymentVoucher paymentVoucher,Boolean isDebitCredit,BigDecimal amount) {
|
||||
System.out.println("updateCashRegisterTheoricalSolde : : : " + paymentVoucher.getCashAccountConfig());
|
||||
if (paymentVoucher.getCashAccountConfig() != null || paymentVoucher.getPartner() != null) {
|
||||
CashRegisterRepository casRegisterRepository = Beans.get(CashRegisterRepository.class);
|
||||
CashRegister cashRegister = casRegisterRepository.all().order("-createdOn").fetchOne();
|
||||
BigDecimal theoreticalSolde = cashRegister.getTheoricalSolde();
|
||||
if (isDebitCredit) {
|
||||
theoreticalSolde = theoreticalSolde.subtract(amount);
|
||||
} else {
|
||||
theoreticalSolde = theoreticalSolde.add(amount);
|
||||
}
|
||||
System.out.println("theoreticalSolde : : : " + theoreticalSolde);
|
||||
cashRegister.setTheoricalSolde(theoreticalSolde);
|
||||
Beans.get(CashRegisterRepository.class).save(cashRegister);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void validateCashPaymentVoucher(PaymentVoucher paymentVoucher) throws AxelorException {
|
||||
if (paymentVoucher.getCashAccountConfig() == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_INCONSISTENCY,
|
||||
"Cash account config is not set for the payment voucher.");
|
||||
}
|
||||
if (paymentVoucher.getCashAccountConfig().getAccount() == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_INCONSISTENCY,
|
||||
"Cash account is not set for the payment voucher.");
|
||||
}
|
||||
CashRegisterRepository casRegisterRepository = Beans.get(CashRegisterRepository.class);
|
||||
CashRegister cashRegister = casRegisterRepository.all().order("-createdOn").fetchOne();
|
||||
|
||||
BigDecimal solde = cashRegister.getTheoricalSolde();
|
||||
if (Integer.parseInt(paymentVoucher.getDebitCreditSelect()) == 1) {
|
||||
solde = solde.subtract(paymentVoucher.getPaidAmount());
|
||||
}else{
|
||||
solde = solde.add(paymentVoucher.getPaidAmount());
|
||||
}
|
||||
|
||||
paymentVoucher.setInitialTheoricalSolde(cashRegister.getTheoricalSolde());
|
||||
paymentVoucher.setTheoricalSolde(solde);
|
||||
paymentVoucher.setCashStatusSelect(PaymentVoucherRepository.STATUS_WAITING_FOR_DEPOSIT_SLIP);
|
||||
paymentVoucher.setApprovalDate(LocalDate.now());
|
||||
paymentVoucher.setApprovedByUser(AuthUtils.getUser());
|
||||
Boolean isDebitToPay = false;
|
||||
|
||||
if (Integer.parseInt(paymentVoucher.getDebitCreditSelect()) == 1) {
|
||||
isDebitToPay = true;
|
||||
}
|
||||
updateCashRegisterTheoricalSolde(paymentVoucher, isDebitToPay,paymentVoucher.getPaidAmount());
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void cancelCashPaymentVoucher(PaymentVoucher paymentVoucher) throws AxelorException {
|
||||
if (paymentVoucher.getCashAccountConfig() == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_INCONSISTENCY,
|
||||
"Cash account config is not set for the payment voucher.");
|
||||
}
|
||||
if (paymentVoucher.getCashAccountConfig().getAccount() == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_INCONSISTENCY,
|
||||
"Cash account is not set for the payment voucher.");
|
||||
}
|
||||
CashRegisterRepository casRegisterRepository = Beans.get(CashRegisterRepository.class);
|
||||
CashRegister cashRegister = casRegisterRepository.all().order("-createdOn").fetchOne();
|
||||
|
||||
BigDecimal solde = cashRegister.getTheoricalSolde();
|
||||
if (Integer.parseInt(paymentVoucher.getDebitCreditSelect()) == 2) {
|
||||
solde = solde.subtract(paymentVoucher.getPaidAmount());
|
||||
}else{
|
||||
solde = solde.add(paymentVoucher.getPaidAmount());
|
||||
}
|
||||
|
||||
paymentVoucher.setInitialTheoricalSolde(cashRegister.getTheoricalSolde());
|
||||
paymentVoucher.setTheoricalSolde(solde);
|
||||
paymentVoucher.setCashStatusSelect(4);
|
||||
Boolean isDebitToPay = false;
|
||||
|
||||
if (Integer.parseInt(paymentVoucher.getDebitCreditSelect()) == 1) {
|
||||
isDebitToPay = true;
|
||||
}
|
||||
// Beans.get(MoveServiceImpl.class).
|
||||
updateCashRegisterTheoricalSolde(paymentVoucher, !isDebitToPay,paymentVoucher.getPaidAmount());
|
||||
for (Move move : paymentVoucher.getGeneratedMoveList()) {
|
||||
Beans.get(MoveCancelService.class).cancel(move);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -88,27 +88,27 @@ public class PaymentVoucherLoadService {
|
||||
List<MoveLine> moveLines = null;
|
||||
|
||||
String query =
|
||||
"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 ";
|
||||
|
||||
|
||||
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.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) {
|
||||
!= 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 {
|
||||
@@ -221,11 +221,22 @@ public class PaymentVoucherLoadService {
|
||||
int sequence = paymentVoucher.getPayVoucherElementToPayList().size() + 1;
|
||||
BigDecimal amountRemaining = paymentVoucher.getRemainingAmount();
|
||||
List<PayVoucherDueElement> dueElements = paymentVoucherContext.getPayVoucherDueElementList();
|
||||
|
||||
int sizeInvoiced = dueElements.stream().filter(t -> t.getMoveLine().getMove().getInvoice() == null).collect(Collectors.toList()).size();
|
||||
System.out.println("sizeInvoiced : {}"+sizeInvoiced);
|
||||
if(sizeInvoiced == 0){
|
||||
dueElements.sort((o1, o2) -> o2.getMoveLine().getMove().getInvoice().getInvoiceId().compareTo(o1.getMoveLine().getMove().getInvoice().getInvoiceId()));
|
||||
|
||||
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) {
|
||||
@@ -235,9 +246,11 @@ public class PaymentVoucherLoadService {
|
||||
if (payVoucherDueElementContext.isSelected()) {
|
||||
|
||||
paymentVoucher.addPayVoucherElementToPayListItem(
|
||||
this.createPayVoucherElementToPay(payVoucherDueElement, sequence++,amountRemaining));
|
||||
this.createPayVoucherElementToPay(payVoucherDueElement, sequence++, amountRemaining));
|
||||
|
||||
amountRemaining = amountRemaining.subtract(amountRemaining.min(payVoucherDueElement.getAmountRemaining()));
|
||||
amountRemaining =
|
||||
amountRemaining.subtract(
|
||||
amountRemaining.min(payVoucherDueElement.getAmountRemaining()));
|
||||
|
||||
// Remove the line from the due elements lists
|
||||
paymentVoucher.removePayVoucherDueElementListItem(payVoucherDueElement);
|
||||
@@ -246,7 +259,8 @@ public class PaymentVoucherLoadService {
|
||||
}
|
||||
|
||||
public PayVoucherElementToPay createPayVoucherElementToPay(
|
||||
PayVoucherDueElement payVoucherDueElement, int sequence,BigDecimal amountRemaining) throws AxelorException {
|
||||
PayVoucherDueElement payVoucherDueElement, int sequence, BigDecimal amountRemaining)
|
||||
throws AxelorException {
|
||||
|
||||
PaymentVoucher paymentVoucher = payVoucherDueElement.getPaymentVoucher();
|
||||
// BigDecimal amountRemaining = paymentVoucher.getRemainingAmount();
|
||||
@@ -420,7 +434,6 @@ public class PaymentVoucherLoadService {
|
||||
int sequence = 0;
|
||||
BigDecimal amountRemaining = paymentVoucher.getRemainingAmount();
|
||||
|
||||
|
||||
for (Iterator<PayVoucherDueElement> it =
|
||||
paymentVoucher.getPayVoucherDueElementList().iterator();
|
||||
it.hasNext(); ) {
|
||||
@@ -429,49 +442,54 @@ public class PaymentVoucherLoadService {
|
||||
if (invoice.equals(payVoucherDueElement.getMoveLine().getMove().getInvoice())
|
||||
&& paymentVoucher.getCurrency().equals(payVoucherDueElement.getCurrency())) {
|
||||
paymentVoucher.addPayVoucherElementToPayListItem(
|
||||
createPayVoucherElementToPay(payVoucherDueElement, ++sequence,amountRemaining));
|
||||
amountRemaining = amountRemaining.subtract(amountRemaining.min(payVoucherDueElement.getAmountRemaining()));
|
||||
createPayVoucherElementToPay(payVoucherDueElement, ++sequence, amountRemaining));
|
||||
amountRemaining =
|
||||
amountRemaining.subtract(
|
||||
amountRemaining.min(payVoucherDueElement.getAmountRemaining()));
|
||||
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void updateVoucher(PaymentVoucher paymentVoucher) throws AxelorException{
|
||||
public void updateVoucher(PaymentVoucher paymentVoucher) throws AxelorException {
|
||||
List<MoveLine> moveLines = new ArrayList<>();
|
||||
List<PayVoucherElementToPay> payVoucherElementToPayList = paymentVoucher.getPayVoucherElementToPayList();
|
||||
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();
|
||||
|
||||
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());
|
||||
Move move = payVoucherElementToPay.getMoveLine().getMove();
|
||||
MoveLine moveLine = payVoucherElementToPay.getMoveLine();
|
||||
|
||||
BigDecimal paidAmountInElementCurrency =
|
||||
currencyService
|
||||
.getAmountCurrencyConvertedAtDate(
|
||||
move.getCompanyCurrency(),
|
||||
move.getCurrency(),
|
||||
moveLine.getAmountPaid(),
|
||||
moveLine.getDate())
|
||||
.setScale(2, RoundingMode.HALF_EVEN);
|
||||
|
||||
|
||||
|
||||
payVoucherElementToPay.setRemainingAmount(
|
||||
moveLine.getCurrencyAmount().subtract(paidAmountInElementCurrency));
|
||||
payVoucherElementToPay.setTotalAmount(moveLine.getCurrencyAmount());
|
||||
|
||||
elementToPayRepository.save(payVoucherElementToPay);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
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;
|
||||
@@ -23,11 +15,33 @@ import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
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;
|
||||
|
||||
public class CashInventoryController {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@Inject
|
||||
private final ConvertNumberToFrenchWordsService convertService;
|
||||
|
||||
@Inject
|
||||
public CashInventoryController(ConvertNumberToFrenchWordsService convertService) {
|
||||
this.convertService = convertService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the cash inventory report.
|
||||
*
|
||||
* @param request The action request containing the context.
|
||||
* @param response The action response to set the view with the report link.
|
||||
* @throws AxelorException If an error occurs during report generation.
|
||||
*/
|
||||
public void printCashInventory(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
@@ -38,72 +52,109 @@ public class CashInventoryController {
|
||||
name += " " + cashInventory.getRef();
|
||||
}
|
||||
|
||||
String fileLink =
|
||||
ReportFactory.createReport(String.format(IReport.CASH_INVENTORY, cashInventory.getOperationTypeSelect()), name + "-${date}")
|
||||
.addParam("cashInventoryId", cashInventory.getId())
|
||||
.generate()
|
||||
.getFileLink();
|
||||
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){
|
||||
|
||||
/**
|
||||
* Computes the theoretical solde in words for the cash inventory.
|
||||
*
|
||||
* @param request The action request containing the context.
|
||||
* @param response The action response to set the theoretical solde in words.
|
||||
*/
|
||||
public void convertTheoricalSoldeInWords(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";
|
||||
String[] arrOfStr = cashInventory.getPhysicalSolde().toString().split("\\.");
|
||||
|
||||
String left = convertService.convert(Long.parseLong(arrOfStr[0]));
|
||||
String right = convertService.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);
|
||||
|
||||
/**
|
||||
* Initializes the theoretical solde in words for the cash inventory.
|
||||
*
|
||||
* @param request The action request containing the context.
|
||||
* @param response The action response to set the theoretical solde value.
|
||||
*/
|
||||
public void initThetoricalSolde(ActionRequest request, ActionResponse response) {
|
||||
BigDecimal theoricalSolde = Beans.get(CashInventoryService.class).initThetoricalSolde();
|
||||
response.setValue("theoricalSolde", theoricalSolde);
|
||||
}
|
||||
|
||||
public void getLastCashData(ActionRequest request, ActionResponse response){
|
||||
CashInventory lastCashInventory = Beans.get(CashInventoryRepository.class).all().order("-id").fetchOne();
|
||||
/**
|
||||
* Computes the totals for the cash inventory.
|
||||
*
|
||||
* @param request The action request containing the context.
|
||||
* @param response The action response to set the computed values.
|
||||
*/
|
||||
public void computeToTals(ActionRequest request, ActionResponse response) {
|
||||
|
||||
List<PaymentVoucher> cashVouchers = Beans.get(PaymentVoucherRepository.class).all().filter("self.operationTypeSelect = 9 and self.cashStatusSelect = 3").fetch();
|
||||
CashInventory cashInventory = request.getContext().asType(CashInventory.class);
|
||||
if(cashInventory.getCashInventoryLines() != null && cashInventory.getCashInventoryLines().size() != 0){
|
||||
Map<String, BigDecimal> map = Beans.get(CashInventoryService.class).computeToTals(cashInventory);
|
||||
response.setValues(map);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the last cash data and calculates the theoretical solde.
|
||||
*
|
||||
* @param request The action request containing the context.
|
||||
* @param response The action response to set the theoretical solde value.
|
||||
*/
|
||||
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());
|
||||
totalSolde = totalSolde.subtract(paymentVoucher.getPaidAmount());
|
||||
break;
|
||||
case "2":
|
||||
totalSolde = totalSolde.add(paymentVoucher.getPaidAmount());
|
||||
totalSolde = totalSolde.add(paymentVoucher.getPaidAmount());
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
response.setValue("theoricalSolde", totalSolde);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// generate sequence for cash inventory
|
||||
public void generateSequence(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
CashInventory cashInventory = request.getContext().asType(CashInventory.class);
|
||||
if (cashInventory.getRef() == null || cashInventory.getRef().isEmpty()) {
|
||||
String sequence = Beans.get(CashInventoryService.class).getCashInventorySequence(cashInventory);
|
||||
response.setValue("ref", sequence);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void approveCashInventory(ActionRequest request, ActionResponse response) throws AxelorException{
|
||||
CashInventory cashInventoryContext = request.getContext().asType(CashInventory.class);
|
||||
CashInventory cashInventory = Beans.get(CashInventoryRepository.class).find(cashInventoryContext.getId());
|
||||
Beans.get(CashInventoryService.class).approveCashInventory(cashInventory);
|
||||
response.setReload(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,17 @@
|
||||
*/
|
||||
package com.axelor.apps.account.web;
|
||||
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.axelor.apps.account.db.AccountingSituation;
|
||||
import com.axelor.apps.account.db.Invoice;
|
||||
import com.axelor.apps.account.db.InvoicePayment;
|
||||
import com.axelor.apps.account.db.Journal;
|
||||
import com.axelor.apps.account.db.PaymentCondition;
|
||||
import com.axelor.apps.account.db.PaymentMode;
|
||||
import com.axelor.apps.account.db.PaymentVoucher;
|
||||
import com.axelor.apps.account.db.Journal;
|
||||
import com.axelor.apps.account.db.repo.AccountConfigRepository;
|
||||
import com.axelor.apps.account.db.repo.InvoiceRepository;
|
||||
import com.axelor.apps.account.exception.IExceptionMessage;
|
||||
import com.axelor.apps.account.report.IReport;
|
||||
import com.axelor.apps.account.service.AccountingSituationService;
|
||||
import com.axelor.apps.account.service.IrrecoverableService;
|
||||
import com.axelor.apps.account.service.app.AppAccountService;
|
||||
@@ -38,7 +39,6 @@ import com.axelor.apps.base.db.BankDetails;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Currency;
|
||||
import com.axelor.apps.base.db.Partner;
|
||||
import com.axelor.apps.base.db.PartnerCategory;
|
||||
import com.axelor.apps.base.db.PriceList;
|
||||
import com.axelor.apps.base.db.PrintingSettings;
|
||||
import com.axelor.apps.base.db.Wizard;
|
||||
@@ -46,6 +46,7 @@ import com.axelor.apps.base.db.repo.LanguageRepository;
|
||||
import com.axelor.apps.base.db.repo.PartnerRepository;
|
||||
import com.axelor.apps.base.service.AddressService;
|
||||
import com.axelor.apps.base.service.BankDetailsService;
|
||||
import com.axelor.apps.base.service.ConvertNumberToFrenchWordsService;
|
||||
import com.axelor.apps.base.service.PartnerPriceListService;
|
||||
import com.axelor.apps.base.service.PartnerService;
|
||||
import com.axelor.apps.base.service.TradingNameService;
|
||||
@@ -64,21 +65,17 @@ import com.axelor.meta.schema.actions.ActionView.ActionViewBuilder;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.axelor.rpc.Context;
|
||||
import com.axelor.apps.base.service.ConvertNumberToFrenchWordsService;
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.inject.Singleton;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.HashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -962,72 +959,89 @@ public class InvoiceController {
|
||||
}
|
||||
response.setAttr("partner", "domain", domain);
|
||||
}
|
||||
|
||||
|
||||
public void printInvoicePayment(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
String name = I18n.get("Payment voucher");
|
||||
String AmountToPay = request.getContext().get("amount").toString();
|
||||
String[] arrOfStr = AmountToPay.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+" centimes";
|
||||
String chequeModelBank = request.getContext().get("chequeModelBank").toString();
|
||||
BigDecimal amount = new BigDecimal(AmountToPay);
|
||||
|
||||
String fileLink =
|
||||
ReportFactory.createReport("chequeModelBank.rptdesign", name + "-${date}")
|
||||
.addParam("NumberToWords", number)
|
||||
.addParam("Wilaya", request.getContext().get("wilaya").toString())
|
||||
.addParam("amount", amount)
|
||||
.addParam("date", request.getContext().get("date").toString() )
|
||||
.addParam("name", request.getContext().get("PartnerName"))
|
||||
.addParam("chequeModelBank", chequeModelBank)
|
||||
.generate()
|
||||
.getFileLink();
|
||||
|
||||
logger.debug("Printing " + name);
|
||||
|
||||
response.setView(ActionView.define(name).add("html", fileLink).map());
|
||||
|
||||
String name = I18n.get("Payment voucher");
|
||||
String AmountToPay = request.getContext().get("amount").toString();
|
||||
String[] arrOfStr = AmountToPay.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 + " centimes";
|
||||
String chequeModelBank = request.getContext().get("chequeModelBank").toString();
|
||||
BigDecimal amount = new BigDecimal(AmountToPay);
|
||||
|
||||
String fileLink =
|
||||
ReportFactory.createReport("chequeModelBank.rptdesign", name + "-${date}")
|
||||
.addParam("NumberToWords", number)
|
||||
.addParam("Wilaya", request.getContext().get("wilaya").toString())
|
||||
.addParam("amount", amount)
|
||||
.addParam("date", request.getContext().get("date").toString())
|
||||
.addParam("name", request.getContext().get("PartnerName"))
|
||||
.addParam("chequeModelBank", chequeModelBank)
|
||||
.generate()
|
||||
.getFileLink();
|
||||
|
||||
logger.debug("Printing " + name);
|
||||
|
||||
response.setView(ActionView.define(name).add("html", fileLink).map());
|
||||
}
|
||||
|
||||
public void printPaymentFile(ActionRequest request, ActionResponse response)
|
||||
public void printPaymentFile2(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
|
||||
|
||||
|
||||
String name = I18n.get("Payment voucher");
|
||||
String AmountToPay = paymentVoucher.getPaidAmount().toString();
|
||||
String[] arrOfStr = AmountToPay.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+" centimes";
|
||||
|
||||
String[] arrOfStr = AmountToPay.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 + " centimes";
|
||||
|
||||
String reportType = "PaymentRequest.rptdesign";
|
||||
|
||||
System.out.println("mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
|
||||
System.out.println(paymentVoucher.getOperationTypeSelect());
|
||||
System.out.println(paymentVoucher.getDebitCreditSelect());
|
||||
System.out.println(paymentVoucher.getOperationTypeSelect() == 9);
|
||||
System.out.println(paymentVoucher.getDebitCreditSelect() == "1");
|
||||
|
||||
if(paymentVoucher.getOperationTypeSelect() == 9){
|
||||
if(paymentVoucher.getDebitCreditSelect().equals("1")){
|
||||
reportType = "CashPaymentRequestDebit.rptdesign";
|
||||
}else if(paymentVoucher.getDebitCreditSelect().equals("2")){
|
||||
reportType = "CashPaymentRequestCredit.rptdesign";
|
||||
}
|
||||
}
|
||||
|
||||
String fileLink =
|
||||
ReportFactory.createReport("PaymentRequest.rptdesign", name + "-${date}")
|
||||
ReportFactory.createReport(reportType, name + "-${date}")
|
||||
.addParam("PaymentVoucherId", paymentVoucher.getId())
|
||||
.addParam("NumberToWords", number)
|
||||
.generate()
|
||||
.getFileLink();
|
||||
|
||||
logger.debug("Printing " + name);
|
||||
|
||||
response.setView(ActionView.define(name).add("html", fileLink).map());
|
||||
|
||||
response.setView(ActionView.define(name).add("html", fileLink).map());
|
||||
}
|
||||
|
||||
public void showInvoice2(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
public void showInvoice2(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
|
||||
Context context = request.getContext();
|
||||
|
||||
Invoice invoice = Beans.get(InvoiceRepository.class)
|
||||
.find(Long.parseLong(context.get("id").toString()));
|
||||
|
||||
String name = I18n.get("Invoice");
|
||||
Invoice invoice =
|
||||
Beans.get(InvoiceRepository.class).find(Long.parseLong(context.get("id").toString()));
|
||||
|
||||
String name = I18n.get("Invoice");
|
||||
|
||||
String format = context.get("format") != null ? context.get("format").toString() : "pdf";
|
||||
Integer reportType =
|
||||
@@ -1048,14 +1062,16 @@ public class InvoiceController {
|
||||
.getCode()
|
||||
: null;
|
||||
|
||||
ReportSettings reportSettings = Beans.get(InvoicePrintService.class).prepareReportSettings(invoice, reportType, format, locale);
|
||||
ReportSettings reportSettings =
|
||||
Beans.get(InvoicePrintService.class)
|
||||
.prepareReportSettings(invoice, reportType, format, locale);
|
||||
|
||||
logger.debug("Printing " + name);
|
||||
|
||||
response.setView(ActionView.define(name).add("html", reportSettings.generate().getFileLink()).map());
|
||||
|
||||
response.setView(
|
||||
ActionView.define(name).add("html", reportSettings.generate().getFileLink()).map());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* set default value for automatic invoice Journal = supplier Purchase Journal
|
||||
*
|
||||
@@ -1067,23 +1083,21 @@ public class InvoiceController {
|
||||
Invoice invoice = request.getContext().asType(Invoice.class);
|
||||
Company company = invoice.getCompany();
|
||||
Partner partner = invoice.getPartner();
|
||||
Journal journal = null ;
|
||||
Journal journal = null;
|
||||
Integer operationTypeSelect = invoice.getOperationTypeSelect();
|
||||
|
||||
if (company != null && partner != null && operationTypeSelect != null ) {
|
||||
if (operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE) {
|
||||
if( partner.getTypeOfSupplier() != null){
|
||||
if(partner.getTypeOfSupplier().equals("1")){
|
||||
journal = company.getAccountConfig().getSupplierPurchaseJournalForeigners();
|
||||
}
|
||||
if(partner.getTypeOfSupplier().equals("2")){
|
||||
journal = company.getAccountConfig().getSupplierPurchaseJournalLocal();
|
||||
}
|
||||
}
|
||||
response.setValue("journal", journal);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (company != null && partner != null && operationTypeSelect != null) {
|
||||
if (operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE) {
|
||||
if (partner.getTypeOfSupplier() != null) {
|
||||
if (partner.getTypeOfSupplier().equals("1")) {
|
||||
journal = company.getAccountConfig().getSupplierPurchaseJournalForeigners();
|
||||
}
|
||||
if (partner.getTypeOfSupplier().equals("2")) {
|
||||
journal = company.getAccountConfig().getSupplierPurchaseJournalLocal();
|
||||
}
|
||||
}
|
||||
response.setValue("journal", journal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,22 +403,24 @@ public class InvoiceLineController {
|
||||
response.setValue("fixedAssetCategory", fixedAssetCategory);
|
||||
}
|
||||
|
||||
|
||||
public void updateQtyUg(ActionRequest request, ActionResponse response) throws AxelorException{
|
||||
public void updateQtyUg(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
Context context = request.getContext();
|
||||
InvoiceLine invoiceLine = context.asType(InvoiceLine.class);
|
||||
|
||||
|
||||
BigDecimal qtyUg = invoiceLine.getProduct().getUg();
|
||||
BigDecimal qty = invoiceLine.getQty();
|
||||
BigDecimal totalQty = qty.add(qty.multiply(qtyUg).divide(new BigDecimal(100), 4,RoundingMode.HALF_EVEN));
|
||||
BigDecimal totalQty =
|
||||
qty.add(qty.multiply(qtyUg).divide(new BigDecimal(100), 4, RoundingMode.HALF_EVEN));
|
||||
Product product = invoiceLine.getProduct();
|
||||
if(product.getUg() != null && product.getUg().compareTo(BigDecimal.ZERO) > 0){
|
||||
BigDecimal ug = invoiceLine.getProduct().getUg().divide(new BigDecimal(100), 10, RoundingMode.HALF_EVEN);
|
||||
BigDecimal ugAmount = ug.divide(ug.add(BigDecimal.ONE),10, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100));
|
||||
if (product.getUg() != null && product.getUg().compareTo(BigDecimal.ZERO) > 0) {
|
||||
BigDecimal ug =
|
||||
invoiceLine.getProduct().getUg().divide(new BigDecimal(100), 10, RoundingMode.HALF_EVEN);
|
||||
BigDecimal ugAmount =
|
||||
ug.divide(ug.add(BigDecimal.ONE), 10, RoundingMode.HALF_EVEN)
|
||||
.multiply(new BigDecimal(100));
|
||||
response.setValue("discountTypeSelect", 1);
|
||||
response.setValue("discountAmount", ugAmount);
|
||||
response.setValue("qty", totalQty);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,52 +1,43 @@
|
||||
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;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class InvoiceTemplateControlller {
|
||||
|
||||
public void showInvoice2(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
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);
|
||||
InvoiceTemplate invoiceTemplate =
|
||||
Beans.get(InvoiceTemplateRepository.class)
|
||||
.find(Long.parseLong(context.get("id").toString()));
|
||||
|
||||
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());
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,12 +65,14 @@ public class PaymentVoucherController {
|
||||
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
|
||||
|
||||
if (Strings.isNullOrEmpty(paymentVoucher.getRef())) {
|
||||
if(paymentVoucher.getOperationTypeSelect() == 9){
|
||||
if (paymentVoucher.getOperationTypeSelect() == 9) {
|
||||
response.setValue(
|
||||
"ref", Beans.get(SequenceService.class).getSequenceNumber("CashSequence", paymentVoucher.getCompany()));
|
||||
}else{
|
||||
"ref",
|
||||
Beans.get(SequenceService.class)
|
||||
.getSequenceNumber("CashSequence", paymentVoucher.getCompany()));
|
||||
} else {
|
||||
response.setValue(
|
||||
"ref", Beans.get(PaymentVoucherSequenceService.class).getReference(paymentVoucher));
|
||||
"ref", Beans.get(PaymentVoucherSequenceService.class).getReference(paymentVoucher));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,8 +216,9 @@ public class PaymentVoucherController {
|
||||
paymentVoucher,
|
||||
rejectionInstance);
|
||||
|
||||
PaymentVoucher paymentVoucher2 =Beans.get(PaymentVoucherConfirmService.class)
|
||||
.rejectPaymentVoucher(paymentVoucher, rejectionRaison);
|
||||
PaymentVoucher paymentVoucher2 =
|
||||
Beans.get(PaymentVoucherConfirmService.class)
|
||||
.rejectPaymentVoucher(paymentVoucher, rejectionRaison);
|
||||
|
||||
// response.setReload(true);
|
||||
response.setView(
|
||||
@@ -327,9 +330,24 @@ public class PaymentVoucherController {
|
||||
if (!Strings.isNullOrEmpty(paymentVoucher.getReceiptNo())) {
|
||||
name += " " + paymentVoucher.getReceiptNo();
|
||||
}
|
||||
String reportType = IReport.PAYMENT_VOUCHER;
|
||||
|
||||
System.out.println("mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
|
||||
System.out.println(paymentVoucher.getOperationTypeSelect());
|
||||
System.out.println(paymentVoucher.getDebitCreditSelect());
|
||||
System.out.println(paymentVoucher.getOperationTypeSelect() == 9);
|
||||
System.out.println(paymentVoucher.getDebitCreditSelect() == "1");
|
||||
|
||||
if(paymentVoucher.getOperationTypeSelect() == 9){
|
||||
if(paymentVoucher.getDebitCreditSelect() == "1"){
|
||||
reportType = "CashPaymentRequestDebit.rptdesign";
|
||||
}else if(paymentVoucher.getDebitCreditSelect() == "2"){
|
||||
reportType = "CashPaymentRequestCredit.rptdesign";
|
||||
}
|
||||
}
|
||||
|
||||
String fileLink =
|
||||
ReportFactory.createReport(IReport.PAYMENT_VOUCHER, name + "-${date}")
|
||||
ReportFactory.createReport(reportType, name + "-${date}")
|
||||
.addParam("PaymentVoucherId", paymentVoucher.getId())
|
||||
.generate()
|
||||
.getFileLink();
|
||||
@@ -380,7 +398,8 @@ public class PaymentVoucherController {
|
||||
}
|
||||
}
|
||||
|
||||
public void confirmMultipleVoucher(ActionRequest request,ActionResponse response) throws AxelorException {
|
||||
public void confirmMultipleVoucher(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
List<PaymentVoucher> voucherList = new ArrayList<>();
|
||||
List<PayVoucherElementToPay> elementToPays = new ArrayList<>();
|
||||
|
||||
@@ -388,22 +407,26 @@ public class PaymentVoucherController {
|
||||
List<Integer> idList = (List<Integer>) request.getContext().get("_ids");
|
||||
|
||||
for (Integer id : idList) {
|
||||
PaymentVoucher paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(id.longValue());
|
||||
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);
|
||||
|
||||
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());
|
||||
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 {
|
||||
public void getVoucherData(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
List<PaymentVoucher> voucherList = new ArrayList<>();
|
||||
List<PayVoucherElementToPay> elementToPays = new ArrayList<>();
|
||||
|
||||
@@ -419,47 +442,83 @@ public class PaymentVoucherController {
|
||||
BigDecimal totalRemainingAmountAfterPaymentRefund = BigDecimal.ZERO;
|
||||
|
||||
for (Integer id : idList) {
|
||||
PaymentVoucher paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(id.longValue());
|
||||
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);
|
||||
totalVoucher =
|
||||
voucherList
|
||||
.stream()
|
||||
.map(t -> t.getPaidAmount())
|
||||
.reduce(BigDecimal::add)
|
||||
.orElse(BigDecimal.ZERO);
|
||||
|
||||
for (PayVoucherElementToPay elementPay : elementToPays) {
|
||||
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());
|
||||
}
|
||||
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());
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
public void validateCashPaymentVoucher(
|
||||
ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
|
||||
paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(paymentVoucher.getId());
|
||||
|
||||
try {
|
||||
Beans.get(PaymentVoucherConfirmService.class).validateCashPaymentVoucher(paymentVoucher);
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void cancelCashPaymentVoucher(
|
||||
ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
|
||||
paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(paymentVoucher.getId());
|
||||
|
||||
try {
|
||||
Beans.get(PaymentVoucherConfirmService.class).cancelCashPaymentVoucher(paymentVoucher);
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package com.axelor.apps.account.web;
|
||||
import com.axelor.apps.account.db.Reconcile;
|
||||
import com.axelor.apps.account.db.repo.ReconcileRepository;
|
||||
import com.axelor.apps.account.service.ReconcileService;
|
||||
import com.axelor.apps.account.service.ReconcileServiceImpl;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
@@ -43,6 +44,20 @@ public class ReconcileController {
|
||||
}
|
||||
}
|
||||
|
||||
// Unreconcile button
|
||||
public void unreconcile2(ActionRequest request, ActionResponse response) {
|
||||
|
||||
Reconcile reconcile = request.getContext().asType(Reconcile.class);
|
||||
|
||||
try {
|
||||
Beans.get(ReconcileServiceImpl.class)
|
||||
.unreconcile2(Beans.get(ReconcileRepository.class).find(reconcile.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Reconcile button
|
||||
public void reconcile(ActionRequest request, ActionResponse response) {
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ public class ImportPaymentVoucher {
|
||||
PayVoucherDueElement payVoucherDueElement =
|
||||
paymentVoucherLoadService.createPayVoucherDueElement(moveLineToPay);
|
||||
paymentVoucher.addPayVoucherElementToPayListItem(
|
||||
paymentVoucherLoadService.createPayVoucherElementToPay(payVoucherDueElement, 1,paymentVoucher.getRemainingAmount()));
|
||||
paymentVoucherLoadService.createPayVoucherElementToPay(
|
||||
payVoucherDueElement, 1, paymentVoucher.getRemainingAmount()));
|
||||
}
|
||||
|
||||
if (paymentVoucher.getStatusSelect() == PaymentVoucherRepository.STATUS_CONFIRMED) {
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
|
||||
<string name="statusSelectAccount" title="Statuses to take into account" />
|
||||
|
||||
<many-to-many name="productCategorySet" ref="com.axelor.apps.base.db.FamilleProduit" title="Product category" />
|
||||
|
||||
<unique-constraint columns="ref,company"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
@@ -3,15 +3,65 @@
|
||||
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"/>
|
||||
<module name="account" package="com.axelor.apps.account.db" />
|
||||
|
||||
<entity name="AnalyticAccount" lang="java">
|
||||
|
||||
<string name="code" title="Code" required="true"/>
|
||||
<string name="name" title="Name" required="true"/>
|
||||
<many-to-one name="analyticAxis" ref="com.axelor.apps.account.db.AnalyticAxis" title="Analytic axis"/>
|
||||
<many-to-one name="parent" ref="com.axelor.apps.account.db.AnalyticAccount" title="Parent Analytic Acc."/>
|
||||
<unique-constraint columns="code,name,analyticAxis"/>
|
||||
|
||||
<string name="code" title="Code" required="true" />
|
||||
<string name="name" title="Name"
|
||||
required="true" />
|
||||
<many-to-one name="analyticAxis"
|
||||
ref="com.axelor.apps.account.db.AnalyticAxis" title="Analytic axis" />
|
||||
<many-to-one
|
||||
name="parent" ref="com.axelor.apps.account.db.AnalyticAccount" title="Parent Analytic Acc." />
|
||||
|
||||
<string
|
||||
name="fullCode">
|
||||
<![CDATA[
|
||||
String fullName = "";
|
||||
if(code != null ){
|
||||
fullName += code;
|
||||
}
|
||||
if(parent != null) {
|
||||
fullName = parent.getCode() + "/" + fullName;
|
||||
if(parent.getParent() != null) {
|
||||
fullName = parent.getParent().getCode() + "/" + fullName;
|
||||
if(parent.getParent().getParent() != null) {
|
||||
fullName = parent.getParent().getParent().getCode() + "/" + fullName;
|
||||
if(parent.getParent().getParent().getParent() != null) {
|
||||
fullName = parent.getParent().getParent().getParent().getCode() + "/" + fullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fullName;
|
||||
]]>
|
||||
</string>
|
||||
|
||||
<string
|
||||
name="fullName" namecolumn="true">
|
||||
<![CDATA[
|
||||
String fullName = "";
|
||||
if(name != null ){
|
||||
fullName += name;
|
||||
}
|
||||
if(parent != null) {
|
||||
fullName = parent.getName() + "/" + fullName;
|
||||
if(parent.getParent() != null) {
|
||||
fullName = parent.getParent().getName() + "/" + fullName;
|
||||
if(parent.getParent().getParent() != null) {
|
||||
fullName = parent.getParent().getParent().getName() + "/" + fullName;
|
||||
if(parent.getParent().getParent().getParent() != null) {
|
||||
fullName = parent.getParent().getParent().getParent().getName() + "/" + fullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fullName;
|
||||
]]>
|
||||
</string>
|
||||
|
||||
<unique-constraint columns="code,name,analyticAxis,parent" />
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
</domain-models>
|
||||
@@ -8,10 +8,12 @@
|
||||
<entity name="AppBudget" lang="java" extends="App">
|
||||
<boolean name="checkAvailableBudget" title="Check Available Budget"/>
|
||||
<boolean name="manageMultiBudget" title="Manage multi budgets on lines"/>
|
||||
<boolean name="budgetRequiredOnPO" title="Budget required on purchase order lines"/>
|
||||
|
||||
<track>
|
||||
<field name="checkAvailableBudget" on="UPDATE"/>
|
||||
<field name="manageMultiBudget" on="UPDATE"/>
|
||||
<field name="budgetRequiredOnPO" on="UPDATE"/>
|
||||
</track>
|
||||
</entity>
|
||||
</domain-models>
|
||||
|
||||
@@ -19,7 +19,11 @@
|
||||
<integer name="periodDurationSelect" title="Period duration" selection="account.year.period.duration.select"/>
|
||||
<decimal name="amountForGeneration" title="Amount for each line"/>
|
||||
<boolean name="checkAvailableBudget" title="Check available budget"/>
|
||||
<many-to-one name="analyticAccount" ref="com.axelor.apps.account.db.AnalyticAccount" title="Analytic account"/>
|
||||
|
||||
|
||||
<finder-method name="findByAnalyticAccount" using="analyticAccount"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
// STATUS SELECT
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<many-to-one name="invoiceLine" ref="com.axelor.apps.account.db.InvoiceLine"/>
|
||||
<many-to-one name="budget" ref="com.axelor.apps.account.db.Budget" title="Budget" required="true"/>
|
||||
<decimal name="amount" title="Amount" precision="20" scale="2"/>
|
||||
|
||||
<many-to-one name="analyticAccount" ref="com.axelor.apps.account.db.AnalyticAccount" title="Analytic Acc."/>
|
||||
<many-to-one name="analyticMoveLine" ref="com.axelor.apps.account.db.AnalyticMoveLine" title="Analytic move line"/>
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
<entity name="BudgetLine" lang="java" cacheable="true">
|
||||
|
||||
<many-to-one name="analyticAccount" ref="com.axelor.apps.account.db.AnalyticAccount" title="Analytic account"/>
|
||||
<date name="fromDate" title="From"/>
|
||||
<date name="toDate" title="To"/>
|
||||
<many-to-one name="budget" ref="com.axelor.apps.account.db.Budget" />
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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="CashAccountConfig" lang="java">
|
||||
|
||||
<string name="fullName" title="Full name" namecolumn="true"/>
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company"/>
|
||||
<many-to-one name="account" ref="Account" required="true" title="Accounting.Account" initParam="true"/>
|
||||
<string name="description" title="Description" large="true"/>
|
||||
|
||||
<track>
|
||||
<field name="fullName"/>
|
||||
<field name="company"/>
|
||||
<field name="account"/>
|
||||
<field name="description"/>
|
||||
</track>
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -19,6 +19,7 @@
|
||||
<string name="theoricalSoldeInWords" title="Theorical solde in words"/>
|
||||
<decimal name="gap" title="Gap" />
|
||||
<decimal name="numbeLastCashPiece" title="Number of last cash piece" />
|
||||
<string name="numbeLastCashPieceStr" title="Last cash piece seq" />
|
||||
|
||||
<many-to-one name="approvedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Approved by"/>
|
||||
<datetime name="approvalDate" title="Approval date" readonly="true"/>
|
||||
@@ -26,6 +27,9 @@
|
||||
<many-to-one name="valdiatedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Validated by"/>
|
||||
<datetime name="validattionDate" title="Validation date" readonly="true"/>
|
||||
|
||||
<many-to-one name="confirmedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Confirmed by"/>
|
||||
<datetime name="confirmationDate" title="Confirmation date" readonly="true"/>
|
||||
|
||||
<decimal name="totalCoinsAmount" title="Total coins amount" />
|
||||
<decimal name="totalBankNotesAmount" title="Total bank notes amount" />
|
||||
<decimal name="totalCash" title="Total cash" />
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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="CashRegister" lang="java">
|
||||
|
||||
<string name="ref" title="Reference" namecolumn="true" required="false"/>
|
||||
<integer name="statusSelect" title="Status" default="1" readonly="true" selection="account.cash.register.status.select"/>
|
||||
|
||||
<decimal name="theoricalSolde" title="Theorical Solde"/>
|
||||
<decimal name="physicalSolde" title="Physical Solde"/>
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company"/>
|
||||
|
||||
<string name="description" title="Description" large="true"/>
|
||||
|
||||
<many-to-one name="openedBy" ref="com.axelor.auth.db.User" readonly="true" title="Opened by"/>
|
||||
<datetime name="openedAt" title="Opened at" readonly="true"/>
|
||||
|
||||
<many-to-one name="closedBy" ref="com.axelor.auth.db.User" readonly="true" title="Closed by"/>
|
||||
<datetime name="closedAt" title="Closed at" readonly="true"/>
|
||||
|
||||
|
||||
<track>
|
||||
<field name="ref"/>
|
||||
<field name="statusSelect"/>
|
||||
<field name="theoricalSolde"/>
|
||||
<field name="physicalSolde"/>
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -62,8 +62,11 @@
|
||||
<many-to-one name="requestedByUser" ref="com.axelor.auth.db.User" readonly="true" title="requested by"/>
|
||||
<date name="requestDate" title="request Date" />
|
||||
|
||||
<many-to-one name="recipientUser" ref="com.axelor.auth.db.User" readonly="true" title="recipient"/>
|
||||
<many-to-one name="recipientUser" ref="com.axelor.auth.db.User" title="recipient"/>
|
||||
|
||||
<many-to-one name="recipientPartner" ref="com.axelor.apps.base.db.Partner" title="recipient partner"/>
|
||||
|
||||
<string name="recipientPartnerStr" title="recipient partner"/>
|
||||
|
||||
<date name="invoiceDate" title="invoice Date" />
|
||||
<date name="dueDate" title="Due Date" />
|
||||
@@ -106,6 +109,13 @@
|
||||
|
||||
<string name="debitCreditSelect" title="Debit/Credit" selection="move.voucher.debit.credit.select"/>
|
||||
|
||||
<boolean name="cashFunding" default="false" title="Cash funding"/>
|
||||
|
||||
<many-to-one ref="CashAccountConfig" name="cashAccountConfig" title="Cash account config"/>
|
||||
|
||||
<decimal name="initialTheoricalSolde" title="Intial theoretical solde"/>
|
||||
<decimal name="theoricalSolde" title="Theoretical solde"/>
|
||||
|
||||
<unique-constraint columns="ref,company"/>
|
||||
<unique-constraint columns="receiptNo,company"/>
|
||||
|
||||
@@ -135,6 +145,7 @@
|
||||
|
||||
<track>
|
||||
<field name="statusSelect"/>
|
||||
<field name="cashStatusSelect"/>
|
||||
<message if="true" on="CREATE">Voucher created</message>
|
||||
<message if="statusSelect == 3" tag="important">Confirmed</message>
|
||||
</track>
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
</ex-property>
|
||||
</list-property>
|
||||
<property name="odaDriverClass">org.postgresql.Driver</property>
|
||||
<property name="odaURL">jdbc:postgresql://localhost:5432/bdd_sophal</property>
|
||||
<property name="odaURL">jdbc:postgresql://localhost:5432/bdd_live2</property>
|
||||
<property name="odaUser">postgres</property>
|
||||
<encrypted-property name="odaPassword" encryptionID="base64">SWpsdj1iQl5oU0dAUFYkLDlqa2hIek8qNzQ=</encrypted-property>
|
||||
</oda-data-source>
|
||||
@@ -187,6 +187,24 @@
|
||||
<text-property name="displayName">product_code</text-property>
|
||||
<text-property name="heading">product_code</text-property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="columnName">product_name</property>
|
||||
<property name="analysis">dimension</property>
|
||||
<text-property name="displayName">product_name</text-property>
|
||||
<text-property name="heading">product_name</text-property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="columnName">category</property>
|
||||
<property name="analysis">dimension</property>
|
||||
<text-property name="displayName">category</text-property>
|
||||
<text-property name="heading">category</text-property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="columnName">sub_category</property>
|
||||
<property name="analysis">dimension</property>
|
||||
<text-property name="displayName">sub_category</text-property>
|
||||
<text-property name="heading">sub_category</text-property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="columnName">account_code</property>
|
||||
<property name="analysis">dimension</property>
|
||||
@@ -251,6 +269,26 @@
|
||||
<property name="isInput">true</property>
|
||||
<property name="isOutput">false</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">param_3</property>
|
||||
<property name="paramName">AccountingReportId</property>
|
||||
<property name="nativeName"></property>
|
||||
<property name="dataType">decimal</property>
|
||||
<property name="nativeDataType">-5</property>
|
||||
<property name="position">3</property>
|
||||
<property name="isInput">true</property>
|
||||
<property name="isOutput">false</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">param_4</property>
|
||||
<property name="paramName">AccountingReportId</property>
|
||||
<property name="nativeName"></property>
|
||||
<property name="dataType">decimal</property>
|
||||
<property name="nativeDataType">-5</property>
|
||||
<property name="position">4</property>
|
||||
<property name="isInput">true</property>
|
||||
<property name="isOutput">false</property>
|
||||
</structure>
|
||||
</list-property>
|
||||
<structure name="cachedMetaData">
|
||||
<list-property name="resultSet">
|
||||
@@ -261,36 +299,51 @@
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">2</property>
|
||||
<property name="name">account_code</property>
|
||||
<property name="name">product_name</property>
|
||||
<property name="dataType">string</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">3</property>
|
||||
<property name="name">category</property>
|
||||
<property name="dataType">string</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">4</property>
|
||||
<property name="name">sub_category</property>
|
||||
<property name="dataType">string</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">5</property>
|
||||
<property name="name">account_code</property>
|
||||
<property name="dataType">string</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">6</property>
|
||||
<property name="name">initial_qty</property>
|
||||
<property name="dataType">decimal</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">4</property>
|
||||
<property name="position">7</property>
|
||||
<property name="name">initial_value</property>
|
||||
<property name="dataType">decimal</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">5</property>
|
||||
<property name="position">8</property>
|
||||
<property name="name">qty_in</property>
|
||||
<property name="dataType">decimal</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">6</property>
|
||||
<property name="position">9</property>
|
||||
<property name="name">val_in</property>
|
||||
<property name="dataType">decimal</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">7</property>
|
||||
<property name="position">10</property>
|
||||
<property name="name">qty_out</property>
|
||||
<property name="dataType">decimal</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">8</property>
|
||||
<property name="position">11</property>
|
||||
<property name="name">val_out</property>
|
||||
<property name="dataType">decimal</property>
|
||||
</structure>
|
||||
@@ -308,48 +361,69 @@
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">2</property>
|
||||
<property name="name">product_name</property>
|
||||
<property name="nativeName">product_name</property>
|
||||
<property name="dataType">string</property>
|
||||
<property name="nativeDataType">12</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">3</property>
|
||||
<property name="name">category</property>
|
||||
<property name="nativeName">category</property>
|
||||
<property name="dataType">string</property>
|
||||
<property name="nativeDataType">12</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">4</property>
|
||||
<property name="name">sub_category</property>
|
||||
<property name="nativeName">sub_category</property>
|
||||
<property name="dataType">string</property>
|
||||
<property name="nativeDataType">12</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">5</property>
|
||||
<property name="name">account_code</property>
|
||||
<property name="nativeName">account_code</property>
|
||||
<property name="dataType">string</property>
|
||||
<property name="nativeDataType">12</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">3</property>
|
||||
<property name="position">6</property>
|
||||
<property name="name">initial_qty</property>
|
||||
<property name="nativeName">initial_qty</property>
|
||||
<property name="dataType">decimal</property>
|
||||
<property name="nativeDataType">2</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">4</property>
|
||||
<property name="position">7</property>
|
||||
<property name="name">initial_value</property>
|
||||
<property name="nativeName">initial_value</property>
|
||||
<property name="dataType">decimal</property>
|
||||
<property name="nativeDataType">2</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">5</property>
|
||||
<property name="position">8</property>
|
||||
<property name="name">qty_in</property>
|
||||
<property name="nativeName">qty_in</property>
|
||||
<property name="dataType">decimal</property>
|
||||
<property name="nativeDataType">2</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">6</property>
|
||||
<property name="position">9</property>
|
||||
<property name="name">val_in</property>
|
||||
<property name="nativeName">val_in</property>
|
||||
<property name="dataType">decimal</property>
|
||||
<property name="nativeDataType">2</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">7</property>
|
||||
<property name="position">10</property>
|
||||
<property name="name">qty_out</property>
|
||||
<property name="nativeName">qty_out</property>
|
||||
<property name="dataType">decimal</property>
|
||||
<property name="nativeDataType">2</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="position">8</property>
|
||||
<property name="position">11</property>
|
||||
<property name="name">val_out</property>
|
||||
<property name="nativeName">val_out</property>
|
||||
<property name="dataType">decimal</property>
|
||||
@@ -357,35 +431,55 @@
|
||||
</structure>
|
||||
</list-property>
|
||||
<xml-property name="queryText"><![CDATA[select
|
||||
COALESCE(s1.product_code,s2.product_code) as product_code,
|
||||
COALESCE(s1.product_code,s2.productcode) as product_code,
|
||||
s1.PRODUCT_NAME,
|
||||
s1.category,
|
||||
s1.sub_category,
|
||||
coalesce(account_code,s2.code) as account_code,
|
||||
coalesce(initial_qty,0) as initial_qty,
|
||||
coalesce(initial_value,0) as initial_value,
|
||||
coalesce(qty_in,0) as qty_in,
|
||||
coalesce(val_in,0) as val_in,
|
||||
coalesce(qty_out,0) as qty_out,
|
||||
coalesce(val_out,0) as val_out
|
||||
from
|
||||
(coalesce(initial_qty,0)) as initial_qty,
|
||||
(coalesce(initial_value,0)) as initial_value,
|
||||
(coalesce(qty_in,0)) as qty_in,
|
||||
(coalesce(val_in,0)) as val_in,
|
||||
(coalesce(qty_out,0)) as qty_out,
|
||||
(coalesce(val_out,0)) as val_out
|
||||
from
|
||||
(SELECT *
|
||||
FROM
|
||||
(SELECT
|
||||
_PRODUCT.ID AS PRODUCT_ID,
|
||||
_PRODUCT.name AS PRODUCT_NAME,
|
||||
_ACCOUNT.CODE AS ACCOUNT_CODE,
|
||||
_PRODUCT.CODE AS PRODUCT_CODE,
|
||||
_famille.name as category,
|
||||
_sous_famille.name as sub_category
|
||||
FROM BASE_PRODUCT _PRODUCT
|
||||
LEFT JOIN ACCOUNT_ACCOUNT_MANAGEMENT _MANAGEMENT ON _MANAGEMENT.PRODUCT = _PRODUCT.ID
|
||||
LEFT JOIN ACCOUNT_ACCOUNT _ACCOUNT ON _ACCOUNT.ID = _MANAGEMENT.STOCK_ACCOUNT
|
||||
left join base_famille_produit _famille on _famille.id = _product.famille_produit
|
||||
left join base_famille_produit _sous_famille on _sous_famille.id = _product.sous_famille_produit
|
||||
where (_famille.id is null or _famille.id in (select product_category_set from account_accounting_report_product_category_set where account_accounting_report = ?))
|
||||
) AS D1
|
||||
|
||||
LEFT JOIN
|
||||
(SELECT INVENTORY_LINE.PRODUCT AS PRODUCT_ID,
|
||||
SUM(REAL_QTY) AS INITIAL_QTY,
|
||||
SUM(REAL_QTY) * AVG(GAP_VALUE) AS INITIAL_VALUE
|
||||
FROM ACCOUNT_ACCOUNTING_REPORT ACCOUNTINGREPORT
|
||||
left outer JOIN STOCK_INVENTORY_LINE INVENTORY_LINE ON ACCOUNTINGREPORT.ID = ?
|
||||
LEFT JOIN STOCK_INVENTORY INVENTORY ON INVENTORY.ID = INVENTORY_LINE.INVENTORY
|
||||
left join base_period _period on ACCOUNTINGREPORT.period = _period.id
|
||||
left join base_year _year on _year.id = _period.year
|
||||
left join base_period _period_inventory on inventory.period = _period_inventory.id
|
||||
left join base_year _year_inventory on _year_inventory.id = _period_inventory.year
|
||||
WHERE INVENTORY.ID IS NOT NULL and inventory.stock_location not in (5,6) AND cast(_year.code as decimal) = cast(_year_inventory.code as decimal) + 1
|
||||
and (real_qty > 0 )
|
||||
GROUP BY PRODUCT_ID) as D2 on D2.PRODUCT_ID = D1.PRODUCT_ID) as s1
|
||||
full outer join
|
||||
(select
|
||||
_ACCOUNT.code as account_code,
|
||||
_product.code as product_code,
|
||||
sum(real_qty) as initial_qty,
|
||||
sum(real_qty) * avg(gap_value) as initial_value
|
||||
from account_accounting_report AccountingReport
|
||||
left join base_product _product on AccountingReport.id = ?
|
||||
left join stock_inventory_line inventory_line on inventory_line.product = _product.id
|
||||
left join stock_inventory inventory on inventory.id = inventory_line.inventory
|
||||
LEFT JOIN ACCOUNT_ACCOUNT_MANAGEMENT _MANAGEMENT ON _MANAGEMENT.PRODUCT = _product.id
|
||||
LEFT JOIN ACCOUNT_ACCOUNT _ACCOUNT ON _ACCOUNT.ID = _MANAGEMENT.STOCK_ACCOUNT
|
||||
where (date_part('year',inventory.planned_start_datet) = 2022 or inventory.id is null)
|
||||
and inventory.stock_location not in (5,6)
|
||||
group by _ACCOUNT.code,product_code
|
||||
) as s1
|
||||
full outer join
|
||||
(select a.CODE,
|
||||
a.CODE,
|
||||
a.NAME,
|
||||
a.product_code,
|
||||
a.qty_in,
|
||||
coalesce(a.product_code,b.product_code) as productcode,
|
||||
a.qty_in,
|
||||
val_in,
|
||||
b.qty_out,
|
||||
val_out
|
||||
@@ -395,11 +489,11 @@ group by _ACCOUNT.code,product_code
|
||||
_PRODUCT.CODE as product_code,
|
||||
sum(real_qty) as qty_in,
|
||||
sum(case
|
||||
when _move.type_select = 3 and _move.partner != 853 then round(_LINE.UNIT_PRICE_UNTAXED,3) * _line.real_qty
|
||||
when _move.type_select = 3 and _move.partner = 853 then ROUND(_LINE.wap_price,3) * _line.real_qty
|
||||
when _move.type_select = 3 and _move.partner != 853 then round(_LINE.UNIT_PRICE_UNTAXED,2) * _line.real_qty
|
||||
when _move.type_select = 3 and _move.partner = 853 then ROUND(_LINE.wap_price,2) * _line.real_qty
|
||||
else 0 end) val_in
|
||||
from account_accounting_report AccountingReport
|
||||
left outer join STOCK_STOCK_MOVE_LINE _LINE on AccountingReport.id = 9
|
||||
left outer join STOCK_STOCK_MOVE_LINE _LINE on AccountingReport.id = ?
|
||||
LEFT JOIN STOCK_STOCK_MOVE _MOVE ON _MOVE.ID = _LINE.STOCK_MOVE
|
||||
LEFT JOIN BASE_PRODUCT _PRODUCT ON _PRODUCT.ID = _LINE.PRODUCT
|
||||
LEFT JOIN ACCOUNT_ACCOUNT_MANAGEMENT _MANAGEMENT ON _MANAGEMENT.PRODUCT = _LINE.PRODUCT
|
||||
@@ -410,14 +504,16 @@ WHERE _MOVE.estimated_date >= AccountingReport.date_from AND _MOVE.estimated_da
|
||||
AND (_LINE.ARCHIVED IS NULL OR _LINE.ARCHIVED IS FALSE)
|
||||
and _MOVE.type_select = 3
|
||||
and (_MOVE.from_stock_location not in (5,6) and _MOVE.to_stock_location not in (5,6))
|
||||
group by _ACCOUNT.CODE, _ACCOUNT.NAME,_PRODUCT.CODE) as a full outer join
|
||||
group by _ACCOUNT.CODE, _ACCOUNT.NAME,_PRODUCT.CODE) as a
|
||||
full outer join
|
||||
(SELECT
|
||||
_ACCOUNT.CODE,
|
||||
_ACCOUNT.NAME,
|
||||
_PRODUCT.CODE as product_code,
|
||||
sum(real_qty) as qty_out,
|
||||
sum(case
|
||||
when _move.type_select = 2 and _move.partner = 853 then round(_LINE.wap_price,3) * _line.real_qty
|
||||
when _move.type_select = 2 and _move.partner = 853 then round(_LINE.wap_price,2) * _line.real_qty
|
||||
when _move.type_select = 2 and _move.partner != 853 then round(_LINE.unit_price_untaxed,2) * _line.real_qty
|
||||
else 0 end ) val_out
|
||||
from account_accounting_report AccountingReport
|
||||
left outer join STOCK_STOCK_MOVE_LINE _LINE on AccountingReport.id = ?
|
||||
@@ -432,8 +528,14 @@ WHERE _MOVE.estimated_date >= AccountingReport.date_from AND _MOVE.estimated_da
|
||||
and _MOVE.type_select = 2
|
||||
and (_MOVE.from_stock_location not in (5,6) and _MOVE.to_stock_location not in (5,6))
|
||||
group by _ACCOUNT.CODE, _ACCOUNT.NAME,_PRODUCT.CODE) as b on a.product_code = b.product_code
|
||||
order by a.code) as s2 on s1.product_code = s2.product_code
|
||||
where account_code like '3%']]></xml-property>
|
||||
order by a.code)
|
||||
as s2 on s1.product_code = s2.productcode
|
||||
where (coalesce(s1.product_code,s2.productcode) is not null ) and account_code like '3%'
|
||||
and (coalesce(initial_qty,0) + coalesce(qty_in,0) + coalesce(qty_out,0) != 0 )
|
||||
|
||||
|
||||
|
||||
]]></xml-property>
|
||||
</oda-data-set>
|
||||
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="AccountingReportDS" id="489">
|
||||
<property name="nullsOrdering">nulls lowest</property>
|
||||
@@ -1735,7 +1837,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumSoldeQtyAgg</property>
|
||||
<text-property name="displayName">sumSoldeQty</text-property>
|
||||
<text-property name="displayName">sumSoldeVal</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<simple-property-list name="aggregateOn">
|
||||
<value>NewTableGroup1</value>
|
||||
@@ -1749,9 +1851,136 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">Aggregation_6</property>
|
||||
<text-property name="displayName">sumSoldeQty</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<simple-property-list name="aggregateOn">
|
||||
<value>NewTableGroup1</value>
|
||||
</simple-property-list>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["Aggregation"] + row["Aggregation_2"] - row["Aggregation_4"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">product_name</property>
|
||||
<text-property name="displayName">product_name</text-property>
|
||||
<expression name="expression" type="javascript">dataSetRow["product_name"]</expression>
|
||||
<property name="dataType">string</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumInitAll</property>
|
||||
<text-property name="displayName">sumInitAll</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["Aggregation"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumInitValAll</property>
|
||||
<text-property name="displayName">sumInitValAll</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["Aggregation_1"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumQttInAll</property>
|
||||
<text-property name="displayName">sumQtyInAll</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["Aggregation_2"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumValInAll</property>
|
||||
<text-property name="displayName">sumValInAll</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["Aggregation_3"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumQtyOutAll</property>
|
||||
<text-property name="displayName">sumQtyOutAll</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["Aggregation_4"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumValOutAll</property>
|
||||
<text-property name="displayName">sumValOutAll</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["Aggregation_5"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumSoldeQtyAll</property>
|
||||
<text-property name="displayName">sumSoldeQtyAll</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["Aggregation_6"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
<structure>
|
||||
<property name="name">sumSoldeValAll</property>
|
||||
<text-property name="displayName">sumSoldeValAll</text-property>
|
||||
<property name="dataType">float</property>
|
||||
<property name="aggregateFunction">SUM</property>
|
||||
<list-property name="arguments">
|
||||
<structure>
|
||||
<property name="name">Expression</property>
|
||||
<expression name="value" type="javascript">row["sumSoldeQtyAgg"]</expression>
|
||||
</structure>
|
||||
</list-property>
|
||||
<property name="allowExport">true</property>
|
||||
</structure>
|
||||
</list-property>
|
||||
<column id="4664"/>
|
||||
<column id="4665"/>
|
||||
<column id="5142"/>
|
||||
<column id="4666"/>
|
||||
<column id="4667"/>
|
||||
<column id="4668"/>
|
||||
@@ -1795,6 +2024,22 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<text-property name="text">CODE PRODUIT</text-property>
|
||||
</label>
|
||||
</cell>
|
||||
<cell id="5136">
|
||||
<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>
|
||||
<property name="verticalAlign">middle</property>
|
||||
<label id="5143">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">12pt</property>
|
||||
<text-property name="text">LIBELLE PRODUIT</text-property>
|
||||
</label>
|
||||
</cell>
|
||||
<cell id="4626">
|
||||
<property name="colSpan">2</property>
|
||||
<property name="rowSpan">1</property>
|
||||
@@ -1810,7 +2055,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<label id="4678">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">12pt</property>
|
||||
<text-property name="text">INITIALE</text-property>
|
||||
<text-property name="text">INITIAL</text-property>
|
||||
</label>
|
||||
</cell>
|
||||
<cell id="4630">
|
||||
@@ -1846,7 +2091,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<label id="5081">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">12pt</property>
|
||||
<text-property name="text">SOLDE</text-property>
|
||||
<text-property name="text">SOLDE FINAL</text-property>
|
||||
</label>
|
||||
</cell>
|
||||
</row>
|
||||
@@ -1874,6 +2119,17 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<property name="verticalAlign">middle</property>
|
||||
</cell>
|
||||
<cell id="5137">
|
||||
<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>
|
||||
<property name="verticalAlign">middle</property>
|
||||
</cell>
|
||||
<cell id="5118">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
@@ -2023,6 +2279,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="5086"/>
|
||||
<cell id="5138"/>
|
||||
<cell id="5087"/>
|
||||
<cell id="5088"/>
|
||||
<cell id="5089"/>
|
||||
@@ -2050,13 +2307,19 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
</cell>
|
||||
<cell id="5140">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
</cell>
|
||||
<cell id="5097">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5105">
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="fontSize">8pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
@@ -2072,7 +2335,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5106">
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="fontSize">8pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
@@ -2088,7 +2351,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5107">
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="fontSize">8pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
@@ -2104,7 +2367,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5128">
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="fontSize">8pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
@@ -2120,7 +2383,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5129">
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="fontSize">8pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
@@ -2136,7 +2399,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5130">
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="fontSize">8pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
@@ -2151,15 +2414,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5131">
|
||||
<property name="fontSize">9pt</property>
|
||||
<data id="5135">
|
||||
<property name="fontSize">8pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumSoldeQtyAgg</property>
|
||||
<property name="resultSetColumn">Aggregation_6</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="5111">
|
||||
@@ -2169,6 +2432,16 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5131">
|
||||
<property name="fontSize">8pt</property>
|
||||
<property name="fontWeight">bold</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumSoldeQtyAgg</property>
|
||||
</data>
|
||||
</cell>
|
||||
</row>
|
||||
</footer>
|
||||
@@ -2186,6 +2459,7 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4642">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="resultSetColumn">account_code</property>
|
||||
</data>
|
||||
</cell>
|
||||
@@ -2200,9 +2474,25 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4640">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="resultSetColumn">product_code</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="5139">
|
||||
<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="5144">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="resultSetColumn">product_name</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4643">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
@@ -2213,6 +2503,8 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4644">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
@@ -2231,6 +2523,8 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4646">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
@@ -2249,6 +2543,8 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4648">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
@@ -2267,6 +2563,8 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4650">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
@@ -2285,6 +2583,8 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4652">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
@@ -2303,6 +2603,8 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="4654">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
@@ -2321,6 +2623,8 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<text id="5082">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="dataSet">MoveLineDS</property>
|
||||
<list-property name="boundDataColumns">
|
||||
@@ -2357,6 +2661,8 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<text id="5114">
|
||||
<property name="fontFamily">"Tw Cen MT"</property>
|
||||
<property name="fontSize">9pt</property>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="dataSet">MoveLineDS</property>
|
||||
<list-property name="boundDataColumns">
|
||||
@@ -2407,6 +2713,16 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
</cell>
|
||||
<cell id="5141">
|
||||
<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="4658">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
<property name="borderBottomWidth">thin</property>
|
||||
@@ -2416,6 +2732,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5145">
|
||||
<property name="fontSize">8pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumInitAll</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4659">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
@@ -2426,6 +2751,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5146">
|
||||
<property name="fontSize">8pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumInitValAll</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4660">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
@@ -2436,6 +2770,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5147">
|
||||
<property name="fontSize">8pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumQttInAll</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4661">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
@@ -2446,6 +2789,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5148">
|
||||
<property name="fontSize">8pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumValInAll</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4662">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
@@ -2456,6 +2808,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5149">
|
||||
<property name="fontSize">8pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumQtyOutAll</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="4663">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
@@ -2466,6 +2827,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5150">
|
||||
<property name="fontSize">8pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumValOutAll</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="5079">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
@@ -2476,6 +2846,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5151">
|
||||
<property name="fontSize">8pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumSoldeQtyAll</property>
|
||||
</data>
|
||||
</cell>
|
||||
<cell id="5112">
|
||||
<property name="borderBottomStyle">solid</property>
|
||||
@@ -2486,6 +2865,15 @@ where LangTranslate.message_key = ? and LangTranslate.language = ?]]></xml-prope
|
||||
<property name="borderRightWidth">thin</property>
|
||||
<property name="borderTopStyle">solid</property>
|
||||
<property name="borderTopWidth">thin</property>
|
||||
<data id="5152">
|
||||
<property name="fontSize">8pt</property>
|
||||
<structure name="numberFormat">
|
||||
<property name="category">Currency</property>
|
||||
<property name="pattern">#,##0.00{RoundingMode=HALF_UP}</property>
|
||||
</structure>
|
||||
<property name="textAlign">right</property>
|
||||
<property name="resultSetColumn">sumSoldeValAll</property>
|
||||
</data>
|
||||
</cell>
|
||||
</row>
|
||||
</footer>
|
||||
|
||||
@@ -285,7 +285,9 @@
|
||||
<xml-property name="queryText"><![CDATA[SELECT
|
||||
account_journal.code,
|
||||
account_journal.name as "JournalName",
|
||||
to_char(origin_date ,'YYYY-MM'),
|
||||
to_char(MoveLine.date_val ,'YYYY-MM'),
|
||||
-- debit,
|
||||
-- credit
|
||||
sum(debit) as debit,
|
||||
sum(credit) as credit
|
||||
from public.account_accounting_report as AccountingReport
|
||||
@@ -293,16 +295,16 @@ left outer join public.account_move_line as MoveLine on (AccountingReport.id = ?
|
||||
left outer join public.account_move as Move on (MoveLine.move = Move.id AND Move.ignore_in_accounting_ok = false)
|
||||
left join account_journal on account_journal.id = Move.journal
|
||||
where
|
||||
(AccountingReport.date_from IS NULL OR MoveLine.origin_date >= AccountingReport.date_from) AND
|
||||
(AccountingReport.date_to IS NULL OR MoveLine.origin_date <= AccountingReport.date_to) AND
|
||||
MoveLine.origin_date <= AccountingReport.date_val
|
||||
AND Move.company = AccountingReport.company and Move.status_select = 3
|
||||
(AccountingReport.date_from IS NULL OR MoveLine.date_val >= AccountingReport.date_from) AND
|
||||
(AccountingReport.date_to IS NULL OR MoveLine.date_val <= AccountingReport.date_to) AND
|
||||
MoveLine.date_val <= AccountingReport.date_val
|
||||
AND Move.company = AccountingReport.company and Move.status_select = 3
|
||||
group by
|
||||
to_char(origin_date ,'YYYY-MM'),
|
||||
to_char(MoveLine.date_val ,'YYYY-MM'),
|
||||
account_journal.code,
|
||||
account_journal.name
|
||||
order by
|
||||
to_char(origin_date ,'YYYY-MM')]]></xml-property>
|
||||
to_char(MoveLine.date_val ,'YYYY-MM')]]></xml-property>
|
||||
</oda-data-set>
|
||||
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="AccountingReportDS" id="489">
|
||||
<property name="nullsOrdering">nulls lowest</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
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,80 @@
|
||||
package com.axelor.apps.account.web;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.axelor.apps.account.db.CashInventory;
|
||||
import com.axelor.apps.base.service.ConvertNumberToFrenchWordsService;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import static org.mockito.Mockito.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class CashInventoryControllerTest {
|
||||
|
||||
private CashInventoryController controller;
|
||||
private ActionRequest request;
|
||||
private ActionResponse response;
|
||||
private CashInventory cashInventory;
|
||||
private ConvertNumberToFrenchWordsService convertService;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
request = mock(ActionRequest.class);
|
||||
response = mock(ActionResponse.class);
|
||||
cashInventory = mock(CashInventory.class);
|
||||
convertService = mock(ConvertNumberToFrenchWordsService.class);
|
||||
|
||||
controller = new CashInventoryController(convertService); // ✅ No Guice needed
|
||||
|
||||
// Mock request.getContext().asType(CashInventory.class)
|
||||
com.axelor.rpc.Context context = mock(com.axelor.rpc.Context.class);
|
||||
when(request.getContext()).thenReturn(context);
|
||||
when(context.asType(CashInventory.class)).thenReturn(cashInventory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_withDecimalSolde() {
|
||||
// Given
|
||||
when(cashInventory.getTheoricalSolde()).thenReturn(new BigDecimal("1234.56"));
|
||||
when(convertService.convert(1234L)).thenReturn("mille deux cent trente-quatre");
|
||||
when(convertService.convert(56L)).thenReturn("cinquante-six");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_withIntegerSolde() {
|
||||
// Given
|
||||
when(cashInventory.getTheoricalSolde()).thenReturn(new BigDecimal("1000.00"));
|
||||
when(convertService.convert(1000L)).thenReturn("mille");
|
||||
when(convertService.convert(0L)).thenReturn("zéro");
|
||||
|
||||
|
||||
// Then
|
||||
ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
|
||||
ArgumentCaptor<String> valueCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(response).setValue(keyCaptor.capture(), valueCaptor.capture());
|
||||
assertEquals("theoricalSoldeInWords", keyCaptor.getValue());
|
||||
assertEquals("mille dinars algériens et zéro Cts", valueCaptor.getValue());
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testConvert_withNoDecimalPart() {
|
||||
// // Given
|
||||
// when(cashInventory.getTheoricalSolde()).thenReturn(new BigDecimal("42"));
|
||||
// when(convertService.convert(42L)).thenReturn("quarante-deux");
|
||||
// when(convertService.convert(0L)).thenReturn("zéro");
|
||||
|
||||
|
||||
// // Then
|
||||
// ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
|
||||
// ArgumentCaptor<String> valueCaptor = ArgumentCaptor.forClass(String.class);
|
||||
// verify(response).setValue(keyCaptor.capture(), valueCaptor.capture());
|
||||
// assertEquals("theoricalSoldeInWords", keyCaptor.getValue());
|
||||
// assertEquals("quarante-deux dinars algériens et zéro Cts",
|
||||
// valueCaptor.getValue());
|
||||
// }
|
||||
}
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
<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-test" />
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/bdd_sophal" />
|
||||
|
||||
<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="root" />
|
||||
|
||||
<!--
|
||||
value="create" to build a new database on each run;
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
*/
|
||||
package com.axelor.apps.base.service;
|
||||
|
||||
|
||||
|
||||
public interface ConvertNumberToFrenchWordsService {
|
||||
|
||||
public String convert(long number);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,202 +16,203 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.axelor.apps.base.service;
|
||||
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class ConvertNumberToFrenchWordsServiceImpl implements ConvertNumberToFrenchWordsService {
|
||||
|
||||
private final String[] dizaineNames = { "", //
|
||||
"", //
|
||||
"vingt", //
|
||||
"trente", //
|
||||
"quarante", //
|
||||
"cinquante", //
|
||||
"soixante", //
|
||||
"soixante", //
|
||||
"quatre-vingt", //
|
||||
"quatre-vingt" //
|
||||
};
|
||||
private final String[] dizaineNames = {
|
||||
"", //
|
||||
"", //
|
||||
"vingt", //
|
||||
"trente", //
|
||||
"quarante", //
|
||||
"cinquante", //
|
||||
"soixante", //
|
||||
"soixante", //
|
||||
"quatre-vingt", //
|
||||
"quatre-vingt" //
|
||||
};
|
||||
|
||||
private final String[] uniteNames1 = { "", //
|
||||
"un", //
|
||||
"deux", //
|
||||
"trois", //
|
||||
"quatre", //
|
||||
"cinq", //
|
||||
"six", //
|
||||
"sept", //
|
||||
"huit", //
|
||||
"neuf", //
|
||||
"dix", //
|
||||
"onze", //
|
||||
"douze", //
|
||||
"treize", //
|
||||
"quatorze", //
|
||||
"quinze", //
|
||||
"seize", //
|
||||
"dix-sept", //
|
||||
"dix-huit", //
|
||||
"dix-neuf" //
|
||||
};
|
||||
private final String[] uniteNames1 = {
|
||||
"", //
|
||||
"un", //
|
||||
"deux", //
|
||||
"trois", //
|
||||
"quatre", //
|
||||
"cinq", //
|
||||
"six", //
|
||||
"sept", //
|
||||
"huit", //
|
||||
"neuf", //
|
||||
"dix", //
|
||||
"onze", //
|
||||
"douze", //
|
||||
"treize", //
|
||||
"quatorze", //
|
||||
"quinze", //
|
||||
"seize", //
|
||||
"dix-sept", //
|
||||
"dix-huit", //
|
||||
"dix-neuf" //
|
||||
};
|
||||
|
||||
private final String[] uniteNames2 = { "", //
|
||||
"", //
|
||||
"deux", //
|
||||
"trois", //
|
||||
"quatre", //
|
||||
"cinq", //
|
||||
"six", //
|
||||
"sept", //
|
||||
"huit", //
|
||||
"neuf", //
|
||||
"dix" //
|
||||
};
|
||||
private final String[] uniteNames2 = {
|
||||
"", //
|
||||
"", //
|
||||
"deux", //
|
||||
"trois", //
|
||||
"quatre", //
|
||||
"cinq", //
|
||||
"six", //
|
||||
"sept", //
|
||||
"huit", //
|
||||
"neuf", //
|
||||
"dix" //
|
||||
};
|
||||
|
||||
|
||||
private String convertZeroToHundred(int number) {
|
||||
|
||||
private String convertZeroToHundred(int number) {
|
||||
int laDizaine = number / 10;
|
||||
int lUnite = number % 10;
|
||||
String resultat = "";
|
||||
|
||||
int laDizaine = number / 10;
|
||||
int lUnite = number % 10;
|
||||
String resultat = "";
|
||||
|
||||
switch (laDizaine) {
|
||||
switch (laDizaine) {
|
||||
case 1:
|
||||
case 7:
|
||||
case 9:
|
||||
lUnite = lUnite + 10;
|
||||
break;
|
||||
lUnite = lUnite + 10;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
String laLiaison = "";
|
||||
if (laDizaine > 1) {
|
||||
laLiaison = "-";
|
||||
}
|
||||
switch (lUnite) {
|
||||
String laLiaison = "";
|
||||
if (laDizaine > 1) {
|
||||
laLiaison = "-";
|
||||
}
|
||||
switch (lUnite) {
|
||||
case 0:
|
||||
laLiaison = "";
|
||||
break;
|
||||
laLiaison = "";
|
||||
break;
|
||||
case 1:
|
||||
if (laDizaine == 8) {
|
||||
laLiaison = "-";
|
||||
} else {
|
||||
laLiaison = " et ";
|
||||
}
|
||||
break;
|
||||
if (laDizaine == 8) {
|
||||
laLiaison = "-";
|
||||
} else {
|
||||
laLiaison = " et ";
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
if (laDizaine == 7) {
|
||||
laLiaison = " et ";
|
||||
}
|
||||
break;
|
||||
if (laDizaine == 7) {
|
||||
laLiaison = " et ";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// dizaines en lettres
|
||||
switch (laDizaine) {
|
||||
// dizaines en lettres
|
||||
switch (laDizaine) {
|
||||
case 0:
|
||||
resultat = uniteNames1[lUnite];
|
||||
break;
|
||||
resultat = uniteNames1[lUnite];
|
||||
break;
|
||||
case 8:
|
||||
if (lUnite == 0) {
|
||||
resultat = dizaineNames[laDizaine];
|
||||
} else {
|
||||
resultat = dizaineNames[laDizaine] + laLiaison + uniteNames1[lUnite];
|
||||
}
|
||||
break;
|
||||
if (lUnite == 0) {
|
||||
resultat = dizaineNames[laDizaine];
|
||||
} else {
|
||||
resultat = dizaineNames[laDizaine] + laLiaison + uniteNames1[lUnite];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
resultat = dizaineNames[laDizaine] + laLiaison + uniteNames1[lUnite];
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
resultat = dizaineNames[laDizaine] + laLiaison + uniteNames1[lUnite];
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
|
||||
private String convertLessThanOneThousand(int number) {
|
||||
private String convertLessThanOneThousand(int number) {
|
||||
|
||||
int lesCentaines = number / 100;
|
||||
int leReste = number % 100;
|
||||
String sReste = convertZeroToHundred(leReste);
|
||||
int lesCentaines = number / 100;
|
||||
int leReste = number % 100;
|
||||
String sReste = convertZeroToHundred(leReste);
|
||||
|
||||
String resultat;
|
||||
switch (lesCentaines) {
|
||||
String resultat;
|
||||
switch (lesCentaines) {
|
||||
case 0:
|
||||
resultat = sReste;
|
||||
break;
|
||||
resultat = sReste;
|
||||
break;
|
||||
case 1:
|
||||
if (leReste > 0) {
|
||||
resultat = "cent " + sReste;
|
||||
} else {
|
||||
resultat = "cent";
|
||||
}
|
||||
break;
|
||||
if (leReste > 0) {
|
||||
resultat = "cent " + sReste;
|
||||
} else {
|
||||
resultat = "cent";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (leReste > 0) {
|
||||
resultat = uniteNames2[lesCentaines] + " cent " + sReste;
|
||||
} else {
|
||||
resultat = uniteNames2[lesCentaines] + " cents";
|
||||
}
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
if (leReste > 0) {
|
||||
resultat = uniteNames2[lesCentaines] + " cent " + sReste;
|
||||
} else {
|
||||
resultat = uniteNames2[lesCentaines] + " cents";
|
||||
}
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public String convert(long number) {
|
||||
if (number == 0) {
|
||||
return "zero";
|
||||
}
|
||||
public String convert(long number) {
|
||||
if (number == 0) {
|
||||
return "zero";
|
||||
}
|
||||
|
||||
String snumber = Long.toString(number);
|
||||
String mask = "000000000000";
|
||||
DecimalFormat df = new DecimalFormat(mask);
|
||||
snumber = df.format(number);
|
||||
String snumber = Long.toString(number);
|
||||
String mask = "000000000000";
|
||||
DecimalFormat df = new DecimalFormat(mask);
|
||||
snumber = df.format(number);
|
||||
|
||||
int lesMilliards = Integer.parseInt(snumber.substring(0, 3));
|
||||
int lesMillions = Integer.parseInt(snumber.substring(3, 6));
|
||||
int lesCentMille = Integer.parseInt(snumber.substring(6, 9));
|
||||
int lesMille = Integer.parseInt(snumber.substring(9, 12));
|
||||
int lesMilliards = Integer.parseInt(snumber.substring(0, 3));
|
||||
int lesMillions = Integer.parseInt(snumber.substring(3, 6));
|
||||
int lesCentMille = Integer.parseInt(snumber.substring(6, 9));
|
||||
int lesMille = Integer.parseInt(snumber.substring(9, 12));
|
||||
|
||||
String tradMilliards;
|
||||
switch (lesMilliards) {
|
||||
String tradMilliards;
|
||||
switch (lesMilliards) {
|
||||
case 0:
|
||||
tradMilliards = "";
|
||||
break;
|
||||
tradMilliards = "";
|
||||
break;
|
||||
case 1:
|
||||
tradMilliards = convertLessThanOneThousand(lesMilliards) + " milliard ";
|
||||
break;
|
||||
tradMilliards = convertLessThanOneThousand(lesMilliards) + " milliard ";
|
||||
break;
|
||||
default:
|
||||
tradMilliards = convertLessThanOneThousand(lesMilliards) + " milliards ";
|
||||
}
|
||||
String resultat = tradMilliards;
|
||||
tradMilliards = convertLessThanOneThousand(lesMilliards) + " milliards ";
|
||||
}
|
||||
String resultat = tradMilliards;
|
||||
|
||||
String tradMillions;
|
||||
switch (lesMillions) {
|
||||
String tradMillions;
|
||||
switch (lesMillions) {
|
||||
case 0:
|
||||
tradMillions = "";
|
||||
break;
|
||||
tradMillions = "";
|
||||
break;
|
||||
case 1:
|
||||
tradMillions = convertLessThanOneThousand(lesMillions) + " million ";
|
||||
break;
|
||||
tradMillions = convertLessThanOneThousand(lesMillions) + " million ";
|
||||
break;
|
||||
default:
|
||||
tradMillions = convertLessThanOneThousand(lesMillions) + " millions ";
|
||||
}
|
||||
resultat = resultat + tradMillions;
|
||||
tradMillions = convertLessThanOneThousand(lesMillions) + " millions ";
|
||||
}
|
||||
resultat = resultat + tradMillions;
|
||||
|
||||
String tradCentMille;
|
||||
switch (lesCentMille) {
|
||||
String tradCentMille;
|
||||
switch (lesCentMille) {
|
||||
case 0:
|
||||
tradCentMille = "";
|
||||
break;
|
||||
tradCentMille = "";
|
||||
break;
|
||||
case 1:
|
||||
tradCentMille = "mille ";
|
||||
break;
|
||||
tradCentMille = "mille ";
|
||||
break;
|
||||
default:
|
||||
tradCentMille = convertLessThanOneThousand(lesCentMille) + " mille ";
|
||||
}
|
||||
resultat = resultat + tradCentMille;
|
||||
tradCentMille = convertLessThanOneThousand(lesCentMille) + " mille ";
|
||||
}
|
||||
resultat = resultat + tradCentMille;
|
||||
|
||||
String tradMille;
|
||||
tradMille = convertLessThanOneThousand(lesMille);
|
||||
resultat = resultat + tradMille;
|
||||
String tradMille;
|
||||
tradMille = convertLessThanOneThousand(lesMille);
|
||||
resultat = resultat + tradMille;
|
||||
|
||||
return resultat;
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.axelor.apps.base.db.repo.SequenceRepository;
|
||||
import com.axelor.apps.base.exceptions.IExceptionMessage;
|
||||
import com.axelor.apps.base.service.administration.SequenceService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.base.service.BarcodeGeneratorService;
|
||||
import com.axelor.apps.message.db.EmailAddress;
|
||||
import com.axelor.common.StringUtils;
|
||||
import com.axelor.db.JPA;
|
||||
@@ -42,15 +41,14 @@ 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.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import com.axelor.meta.MetaFiles;
|
||||
import com.axelor.meta.db.MetaFile;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.validation.ValidationException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
@@ -61,6 +59,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Singleton;
|
||||
import javax.validation.ValidationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -71,7 +70,7 @@ public class PartnerServiceImpl implements PartnerService {
|
||||
|
||||
protected PartnerRepository partnerRepo;
|
||||
protected AppBaseService appBaseService;
|
||||
|
||||
|
||||
@Inject protected BarcodeGeneratorService barcodeGeneratorService;
|
||||
@Inject private MetaFiles metaFiles;
|
||||
|
||||
@@ -171,7 +170,7 @@ public class PartnerServiceImpl implements PartnerService {
|
||||
|
||||
this.setPartnerFullName(partner);
|
||||
this.setCompanyStr(partner);
|
||||
this.setPartnerBarCodeSeq(partner);
|
||||
this.setPartnerBarCodeSeq(partner);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -709,30 +708,29 @@ public class PartnerServiceImpl implements PartnerService {
|
||||
}
|
||||
return partnerQuery.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
public void setPartnerBarCodeSeq(Partner partner) {
|
||||
if (partner.getBarCodeSeq() == null) {
|
||||
try {
|
||||
boolean addPadding = false;
|
||||
InputStream inStream = null;
|
||||
|
||||
inStream =
|
||||
barcodeGeneratorService.createBarCode(
|
||||
partner.getPartnerSeq(),
|
||||
appBaseService.getAppBase().getBarcodeTypeConfigPartnerSeq(),
|
||||
addPadding);
|
||||
|
||||
if (inStream != null) {
|
||||
MetaFile barcodeFile =
|
||||
metaFiles.upload(inStream, String.format("PartnerBarCodeSeq%d.png",partner.getId()));
|
||||
partner.setBarCodeSeq(barcodeFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AxelorException e) {
|
||||
throw new ValidationException(e.getMessage());
|
||||
|
||||
public void setPartnerBarCodeSeq(Partner partner) {
|
||||
if (partner.getBarCodeSeq() == null) {
|
||||
try {
|
||||
boolean addPadding = false;
|
||||
InputStream inStream = null;
|
||||
|
||||
inStream =
|
||||
barcodeGeneratorService.createBarCode(
|
||||
partner.getPartnerSeq(),
|
||||
appBaseService.getAppBase().getBarcodeTypeConfigPartnerSeq(),
|
||||
addPadding);
|
||||
|
||||
if (inStream != null) {
|
||||
MetaFile barcodeFile =
|
||||
metaFiles.upload(inStream, String.format("PartnerBarCodeSeq%d.png", partner.getId()));
|
||||
partner.setBarCodeSeq(barcodeFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AxelorException e) {
|
||||
throw new ValidationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,32 +338,30 @@ public class UserServiceImpl implements UserService {
|
||||
Boolean sendEmailUponPasswordChange = user.getSendEmailUponPasswordChange();
|
||||
Boolean sendEmailUponAccountCreation = user.getSendEmailUponAccountCreation();
|
||||
|
||||
if(!sendEmailUponPasswordChange && !sendEmailUponAccountCreation){
|
||||
if (!sendEmailUponPasswordChange && !sendEmailUponAccountCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(sendEmailUponPasswordChange){
|
||||
if (sendEmailUponPasswordChange) {
|
||||
|
||||
if (user.equals(AuthUtils.getUser())) {
|
||||
if (user.equals(AuthUtils.getUser())) {
|
||||
logger.debug("User {} changed own password.", user.getCode());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
|
||||
Template template = appBase.getPasswordChangedTemplate();
|
||||
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
|
||||
Template template = appBase.getPasswordChangedTemplate();
|
||||
|
||||
if (template == null) {
|
||||
throw new AxelorException(
|
||||
appBase,
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Template for changed password is missing."));
|
||||
}
|
||||
if (template == null) {
|
||||
throw new AxelorException(
|
||||
appBase,
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Template for changed password is missing."));
|
||||
}
|
||||
|
||||
TemplateMessageService templateMessageService = Beans.get(TemplateMessageService.class);
|
||||
templateMessageService.generateAndSendMessage(user, template);
|
||||
}
|
||||
|
||||
else if(sendEmailUponAccountCreation){
|
||||
TemplateMessageService templateMessageService = Beans.get(TemplateMessageService.class);
|
||||
templateMessageService.generateAndSendMessage(user, template);
|
||||
} else if (sendEmailUponAccountCreation) {
|
||||
user.setSendEmailUponAccountCreation(false);
|
||||
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
|
||||
Template template = appBase.getAccountCreationTemplate();
|
||||
|
||||
@@ -17,20 +17,6 @@
|
||||
*/
|
||||
package com.axelor.apps.base.web;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import wslite.json.JSONException;
|
||||
import wslite.json.JSONObject;
|
||||
|
||||
import org.apache.batik.util.io.StringDecoder;
|
||||
|
||||
import com.axelor.app.AppSettings;
|
||||
import com.axelor.apps.base.db.AppBase;
|
||||
import com.axelor.apps.base.exceptions.IExceptionMessage;
|
||||
@@ -48,13 +34,22 @@ import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import wslite.json.JSONException;
|
||||
import wslite.json.JSONObject;
|
||||
|
||||
@Singleton
|
||||
public class AppBaseController {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
private static final String localhost = "127.0.0.1";
|
||||
|
||||
public void exportObjects(ActionRequest request, ActionResponse response) {
|
||||
@@ -133,41 +128,47 @@ public class AppBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@CallMethod
|
||||
public void execWhatsApp(String username,String message,String url,String id,String enc) throws IOException, ClassNotFoundException {
|
||||
|
||||
try{
|
||||
public void execWhatsApp(String username, String message, String url, String id, String enc)
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
try {
|
||||
String uri = Beans.get(AppBaseService.class).getAppBase().getWhatsAppURL();
|
||||
|
||||
String fullUrl = uri + "/"+ url + "/" + id;
|
||||
Socket socket = new Socket(localhost, 6060);
|
||||
// String data = "{\"username\" : \"" + username + "\",\"url\": \""+ fullUrl +"\",\"message\":\""+ message +"\"}";
|
||||
String data = username + "***"+ fullUrl +"***"+ message;
|
||||
String fullUrl = uri + "/" + url + "/" + id;
|
||||
Socket socket = new Socket(localhost, 6060);
|
||||
// String data = "{\"username\" : \"" + username + "\",\"url\": \""+ fullUrl
|
||||
// +"\",\"message\":\""+ message +"\"}";
|
||||
String data = username + "***" + fullUrl + "***" + message;
|
||||
|
||||
DataOutputStream dout=new DataOutputStream(socket.getOutputStream());
|
||||
DataOutputStream dout = new DataOutputStream(socket.getOutputStream());
|
||||
DataInputStream in = new DataInputStream(socket.getInputStream());
|
||||
|
||||
dout.write(data.getBytes("UTF8"));
|
||||
|
||||
String msg=(String)in.readUTF();
|
||||
|
||||
if( msg == "message_received"){
|
||||
String msg = (String) in.readUTF();
|
||||
|
||||
if (msg == "message_received") {
|
||||
dout.flush();
|
||||
dout.close();
|
||||
// socket.close();
|
||||
System.out.println("Message: " + msg);
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
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 };
|
||||
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()));
|
||||
}
|
||||
@@ -235,5 +236,4 @@ public class AppBaseController {
|
||||
return null; // Handle error appropriately
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ 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;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.inject.Singleton;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.axelor.rpc.Context;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class ProductController {
|
||||
@@ -139,20 +139,20 @@ public class ProductController {
|
||||
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());
|
||||
|
||||
Integer typeSelect = Integer.parseInt(context.get("printingTypeSelect").toString());
|
||||
|
||||
switch (typeSelect) {
|
||||
case 1:
|
||||
id = new Long((Integer) ((Map) context.get("product")).get("id"));
|
||||
id = new Long((Integer) ((Map) context.get("product")).get("id"));
|
||||
break;
|
||||
case 2:
|
||||
id = new Long((Integer) ((Map) request.getContext().get("stockLocation")).get("id"));
|
||||
id = new Long((Integer) ((Map) request.getContext().get("stockLocation")).get("id"));
|
||||
break;
|
||||
case 3:
|
||||
id = ((FamilleProduit) request.getContext().get("familleProduit")).getId();
|
||||
id = ((FamilleProduit) request.getContext().get("familleProduit")).getId();
|
||||
break;
|
||||
default:
|
||||
id = 0L;
|
||||
@@ -166,7 +166,7 @@ public class ProductController {
|
||||
.addParam("typeSelect", typeSelect)
|
||||
.addParam("productId", id)
|
||||
.addParam("stockLocation", id)
|
||||
.addParam("familleProduit",id)
|
||||
.addParam("familleProduit", id)
|
||||
.generate()
|
||||
.getFileLink();
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
<!-- From contact -->
|
||||
<one-to-one name="emailAddress" ref="com.axelor.apps.message.db.EmailAddress" title="Email"/>
|
||||
<one-to-one name="emailAddressCC1" ref="com.axelor.apps.message.db.EmailAddress" title="Email CC1"/>
|
||||
<one-to-one name="emailAddressCC2" ref="com.axelor.apps.message.db.EmailAddress" title="Email CC2"/>
|
||||
<string name="fax" title="Fax"/>
|
||||
<string name="fixedPhone" title="Fixed phone"/>
|
||||
<string name="mobilePhone" title="Mobile phone"/>
|
||||
|
||||
@@ -148,6 +148,9 @@
|
||||
<decimal name="ug" title="UG" />
|
||||
|
||||
<boolean name="isDangerousProduct" title="Is dangerous" />
|
||||
|
||||
|
||||
<many-to-one name="coaSpec" ref="com.axelor.meta.db.MetaFile" />
|
||||
|
||||
<finder-method name="findByCode" using="code" cacheable="true" />
|
||||
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
<?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="ProductInventory" lang="java">
|
||||
|
||||
<string name="name" title="Name" required="true" initParam="true"
|
||||
translatable="true" />
|
||||
<string name="serialNumber" title="Serial Nbr"/>
|
||||
<string name="code" title="Code" initParam="true" namecolumn="true" unique="true"/>
|
||||
|
||||
<string name="description" large="true" title="Description"
|
||||
initParam="true" translatable="true" />
|
||||
<string name="internalDescription" large="true" title="Internal description"
|
||||
initParam="true" />
|
||||
<many-to-one name="picture" ref="com.axelor.meta.db.MetaFile"
|
||||
initParam="true" />
|
||||
|
||||
<many-to-one name="familleProduit" ref="FamilleProduit"
|
||||
title="Product category" massUpdate="true" /><!--sophal-->
|
||||
<many-to-one name="sousFamilleProduit" ref="FamilleProduit"
|
||||
title="Product category" massUpdate="true" /><!--sophal-->
|
||||
<many-to-one name="sousSousFamilleProduit" ref="FamilleProduit"
|
||||
title="Product category" massUpdate="true" /><!--sophal-->
|
||||
|
||||
<many-to-one name="productCategory" ref="ProductCategory"
|
||||
title="Product category" initParam="true" massUpdate="true" />
|
||||
|
||||
<string name="unitCodeSelect" title="Unit Code"
|
||||
selection="product.unit.code.select" massUpdate="true"/><!--sophal-->
|
||||
<boolean name="codeCreated" title="code Created By Systeme" default="true"/><!--sophal-->
|
||||
<many-to-one name="productFamily" ref="ProductFamily"
|
||||
title="Accounting family" initParam="true" massUpdate="true"/>
|
||||
<many-to-one name="unit" ref="Unit" title="Unit"
|
||||
initParam="true" massUpdate="true" />
|
||||
|
||||
<integer name="saleSupplySelect" title="Sale supply default method on sale order"
|
||||
selection="product.sale.supply.select" initParam="true" massUpdate="true"/>
|
||||
|
||||
<string name="productTypeSelect" title="Type" required="true"
|
||||
selection="product.product.type.select" initParam="true" massUpdate="true"/>
|
||||
<string name="procurementMethodSelect" title="Procurement method"
|
||||
selection="product.procurement.method.select" initParam="true" />
|
||||
<boolean name="isPrototype" title="Prototype" />
|
||||
<boolean name="isUnrenewed" title="Unrenewed"/>
|
||||
<integer name="productSubTypeSelect" title="Product Subtype"
|
||||
selection="product.sub.type.product.select" />
|
||||
<integer name="inventoryTypeSelect" title="Inventory type"
|
||||
selection="product.inventory.type.select" />
|
||||
|
||||
<decimal name="salePrice" title="Sale price W.T." precision="20"
|
||||
scale="10" massUpdate="true" />
|
||||
<many-to-one name="saleCurrency" ref="com.axelor.apps.base.db.Currency"
|
||||
title="Sale currency" initParam="true" />
|
||||
<decimal name="purchasePrice" title="Purchase price W.T."
|
||||
precision="20" scale="10" massUpdate="true" />
|
||||
<many-to-one name="purchaseCurrency" ref="com.axelor.apps.base.db.Currency"
|
||||
title="Purchase / Cost currency" initParam="true" />
|
||||
<boolean name="autoUpdateSalePrice" default="false"
|
||||
title="Update sale price from cost price" />
|
||||
|
||||
<decimal name="costPrice" title="Cost price" precision="20"
|
||||
scale="10" massUpdate="true" />
|
||||
|
||||
<decimal name="managPriceCoef" title="Management coef." />
|
||||
<decimal name="shippingCoef" title="Shipping Coef." />
|
||||
<boolean name="defShipCoefByPartner" title="Define the shipping coef by partner" />
|
||||
|
||||
<date name="startDate" title="Product launch Date" initParam="true" />
|
||||
<date name="endDate" title="Product pulled off market Date"
|
||||
initParam="true" />
|
||||
|
||||
<boolean name="hasWarranty" title="Warranty" />
|
||||
<boolean name="isPerishable" title="Perishable" />
|
||||
<integer name="warrantyNbrOfMonths" title="Warranty length (in months)" />
|
||||
<integer name="perishableNbrOfMonths" title="Time before expiry (in months)" />
|
||||
<boolean name="checkExpirationDateAtStockMoveRealization" />
|
||||
|
||||
<many-to-one name="productVariantConfig"
|
||||
ref="com.axelor.apps.base.db.ProductVariantConfig" />
|
||||
<many-to-one name="productVariant" ref="com.axelor.apps.base.db.ProductVariant" />
|
||||
<many-to-one name="parentProduct" ref="com.axelor.apps.base.db.Product"
|
||||
title="Parent product" />
|
||||
<boolean name="isModel" title="Is model" />
|
||||
<boolean name="manageVariantPrice" default="false"
|
||||
title="Manage prices for product variants" />
|
||||
|
||||
<many-to-one name="defaultSupplierPartner" ref="com.axelor.apps.base.db.Partner"
|
||||
title="Default supplier" />
|
||||
|
||||
|
||||
<integer name="versionSelect" title="Version"
|
||||
selection="base.product.version.select" />
|
||||
|
||||
<boolean name="sellable" title="Sellable" default="true" />
|
||||
<boolean name="purchasable" title="Purchasable" default="true" />
|
||||
<boolean name="inAti" title="In ATI" />
|
||||
|
||||
<integer name="costTypeSelect" title="Cost type"
|
||||
selection="base.product.cost.type.select" default="1" />
|
||||
|
||||
<integer name="supplierDeliveryTime" title="Supplier delivery time (days)" />
|
||||
|
||||
<many-to-one name="barCode" title="Barcode"
|
||||
ref="com.axelor.meta.db.MetaFile" />
|
||||
<many-to-one name="barcodeTypeConfig" title="Barcode Type" ref="com.axelor.apps.base.db.BarcodeTypeConfig"/>
|
||||
<string name="fullName" title="Full name" translatable="true" />
|
||||
|
||||
|
||||
<many-to-one name="massUnit" ref="com.axelor.apps.base.db.Unit"
|
||||
title="Unit of mass" />
|
||||
<decimal name="grossMass" title="Gross mass" precision="20" scale="3" />
|
||||
<decimal name="netMass" title="Net mass" precision="20" scale="3" />
|
||||
|
||||
<many-to-one name="lengthUnit" ref="com.axelor.apps.base.db.Unit"
|
||||
title="Unit of length" />
|
||||
<decimal name="length" title="Length" default="0" />
|
||||
<decimal name="width" title="Width" default="0" />
|
||||
<decimal name="height" title="Height" default="0" />
|
||||
<decimal name="diameter" title="Diameter" />
|
||||
<decimal name="articleVolume" title="Article volume" />
|
||||
<decimal name="economicManufOrderQty" title="Economic manuf. qty"/>
|
||||
|
||||
<boolean name="isShippingCostsProduct" title="Is shipping costs product"/>
|
||||
|
||||
|
||||
<boolean name="allowToForceSaleQty" title="Allow to force sales quantities"/>
|
||||
|
||||
|
||||
<boolean name="allowToForcePurchaseQty" title="Allow to force purchases quantities"/>
|
||||
|
||||
<decimal name="ppa" title="PPA" />
|
||||
<decimal name="shp" title="SHP" />
|
||||
<decimal name="pvg" title="PVG" />
|
||||
<decimal name="stklim" title="Stklim" />
|
||||
<decimal name="ug" title="UG" />
|
||||
|
||||
<boolean name="isDangerousProduct" title="Is dangerous" />
|
||||
|
||||
|
||||
<many-to-one name="coaSpec" ref="com.axelor.meta.db.MetaFile" />
|
||||
|
||||
<finder-method name="findByCode" using="code" cacheable="true" />
|
||||
|
||||
<extra-code>
|
||||
<![CDATA[
|
||||
// PRODUCT TYPE SELECT
|
||||
public static final String PRODUCT_TYPE_SERVICE = "service";
|
||||
public static final String PRODUCT_TYPE_STORABLE = "storable";
|
||||
public static final String PRODUCT_TYPE_PACK = "pack";
|
||||
|
||||
// SALE SUPPLY SELECT
|
||||
public static final int SALE_SUPPLY_FROM_STOCK = 1;
|
||||
public static final int SALE_SUPPLY_PURCHASE = 2;
|
||||
public static final int SALE_SUPPLY_PRODUCE = 3;
|
||||
|
||||
public static final String PROCUREMENT_METHOD_BUY = "buy";
|
||||
public static final String PROCUREMENT_METHOD_PRODUCE = "produce";
|
||||
public static final String PROCUREMENT_METHOD_BUYANDPRODUCE = "buyAndProduce";
|
||||
|
||||
public static final int COST_TYPE_STANDARD = 1;
|
||||
public static final int COST_TYPE_LAST_PURCHASE_PRICE = 2;
|
||||
public static final int COST_TYPE_AVERAGE_PRICE = 3;
|
||||
public static final int COST_TYPE_LAST_PRODUCTION_PRICE = 4;
|
||||
|
||||
// PRODUCT SUB-TYPE SELECT
|
||||
public static final int PRODUCT_SUB_TYPE_FINISHED_PRODUCT = 1;
|
||||
public static final int PRODUCT_SUB_TYPE_SEMI_FINISHED_PRODUCT = 2;
|
||||
public static final int PRODUCT_SUB_TYPE_COMPONENT = 3;
|
||||
]]>
|
||||
</extra-code>
|
||||
|
||||
<track on="UPDATE">
|
||||
<field name="productCategory" />
|
||||
<field name="productFamily" />
|
||||
<field name="saleSupplySelect" />
|
||||
<field name="sellable" />
|
||||
<field name="salePrice" />
|
||||
<field name="saleCurrency" />
|
||||
<field name="unit" />
|
||||
<field name="startDate" />
|
||||
<field name="endDate" />
|
||||
<field name="purchasable" />
|
||||
<field name="purchasePrice" />
|
||||
<field name="defaultSupplierPartner" />
|
||||
<field name="purchaseCurrency" />
|
||||
<field name="supplierDeliveryTime" />
|
||||
<field name="costPrice" />
|
||||
<field name="managPriceCoef" />
|
||||
<field name="costTypeSelect" />
|
||||
<field name="hasWarranty" />
|
||||
<field name="warrantyNbrOfMonths" />
|
||||
<field name="isPerishable" />
|
||||
<field name="perishableNbrOfMonths" />
|
||||
<field name="ppa" />
|
||||
<field name="pvg" />
|
||||
<field name="shp" />
|
||||
<field name="stklim" />
|
||||
<field name="ug" />
|
||||
<message if="true" on="UPDATE">Product updated</message>
|
||||
</track>
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -21,35 +21,21 @@ import com.axelor.app.AxelorModule;
|
||||
import com.axelor.apps.base.module.AdminModule;
|
||||
import com.axelor.apps.base.module.BaseModule;
|
||||
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({UserServiceTest.MyModule.class})
|
||||
@@ -58,7 +44,6 @@ public class UserServiceTest {
|
||||
static UserService userService;
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
public static class MyModule extends AxelorModule {
|
||||
|
||||
@Override
|
||||
@@ -78,14 +63,13 @@ public class UserServiceTest {
|
||||
|
||||
@Inject UserRepository injector;
|
||||
|
||||
|
||||
// public void test() {
|
||||
// assertNotNull(injector.find(1L));
|
||||
// assertNotNull(injector.find(1L));
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testMatchPasswordPatternUpperLowerDigit() {
|
||||
Assert.assertTrue(userService.matchPasswordPattern("Axelor123"));
|
||||
Assert.assertTrue(userService.matchPasswordPattern("5"));
|
||||
Assert.assertTrue(userService.matchPasswordPattern("123Axelor"));
|
||||
Assert.assertTrue(userService.matchPasswordPattern("axelor123A"));
|
||||
}
|
||||
@@ -125,19 +109,19 @@ public class UserServiceTest {
|
||||
Assert.assertFalse(userService.matchPasswordPattern("axelor123456"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void findUser() throws AxelorException {
|
||||
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("testUnitManager");
|
||||
EntityManager entityManager = entityManagerFactory.createEntityManager();
|
||||
// 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();
|
||||
// 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();
|
||||
|
||||
// entityManager.close();
|
||||
// entityManagerFactory.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +60,8 @@ public interface IExceptionMessage {
|
||||
|
||||
static final String EVENT_MEETING_INVITATION_1 = /*$$(*/
|
||||
"No PERSON IS INVITED TO THIS MEETING" /*)*/;
|
||||
|
||||
static final String USER_EMAIL_1 = /*$$(*/
|
||||
"No email address associated to %s" /*)*/;
|
||||
|
||||
static final String USER_EMAIL_1 = /*$$(*/ "No email address associated to %s" /*)*/;
|
||||
|
||||
/** Lead controller */
|
||||
static final String LEAD_1 = /*$$(*/ "Please select the Lead(s) to print." /*)*/;
|
||||
|
||||
@@ -17,15 +17,14 @@
|
||||
*/
|
||||
package com.axelor.apps.crm.service;
|
||||
|
||||
|
||||
import com.axelor.apps.base.db.AppBase;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.base.db.Address;
|
||||
import com.axelor.apps.base.db.AppBase;
|
||||
import com.axelor.apps.base.db.ICalendarUser;
|
||||
import com.axelor.apps.base.db.Partner;
|
||||
import com.axelor.apps.base.db.repo.PartnerRepository;
|
||||
import com.axelor.apps.base.ical.ICalendarService;
|
||||
import com.axelor.apps.base.service.PartnerService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.crm.db.Event;
|
||||
import com.axelor.apps.crm.db.Lead;
|
||||
import com.axelor.apps.crm.db.RecurrenceConfiguration;
|
||||
@@ -34,14 +33,12 @@ import com.axelor.apps.crm.db.repo.LeadRepository;
|
||||
import com.axelor.apps.crm.db.repo.RecurrenceConfigurationRepository;
|
||||
import com.axelor.apps.crm.exception.IExceptionMessage;
|
||||
import com.axelor.apps.message.db.EmailAddress;
|
||||
import com.axelor.apps.message.db.Template;
|
||||
import com.axelor.apps.message.db.repo.EmailAddressRepository;
|
||||
import com.axelor.apps.message.service.MessageService;
|
||||
import com.axelor.apps.message.service.TemplateMessageService;
|
||||
import com.axelor.apps.message.db.Template;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import javax.mail.MessagingException;
|
||||
import java.io.IOException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
@@ -52,6 +49,7 @@ import com.axelor.mail.db.repo.MailFollowerRepository;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.io.IOException;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
@@ -60,11 +58,12 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.mail.MessagingException;
|
||||
import org.apache.commons.math3.exception.TooManyIterationsException;
|
||||
|
||||
public class EventServiceImpl implements EventService {
|
||||
@@ -664,30 +663,28 @@ public class EventServiceImpl implements EventService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEmailMeetingInvitation(Event event, Set<User> users) throws ClassNotFoundException, InstantiationException, IllegalAccessException,
|
||||
public void sendEmailMeetingInvitation(Event event, Set<User> users)
|
||||
throws ClassNotFoundException, InstantiationException, IllegalAccessException,
|
||||
MessagingException, IOException, AxelorException {
|
||||
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
|
||||
Template template = appBase.getSendMailToInvitedPersonInMeetingTemplate();
|
||||
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
|
||||
Template template = appBase.getSendMailToInvitedPersonInMeetingTemplate();
|
||||
|
||||
if (template == null) {
|
||||
throw new AxelorException(
|
||||
appBase,
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Template for sending meeting invitation is missing.")
|
||||
);
|
||||
}
|
||||
if (template == null) {
|
||||
throw new AxelorException(
|
||||
appBase,
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Template for sending meeting invitation is missing."));
|
||||
}
|
||||
|
||||
TemplateMessageService templateMessageService = Beans.get(TemplateMessageService.class);
|
||||
|
||||
try {
|
||||
templateMessageService.generateAndSendMessageToBulkUsers(event, template, users);
|
||||
} catch (MessagingException e) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Failed to send meeting invitation email."),
|
||||
e
|
||||
);
|
||||
}
|
||||
TemplateMessageService templateMessageService = Beans.get(TemplateMessageService.class);
|
||||
|
||||
try {
|
||||
templateMessageService.generateAndSendMessageToBulkUsers(event, template, users);
|
||||
} catch (MessagingException e) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Failed to send meeting invitation email."),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,10 +63,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.math3.ode.events.EventState;
|
||||
import java.util.Set;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -75,7 +73,6 @@ public class EventController {
|
||||
|
||||
@Inject ImportationFolderRepository importationFolderRepository;
|
||||
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
public void computeFromStartDateTime(ActionRequest request, ActionResponse response) {
|
||||
@@ -557,10 +554,23 @@ public class EventController {
|
||||
public void setImportationFolderEvent(ActionRequest request, ActionResponse response) {
|
||||
Event event = new Event();
|
||||
|
||||
final ArrayList<String> importationSequences = new ArrayList(Arrays.asList("PREPARATION","ENTAME","VALIDATION COA/FICHE TECHNIQUE","LOGISTIQUE","TRANSIT","DEDOUANEMENT","RECEPTION"));
|
||||
final ArrayList<String> importationSequences =
|
||||
new ArrayList(
|
||||
Arrays.asList(
|
||||
"PREPARATION",
|
||||
"ENTAME",
|
||||
"VALIDATION COA/FICHE TECHNIQUE",
|
||||
"LOGISTIQUE",
|
||||
"TRANSIT",
|
||||
"DEDOUANEMENT",
|
||||
"RECEPTION"));
|
||||
|
||||
ImportationFolder importationFolder = Beans.get(ImportationFolderRepository.class).find(request.getContext().asType(ImportationFolder.class).getId());
|
||||
event.setSubject(importationSequences.get(Integer.parseInt(request.getContext().get("statusSelect").toString())));
|
||||
ImportationFolder importationFolder =
|
||||
Beans.get(ImportationFolderRepository.class)
|
||||
.find(request.getContext().asType(ImportationFolder.class).getId());
|
||||
event.setSubject(
|
||||
importationSequences.get(
|
||||
Integer.parseInt(request.getContext().get("statusSelect").toString())));
|
||||
event.setStatusSelect(1);
|
||||
event.setStartDateTime(LocalDateTime.now());
|
||||
event.setEndDateTime(LocalDateTime.now().plusDays(10));
|
||||
@@ -572,22 +582,19 @@ 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());
|
||||
LOG.debug("link {}", uri + AuthUtils.getUser().getId());
|
||||
|
||||
response.setView(
|
||||
ActionView.define(I18n.get("ROQ"))
|
||||
.model("")
|
||||
.add("html", uri +AuthUtils.getUser().getId())
|
||||
.map());
|
||||
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());
|
||||
@@ -601,41 +608,41 @@ public class EventController {
|
||||
.generate()
|
||||
.getFileLink();
|
||||
|
||||
|
||||
response.setView(ActionView.define(eventName).add("html", fileLink).map());
|
||||
}
|
||||
|
||||
public void sendMailToGuests(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
public void sendMailToGuests(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
Event event = request.getContext().asType(Event.class);
|
||||
event = Beans.get(EventRepository.class).find(event.getId());
|
||||
Event event = request.getContext().asType(Event.class);
|
||||
event = Beans.get(EventRepository.class).find(event.getId());
|
||||
|
||||
Set<User> users = event.getGuestList();
|
||||
if (event.getUser() != null)
|
||||
users.add(event.getUser());
|
||||
users.add(event.getCreatedBy());
|
||||
Set<User> users = event.getGuestList();
|
||||
if (event.getUser() != null) users.add(event.getUser());
|
||||
users.add(event.getCreatedBy());
|
||||
|
||||
if (!users.isEmpty()) {
|
||||
// Check if all users have an email address
|
||||
for (User user : users) {
|
||||
if (user.getEmail() == null) {
|
||||
response.setFlash(I18n.get(String.format(IExceptionMessage.USER_EMAIL_1, user.getName())));
|
||||
return; // Exit the method if any user lacks an email
|
||||
}
|
||||
}
|
||||
|
||||
// All users have emails; proceed to send emails
|
||||
try {
|
||||
Beans.get(EventService.class).sendEmailMeetingInvitation(event,users);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage());
|
||||
return; // Exit if any email fails to send
|
||||
}
|
||||
|
||||
response.setFlash(I18n.get("Emails successfully sent to all guests."));
|
||||
|
||||
} else {
|
||||
response.setFlash(I18n.get(IExceptionMessage.EVENT_MEETING_INVITATION_1));
|
||||
if (!users.isEmpty()) {
|
||||
// Check if all users have an email address
|
||||
for (User user : users) {
|
||||
if (user.getEmail() == null) {
|
||||
response.setFlash(
|
||||
I18n.get(String.format(IExceptionMessage.USER_EMAIL_1, user.getName())));
|
||||
return; // Exit the method if any user lacks an email
|
||||
}
|
||||
}
|
||||
|
||||
// All users have emails; proceed to send emails
|
||||
try {
|
||||
Beans.get(EventService.class).sendEmailMeetingInvitation(event, users);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage());
|
||||
return; // Exit if any email fails to send
|
||||
}
|
||||
|
||||
response.setFlash(I18n.get("Emails successfully sent to all guests."));
|
||||
|
||||
} else {
|
||||
response.setFlash(I18n.get(IExceptionMessage.EVENT_MEETING_INVITATION_1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
package com.axelor.apps.hr.job;
|
||||
|
||||
import com.axelor.apps.hr.db.CheckInOut;
|
||||
import com.axelor.app.AppSettings;
|
||||
import com.axelor.apps.hr.db.repo.CheckInOutRepository;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.inject.Beans;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.time.LocalDate;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.axelor.inject.Beans;
|
||||
import java.time.LocalDate;
|
||||
import org.quartz.SchedulerException;
|
||||
import com.axelor.app.AppSettings;
|
||||
|
||||
public class FetchCheckInOutJob implements Job {
|
||||
|
||||
@@ -38,14 +37,18 @@ public class FetchCheckInOutJob implements Job {
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
// Fetch the CheckInOut list from the repository where the date_attendance is today
|
||||
int lenCheckInOutList = Beans.get(CheckInOutRepository.class)
|
||||
.all()
|
||||
.filter("self.date_attendance = :today")
|
||||
.bind("today", today)
|
||||
.fetch().size();
|
||||
int lenCheckInOutList =
|
||||
Beans.get(CheckInOutRepository.class)
|
||||
.all()
|
||||
.filter("self.date_attendance = :today")
|
||||
.bind("today", today)
|
||||
.fetch()
|
||||
.size();
|
||||
|
||||
// Define the command to run the Python script with the correct path (V3)
|
||||
String[] args = {"python", pythonScriptDir + "\\Scrape\\main2.py", String.valueOf(lenCheckInOutList)};
|
||||
String[] args = {
|
||||
"python", pythonScriptDir + "\\Scrape\\main2.py", String.valueOf(lenCheckInOutList)
|
||||
};
|
||||
|
||||
// Execute the command
|
||||
Process p = Runtime.getRuntime().exec(args);
|
||||
@@ -101,5 +104,4 @@ public class FetchCheckInOutJob implements Job {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.axelor.apps.hr.service;
|
||||
import com.axelor.apps.hr.db.Absence;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface AbsenceService {
|
||||
|
||||
@@ -13,13 +13,16 @@ public interface AbsenceService {
|
||||
void attachTheAbsenceWithDailyReport(Absence absence, List<DailyReport> dailyreports);
|
||||
|
||||
@Transactional
|
||||
void deAttachTheAbsenceWithDailyReport(Absence absence, List<DailyReport> dailyreports, Boolean archive);
|
||||
void deAttachTheAbsenceWithDailyReport(
|
||||
Absence absence, List<DailyReport> dailyreports, Boolean archive);
|
||||
|
||||
@Transactional
|
||||
void chooseAbsenceType(Absence absence, Integer selectedType);
|
||||
|
||||
@Transactional
|
||||
BigDecimal calculateTotalAbsenceHours(LocalDateTime absenceStartDate, LocalDateTime absenceEndDate);
|
||||
BigDecimal calculateTotalAbsenceHours(
|
||||
LocalDateTime absenceStartDate, LocalDateTime absenceEndDate);
|
||||
|
||||
BigDecimal calculateTotalAbsenceMinutes(LocalDateTime absenceStartDate, LocalDateTime absenceEndDate);
|
||||
BigDecimal calculateTotalAbsenceMinutes(
|
||||
LocalDateTime absenceStartDate, LocalDateTime absenceEndDate);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
package com.axelor.apps.hr.service;
|
||||
|
||||
import com.axelor.apps.base.db.EventsPlanning;
|
||||
import com.axelor.apps.base.db.EventsPlanningLine;
|
||||
import com.axelor.apps.base.db.repo.EventsPlanningRepository;
|
||||
import com.axelor.apps.base.db.repo.EventsPlanningLineRepository;
|
||||
import com.axelor.apps.hr.db.Absence;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.repo.AbsenceRepository;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import com.axelor.inject.Beans;
|
||||
import java.util.List;
|
||||
import java.time.Year;
|
||||
import java.time.DayOfWeek;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.Duration;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
public class AbsenceServiceImpl implements AbsenceService {
|
||||
|
||||
@@ -28,19 +25,16 @@ public class AbsenceServiceImpl implements AbsenceService {
|
||||
private List<EventsPlanningLine> eventsPlanningLines;
|
||||
|
||||
@Inject
|
||||
public AbsenceServiceImpl( AbsenceRepository absenceRepository, DailyReportRepository dailyReportRepository) {
|
||||
public AbsenceServiceImpl(
|
||||
AbsenceRepository absenceRepository, DailyReportRepository dailyReportRepository) {
|
||||
this.absenceRepository = absenceRepository;
|
||||
this.dailyReportRepository = dailyReportRepository;
|
||||
eventsPlanningLines =
|
||||
Beans.get(EventsPlanningLineRepository.class)
|
||||
.all()
|
||||
.filter("self.id = 4")
|
||||
.fetch();
|
||||
Beans.get(EventsPlanningLineRepository.class).all().filter("self.id = 4").fetch();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void attachTheAbsenceWithDailyReport(
|
||||
Absence absence, List<DailyReport> dailyreports) {
|
||||
public void attachTheAbsenceWithDailyReport(Absence absence, List<DailyReport> dailyreports) {
|
||||
// Iterate over each DailyReport in the list
|
||||
for (DailyReport dailyreport : dailyreports) {
|
||||
dailyreport.addAbsenceSetItem(absence); // Set the absence for each report
|
||||
@@ -49,8 +43,9 @@ public class AbsenceServiceImpl implements AbsenceService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deAttachTheAbsenceWithDailyReport(Absence absence, List<DailyReport> dailyreports, Boolean archive) {
|
||||
if(dailyreports != null){
|
||||
public void deAttachTheAbsenceWithDailyReport(
|
||||
Absence absence, List<DailyReport> dailyreports, Boolean archive) {
|
||||
if (dailyreports != null) {
|
||||
// Iterate over each DailyReport in the list
|
||||
for (DailyReport dailyreport : dailyreports) {
|
||||
dailyreport.removeAbsenceSetItem(null); // Set the absence for each report
|
||||
@@ -59,8 +54,8 @@ public class AbsenceServiceImpl implements AbsenceService {
|
||||
}
|
||||
|
||||
if (archive) {
|
||||
absence.setArchived(true);
|
||||
absenceRepository.save(absence);
|
||||
absence.setArchived(true);
|
||||
absenceRepository.save(absence);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,46 +69,50 @@ public class AbsenceServiceImpl implements AbsenceService {
|
||||
absenceRepository.save(absence);
|
||||
}
|
||||
|
||||
public BigDecimal calculateTotalAbsenceHours(LocalDateTime absenceStartDate, LocalDateTime absenceEndDate) {
|
||||
BigDecimal totalAbsenceHours = BigDecimal.ZERO;
|
||||
public BigDecimal calculateTotalAbsenceHours(
|
||||
LocalDateTime absenceStartDate, LocalDateTime absenceEndDate) {
|
||||
BigDecimal totalAbsenceHours = BigDecimal.ZERO;
|
||||
|
||||
if(absenceStartDate.equals(absenceEndDate)){
|
||||
totalAbsenceHours = BigDecimal.valueOf(8);
|
||||
}
|
||||
else if (absenceStartDate.toLocalDate().equals(absenceEndDate.toLocalDate())) {
|
||||
// If the start and end dates are the same, calculate the hour difference
|
||||
long hours = ChronoUnit.HOURS.between(absenceStartDate, absenceEndDate);
|
||||
totalAbsenceHours = BigDecimal.valueOf(hours);
|
||||
} else {
|
||||
long absenceDays = 0;
|
||||
LocalDate currentDate = absenceStartDate.toLocalDate();
|
||||
if (absenceStartDate.equals(absenceEndDate)) {
|
||||
totalAbsenceHours = BigDecimal.valueOf(8);
|
||||
} else if (absenceStartDate.toLocalDate().equals(absenceEndDate.toLocalDate())) {
|
||||
// If the start and end dates are the same, calculate the hour difference
|
||||
long hours = ChronoUnit.HOURS.between(absenceStartDate, absenceEndDate);
|
||||
totalAbsenceHours = BigDecimal.valueOf(hours);
|
||||
} else {
|
||||
long absenceDays = 0;
|
||||
LocalDate currentDate = absenceStartDate.toLocalDate();
|
||||
|
||||
// Loop through each day between start and end date
|
||||
while (!currentDate.isAfter(absenceEndDate.toLocalDate())) {
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
// Loop through each day between start and end date
|
||||
while (!currentDate.isAfter(absenceEndDate.toLocalDate())) {
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
|
||||
// Exclude Friday (5) and Saturday (6) and holidays
|
||||
if (dayOfWeek != DayOfWeek.FRIDAY && dayOfWeek != DayOfWeek.SATURDAY && !isSpecialOvertimeDay(currentDate)) {
|
||||
absenceDays++;
|
||||
}
|
||||
currentDate = currentDate.plusDays(1);
|
||||
// Exclude Friday (5) and Saturday (6) and holidays
|
||||
if (dayOfWeek != DayOfWeek.FRIDAY
|
||||
&& dayOfWeek != DayOfWeek.SATURDAY
|
||||
&& !isSpecialOvertimeDay(currentDate)) {
|
||||
absenceDays++;
|
||||
}
|
||||
|
||||
// Multiply the counted days by 8 hours per day
|
||||
totalAbsenceHours = BigDecimal.valueOf(absenceDays).multiply(BigDecimal.valueOf(8));
|
||||
currentDate = currentDate.plusDays(1);
|
||||
}
|
||||
return totalAbsenceHours;
|
||||
|
||||
// Multiply the counted days by 8 hours per day
|
||||
totalAbsenceHours = BigDecimal.valueOf(absenceDays).multiply(BigDecimal.valueOf(8));
|
||||
}
|
||||
return totalAbsenceHours;
|
||||
}
|
||||
|
||||
public BigDecimal calculateTotalAbsenceMinutes(LocalDateTime absenceStartDate, LocalDateTime absenceEndDate) {
|
||||
// Calculate the duration between the two LocalDateTime objects
|
||||
Duration duration = Duration.between(absenceStartDate, absenceEndDate);
|
||||
public BigDecimal calculateTotalAbsenceMinutes(
|
||||
LocalDateTime absenceStartDate, LocalDateTime absenceEndDate) {
|
||||
// Calculate the duration between the two LocalDateTime objects
|
||||
Duration duration = Duration.between(absenceStartDate, absenceEndDate);
|
||||
|
||||
// Convert the duration to minutes and then divide by 60 to get hours
|
||||
long minutes = duration.toMinutes();
|
||||
BigDecimal hours = BigDecimal.valueOf(minutes).divide(BigDecimal.valueOf(60), 2, BigDecimal.ROUND_HALF_UP);
|
||||
// Convert the duration to minutes and then divide by 60 to get hours
|
||||
long minutes = duration.toMinutes();
|
||||
BigDecimal hours =
|
||||
BigDecimal.valueOf(minutes).divide(BigDecimal.valueOf(60), 2, BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
return customRound(hours);
|
||||
return customRound(hours);
|
||||
}
|
||||
|
||||
private boolean isSpecialOvertimeDay(LocalDate date) {
|
||||
@@ -147,5 +146,4 @@ public class AbsenceServiceImpl implements AbsenceService {
|
||||
return value; // In case no rounding is needed
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,23 +2,22 @@ package com.axelor.apps.hr.service;
|
||||
|
||||
import com.axelor.apps.base.db.EventsPlanning;
|
||||
import com.axelor.apps.base.db.EventsPlanningLine;
|
||||
import com.axelor.apps.base.db.repo.EventsPlanningRepository;
|
||||
import com.axelor.apps.base.db.repo.EventsPlanningLineRepository;
|
||||
import com.axelor.apps.hr.db.Absence;
|
||||
import com.axelor.apps.hr.db.Authorization;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.OffDayWork;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.Shift;
|
||||
import com.axelor.apps.hr.db.Authorization;
|
||||
import com.axelor.apps.hr.db.repo.AbsenceRepository;
|
||||
import com.axelor.apps.hr.db.repo.AuthorizationRepository;
|
||||
import com.axelor.apps.hr.db.repo.OffDayWorkRepository;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.db.repo.OffDayWorkRepository;
|
||||
import com.axelor.apps.hr.db.repo.ShiftRepository;
|
||||
import com.axelor.apps.hr.service.AbsenceServiceImpl;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.inject.persist.Transactional;
|
||||
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.math.RoundingMode;
|
||||
import java.time.DayOfWeek;
|
||||
@@ -26,10 +25,8 @@ import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.Year;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
public class DailyReportServiceImpl implements DailyReportService {
|
||||
|
||||
@@ -52,23 +49,35 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
private LocalTime SHIFT_6h14_max;
|
||||
|
||||
@Inject
|
||||
public DailyReportServiceImpl(DailyReportRepository dailyReportRepository, AuthorizationRepository autorizationRepository, AbsenceRepository absenceRepository) {
|
||||
public DailyReportServiceImpl(
|
||||
DailyReportRepository dailyReportRepository,
|
||||
AuthorizationRepository autorizationRepository,
|
||||
AbsenceRepository absenceRepository) {
|
||||
this.dailyReportRepository = dailyReportRepository;
|
||||
this.autorizationRepository = autorizationRepository;
|
||||
this.absenceRepository = absenceRepository;
|
||||
eventsPlanningLines = Beans.get(EventsPlanningLineRepository.class)
|
||||
.all()
|
||||
.filter("self.eventsPlanning = 4")
|
||||
.fetch();
|
||||
eventsPlanningLines =
|
||||
Beans.get(EventsPlanningLineRepository.class)
|
||||
.all()
|
||||
.filter("self.eventsPlanning = 4")
|
||||
.fetch();
|
||||
|
||||
SHIFT_8h16_min = Beans.get(ShiftRepository.class).all().filter("self.shift = 0").fetchOne().getEnterMin();
|
||||
SHIFT_8h16_max = Beans.get(ShiftRepository.class).all().filter("self.shift = 0").fetchOne().getEnterMax();
|
||||
SHIFT_14h22_min = Beans.get(ShiftRepository.class).all().filter("self.shift = 1").fetchOne().getEnterMin();
|
||||
SHIFT_14h22_max = Beans.get(ShiftRepository.class).all().filter("self.shift = 1").fetchOne().getEnterMax();
|
||||
SHIFT_22h6_min = Beans.get(ShiftRepository.class).all().filter("self.shift = 2").fetchOne().getEnterMin();
|
||||
SHIFT_22h6_max = Beans.get(ShiftRepository.class).all().filter("self.shift = 2").fetchOne().getEnterMax();
|
||||
SHIFT_6h14_min = Beans.get(ShiftRepository.class).all().filter("self.shift = 3").fetchOne().getEnterMin();
|
||||
SHIFT_6h14_max = Beans.get(ShiftRepository.class).all().filter("self.shift = 3").fetchOne().getEnterMax();
|
||||
SHIFT_8h16_min =
|
||||
Beans.get(ShiftRepository.class).all().filter("self.shift = 0").fetchOne().getEnterMin();
|
||||
SHIFT_8h16_max =
|
||||
Beans.get(ShiftRepository.class).all().filter("self.shift = 0").fetchOne().getEnterMax();
|
||||
SHIFT_14h22_min =
|
||||
Beans.get(ShiftRepository.class).all().filter("self.shift = 1").fetchOne().getEnterMin();
|
||||
SHIFT_14h22_max =
|
||||
Beans.get(ShiftRepository.class).all().filter("self.shift = 1").fetchOne().getEnterMax();
|
||||
SHIFT_22h6_min =
|
||||
Beans.get(ShiftRepository.class).all().filter("self.shift = 2").fetchOne().getEnterMin();
|
||||
SHIFT_22h6_max =
|
||||
Beans.get(ShiftRepository.class).all().filter("self.shift = 2").fetchOne().getEnterMax();
|
||||
SHIFT_6h14_min =
|
||||
Beans.get(ShiftRepository.class).all().filter("self.shift = 3").fetchOne().getEnterMin();
|
||||
SHIFT_6h14_max =
|
||||
Beans.get(ShiftRepository.class).all().filter("self.shift = 3").fetchOne().getEnterMax();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,14 +99,17 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
|
||||
LocalDateTime firstEnter, lastQuit;
|
||||
|
||||
LocalTime shiftStartHour = null, shiftEndHour = null, shiftStartPauseHour = null, shiftEndPauseHour = null;
|
||||
if(shift != null){
|
||||
LocalTime shiftStartHour = null,
|
||||
shiftEndHour = null,
|
||||
shiftStartPauseHour = null,
|
||||
shiftEndPauseHour = null;
|
||||
if (shift != null) {
|
||||
shiftStartHour = dailyReport.getShift().getStartHour();
|
||||
shiftEndHour = dailyReport.getShift().getEndHour();
|
||||
shiftStartPauseHour = dailyReport.getShift().getStartPause();
|
||||
shiftEndPauseHour = dailyReport.getShift().getEndPause();
|
||||
}
|
||||
|
||||
|
||||
if (enters[0] != null && quits[0] != null) {
|
||||
// Calculate total work duration
|
||||
Duration totalDuration = Duration.ZERO;
|
||||
@@ -117,45 +129,54 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
dailyReport.setLastQuit(lastQuit);
|
||||
LocalTime firstEnterTime = firstEnter.toLocalTime();
|
||||
LocalTime lastQuitTime = lastQuit.toLocalTime();
|
||||
|
||||
|
||||
// Calculate late arrival if firstEnter is later than shift start
|
||||
if(shiftStartHour != null){
|
||||
if (shiftStartHour != null) {
|
||||
if (firstEnterTime.isAfter(shiftStartHour)) {
|
||||
long minutesLate = Duration.between(shiftStartHour, firstEnterTime).toMinutes();
|
||||
BigDecimal lateArrival = BigDecimal.valueOf(minutesLate).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal lateArrival =
|
||||
BigDecimal.valueOf(minutesLate)
|
||||
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setLateArrival(lateArrival);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Calculate early departure if lastQuit is earlier than shift end
|
||||
if(shiftEndHour != null){
|
||||
if (shiftEndHour != null) {
|
||||
if (lastQuitTime.isBefore(shiftEndHour)) {
|
||||
long minutesEarly = Duration.between(lastQuitTime, shiftEndHour).toMinutes();
|
||||
BigDecimal earlyDeparture = BigDecimal.valueOf(minutesEarly).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal earlyDeparture =
|
||||
BigDecimal.valueOf(minutesEarly)
|
||||
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setEarlyDeparture(earlyDeparture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Total hours
|
||||
totalDuration = totalDuration.plus(Duration.between(firstEnter, lastQuit));
|
||||
long totalMinutes = totalDuration.toMinutes();
|
||||
BigDecimal totalHours = BigDecimal.valueOf(totalMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal totalHours =
|
||||
BigDecimal.valueOf(totalMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setWorkHours(totalHours);
|
||||
|
||||
// Calculate night hours
|
||||
nightDuration = calculateNightDuration(firstEnter, lastQuit);
|
||||
long totalNightMinutes = nightDuration.toMinutes();
|
||||
BigDecimal totalNightHours = BigDecimal.valueOf(totalNightMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal totalNightHours =
|
||||
BigDecimal.valueOf(totalNightMinutes)
|
||||
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setNightHours(totalNightHours);
|
||||
|
||||
// Break Hours
|
||||
breakDuration = calculateBreakDuration(enters, quits);
|
||||
long breakMinutes = breakDuration.toMinutes();
|
||||
BigDecimal breakHours = BigDecimal.valueOf(breakMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal breakHours =
|
||||
BigDecimal.valueOf(breakMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setBreakHours(breakHours);
|
||||
|
||||
if(shiftStartPauseHour != null && shiftEndPauseHour != null){
|
||||
boolean allInAllowedRange = areBreaksInAllowedRange(enters, quits, shiftStartPauseHour, shiftEndPauseHour);
|
||||
if (shiftStartPauseHour != null && shiftEndPauseHour != null) {
|
||||
boolean allInAllowedRange =
|
||||
areBreaksInAllowedRange(enters, quits, shiftStartPauseHour, shiftEndPauseHour);
|
||||
dailyReport.setBreakNotInTheAllowedRange(allInAllowedRange);
|
||||
}
|
||||
|
||||
@@ -172,14 +193,19 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
// Calculate time from first enter to midnight
|
||||
Duration beforeMidnightDuration = Duration.between(firstEnter, midnight);
|
||||
long beforeMidnightMinutes = beforeMidnightDuration.toMinutes();
|
||||
BigDecimal beforeMidnightHours = BigDecimal.valueOf(beforeMidnightMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal beforeMidnightHours =
|
||||
BigDecimal.valueOf(beforeMidnightMinutes)
|
||||
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
|
||||
// Calculate time from midnight to last quit
|
||||
Duration afterMidnightDuration = Duration.between(midnight, lastQuit);
|
||||
long afterMidnightMinutes = afterMidnightDuration.toMinutes();
|
||||
BigDecimal afterMidnightHours = BigDecimal.valueOf(afterMidnightMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal afterMidnightHours =
|
||||
BigDecimal.valueOf(afterMidnightMinutes)
|
||||
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
|
||||
if (enterDay == DayOfWeek.THURSDAY && quitDay == DayOfWeek.FRIDAY || isSpecialOvertimeDay(lastQuit)) {
|
||||
if (enterDay == DayOfWeek.THURSDAY && quitDay == DayOfWeek.FRIDAY
|
||||
|| isSpecialOvertimeDay(lastQuit)) {
|
||||
extraHours100 = afterMidnightHours;
|
||||
dailyReport.setAllowance(totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
if (enterDay == DayOfWeek.THURSDAY && quitDay == DayOfWeek.FRIDAY)
|
||||
@@ -205,9 +231,11 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
extraHours50 = beforeMidnightHours;
|
||||
dailyReport.setAllowanceRecall(totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
} else {
|
||||
totalSupDuration = calculateSupplementaryHours(firstEnter,lastQuit,shift,reportDate);
|
||||
totalSupDuration = calculateSupplementaryHours(firstEnter, lastQuit, shift, reportDate);
|
||||
long totalSupMinutes = totalSupDuration.toMinutes();
|
||||
extraHours50 = BigDecimal.valueOf(totalSupMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
extraHours50 =
|
||||
BigDecimal.valueOf(totalSupMinutes)
|
||||
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setAllowance(totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -219,21 +247,26 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
// Calculate supplementary hours
|
||||
totalSupDuration = calculateSupplementaryHours(firstEnter, lastQuit, shift, reportDate);
|
||||
long totalSupMinutes = totalSupDuration.toMinutes();
|
||||
BigDecimal totalSupHours = BigDecimal.valueOf(totalSupMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal totalSupHours =
|
||||
BigDecimal.valueOf(totalSupMinutes)
|
||||
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
|
||||
// Holidays and weekends
|
||||
if (firstEnter.getDayOfWeek() == DayOfWeek.SATURDAY) {
|
||||
|
||||
if(shift == 0 || shift == 3){
|
||||
|
||||
if (shift == 0 || shift == 3) {
|
||||
dailyReport.setExtraHours50(totalHours.subtract(totalNightHours));
|
||||
dailyReport.setExtraHours100(totalNightHours);
|
||||
dailyReport.setAllowanceRecall(totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
dailyReport.setAllowanceRecall(
|
||||
totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
} else {
|
||||
dailyReport.setExtraHours50(totalHours);
|
||||
dailyReport.setAllowanceRecall(totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
dailyReport.setAllowanceRecall(
|
||||
totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
} else if (firstEnter.getDayOfWeek() == DayOfWeek.FRIDAY || isSpecialOvertimeDay(firstEnter)) {
|
||||
} else if (firstEnter.getDayOfWeek() == DayOfWeek.FRIDAY
|
||||
|| isSpecialOvertimeDay(firstEnter)) {
|
||||
|
||||
// Add recup
|
||||
if (totalHours.compareTo(BigDecimal.valueOf(6)) >= 0)
|
||||
@@ -243,26 +276,28 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
|
||||
} else {
|
||||
|
||||
if(shift == 0 || shift == 3){
|
||||
if (shift == 0 || shift == 3) {
|
||||
dailyReport.setExtraHours50(totalSupHours.subtract(totalNightHours));
|
||||
dailyReport.setExtraHours100(totalNightHours);
|
||||
dailyReport.setAllowance(totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
dailyReport.setAllowanceRecall(totalSupHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
dailyReport.setAllowanceRecall(
|
||||
totalSupHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
} else {
|
||||
dailyReport.setExtraHours50(totalSupHours);
|
||||
dailyReport.setAllowance(totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
dailyReport.setAllowanceRecall(totalSupHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
}
|
||||
dailyReport.setAllowanceRecall(
|
||||
totalSupHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate ITP
|
||||
dailyReport.setItp(calculateItp(totalHours, shift,dailyReport.getHasItp()));
|
||||
dailyReport.setItp(calculateItp(totalHours, shift, dailyReport.getHasItp()));
|
||||
dailyReport.setIsCalculated(true);
|
||||
|
||||
} else if (enters[0] != null && quits[0] == null) {
|
||||
// When the employee registers attendance only once
|
||||
if(shift!=2){
|
||||
if (shift != 2) {
|
||||
dailyReport.setWorkHours(BigDecimal.valueOf(8));
|
||||
dailyReport.setAbsenceHours(BigDecimal.valueOf(0));
|
||||
dailyReport.setIsCalculated(true);
|
||||
@@ -274,7 +309,8 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
lastQuit = quits[quits.length - 1];
|
||||
totalDuration = totalDuration.plus(Duration.between(firstEnter, lastQuit));
|
||||
long totalMinutes = totalDuration.toMinutes();
|
||||
BigDecimal totalHours = BigDecimal.valueOf(totalMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
BigDecimal totalHours =
|
||||
BigDecimal.valueOf(totalMinutes).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setWorkHours(totalHours);
|
||||
dailyReport.setAllowance(totalHours.compareTo(BigDecimal.valueOf(5)) >= 0 ? 1 : 0);
|
||||
|
||||
@@ -283,16 +319,19 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
LocalTime lastQuitTime = lastQuit.toLocalTime();
|
||||
// Calculate late arrival if firstEnter is later than shift start
|
||||
if (firstEnterTime.isAfter(shiftStartHour)) {
|
||||
long minutesLate = Duration.between(shiftStartHour, firstEnterTime).toMinutes();
|
||||
BigDecimal lateArrival = BigDecimal.valueOf(minutesLate).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setLateArrival(lateArrival);
|
||||
long minutesLate = Duration.between(shiftStartHour, firstEnterTime).toMinutes();
|
||||
BigDecimal lateArrival =
|
||||
BigDecimal.valueOf(minutesLate).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setLateArrival(lateArrival);
|
||||
}
|
||||
|
||||
|
||||
// Calculate early departure if lastQuit is earlier than shift end
|
||||
if (lastQuitTime.isBefore(shiftEndHour)) {
|
||||
long minutesEarly = Duration.between(lastQuitTime, shiftEndHour).toMinutes();
|
||||
BigDecimal earlyDeparture = BigDecimal.valueOf(minutesEarly).divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setEarlyDeparture(earlyDeparture);
|
||||
long minutesEarly = Duration.between(lastQuitTime, shiftEndHour).toMinutes();
|
||||
BigDecimal earlyDeparture =
|
||||
BigDecimal.valueOf(minutesEarly)
|
||||
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
|
||||
dailyReport.setEarlyDeparture(earlyDeparture);
|
||||
}
|
||||
|
||||
} else if (employee == null) {
|
||||
@@ -317,11 +356,15 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
|
||||
// Absences
|
||||
if (dailyReport.getAbsence() == null) {
|
||||
Absence absence = Beans.get(AbsenceRepository.class)
|
||||
Absence absence =
|
||||
Beans.get(AbsenceRepository.class)
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.startDate <= :reportDate and self.endDate >= :reportDate and (self.archived = false or self.archived is null)")
|
||||
.filter(
|
||||
"self.employee = :employee and self.startDate <= :reportDate and self.endDate >= :reportDate and (self.archived = false or self.archived is null)")
|
||||
.bind("employee", employee)
|
||||
.bind("reportDate",reportDate) // Changed from absenceStartDate and absenceEndDate to reportDate
|
||||
.bind(
|
||||
"reportDate",
|
||||
reportDate) // Changed from absenceStartDate and absenceEndDate to reportDate
|
||||
.fetchOne();
|
||||
|
||||
if (absence != null) {
|
||||
@@ -331,33 +374,35 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
|
||||
// Authorization
|
||||
if (dailyReport.getAuthorizationList() == null) {
|
||||
List<Authorization> authorizations = Beans.get(AuthorizationRepository.class)
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.requisitionDate = :reportDate")
|
||||
.bind("employee", employee)
|
||||
.bind("reportDate", reportDate)
|
||||
.fetch();
|
||||
List<Authorization> authorizations =
|
||||
Beans.get(AuthorizationRepository.class)
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.requisitionDate = :reportDate")
|
||||
.bind("employee", employee)
|
||||
.bind("reportDate", reportDate)
|
||||
.fetch();
|
||||
|
||||
if (authorizations != null) {
|
||||
List<Authorization> authorizationList = new ArrayList<>(); // Create a new list for authorizations
|
||||
List<Authorization> authorizationList =
|
||||
new ArrayList<>(); // Create a new list for authorizations
|
||||
|
||||
for (Authorization authorization : authorizations) {
|
||||
authorization.setDailyReport(dailyReport);
|
||||
authorizationList.add(authorization); // Add each authorization to the list
|
||||
for (Authorization authorization : authorizations) {
|
||||
authorization.setDailyReport(dailyReport);
|
||||
authorizationList.add(authorization); // Add each authorization to the list
|
||||
|
||||
// Check authorization type and set corresponding flags in dailyReport
|
||||
if (authorization.getAuthorizationType() == 0 && authorization.getStatusSelect() == 3) {
|
||||
dailyReport.setIsAuthorizedEarlyDeparture(true);
|
||||
}
|
||||
if (authorization.getAuthorizationType() == 1 && authorization.getStatusSelect() == 3) {
|
||||
dailyReport.setIsAuthorizedLateArrival(true);
|
||||
}
|
||||
if (authorization.getAuthorizationType() == 2 && authorization.getStatusSelect() == 3) {
|
||||
dailyReport.setIsAuthorizedAbsence(true);
|
||||
}
|
||||
// Check authorization type and set corresponding flags in dailyReport
|
||||
if (authorization.getAuthorizationType() == 0 && authorization.getStatusSelect() == 3) {
|
||||
dailyReport.setIsAuthorizedEarlyDeparture(true);
|
||||
}
|
||||
// Set the authorization list to dailyReport
|
||||
dailyReport.setAuthorizationList(authorizationList);
|
||||
if (authorization.getAuthorizationType() == 1 && authorization.getStatusSelect() == 3) {
|
||||
dailyReport.setIsAuthorizedLateArrival(true);
|
||||
}
|
||||
if (authorization.getAuthorizationType() == 2 && authorization.getStatusSelect() == 3) {
|
||||
dailyReport.setIsAuthorizedAbsence(true);
|
||||
}
|
||||
}
|
||||
// Set the authorization list to dailyReport
|
||||
dailyReport.setAuthorizationList(authorizationList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,54 +412,68 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
}
|
||||
|
||||
// Weekends
|
||||
if (reportDate.getDayOfWeek() == DayOfWeek.FRIDAY || reportDate.getDayOfWeek() == DayOfWeek.SATURDAY) {
|
||||
if (reportDate.getDayOfWeek() == DayOfWeek.FRIDAY
|
||||
|| reportDate.getDayOfWeek() == DayOfWeek.SATURDAY) {
|
||||
dailyReport.setIsWeekend(true);
|
||||
}
|
||||
|
||||
// Absence Hours
|
||||
if (!(dailyReport.getIsWeekend() || dailyReport.getIsFerieDay()) && dailyReport.getWorkHours().compareTo(BigDecimal.valueOf(8)) < 0) {
|
||||
if (!(dailyReport.getIsWeekend() || dailyReport.getIsFerieDay())
|
||||
&& dailyReport.getWorkHours().compareTo(BigDecimal.valueOf(8)) < 0) {
|
||||
dailyReport.setAbsenceHours(BigDecimal.valueOf(8).subtract(dailyReport.getWorkHours()));
|
||||
// Create Absence AI
|
||||
if(dailyReport.getAbsenceSet().isEmpty()){
|
||||
if (dailyReport.getAbsenceSet().isEmpty()) {
|
||||
Boolean isAuthorizedAbsence = dailyReport.getIsAuthorizedAbsence();
|
||||
Boolean isAuthorizedLateArrival = dailyReport.getIsAuthorizedLateArrival();
|
||||
Boolean isAuthorizedEarlyDeparture = dailyReport.getIsAuthorizedEarlyDeparture();
|
||||
// AI all day
|
||||
if(dailyReport.getAbsenceHours().compareTo(new BigDecimal("8")) == 0){
|
||||
if(!isAuthorizedAbsence){
|
||||
if (dailyReport.getAbsenceHours().compareTo(new BigDecimal("8")) == 0) {
|
||||
if (!isAuthorizedAbsence) {
|
||||
Absence absence = new Absence();
|
||||
absence.setEmployee(employee);
|
||||
absence.setAbsenceType(19); // Absence irrégulière
|
||||
absence.setStartDate(reportDate.atStartOfDay());
|
||||
absence.setEndDate(reportDate.atStartOfDay());
|
||||
BigDecimal totalAbsenceHours = Beans.get(AbsenceServiceImpl.class).calculateTotalAbsenceHours(reportDate.atStartOfDay(),reportDate.atStartOfDay());
|
||||
BigDecimal totalAbsenceHours =
|
||||
Beans.get(AbsenceServiceImpl.class)
|
||||
.calculateTotalAbsenceHours(
|
||||
reportDate.atStartOfDay(), reportDate.atStartOfDay());
|
||||
absence.setTotalAbsenceHours(totalAbsenceHours);
|
||||
absenceRepository.save(absence);
|
||||
dailyReport.addAbsenceSetItem(absence);
|
||||
}
|
||||
}else{
|
||||
if(dailyReport.getShift().getMaxTimeLateArrival() != null){ // to check that is different to shift N/A
|
||||
} else {
|
||||
if (dailyReport.getShift().getMaxTimeLateArrival()
|
||||
!= null) { // to check that is different to shift N/A
|
||||
LocalTime firstEnterTime = dailyReport.getEnter1().toLocalTime();
|
||||
if(firstEnterTime.isAfter(dailyReport.getShift().getMaxTimeLateArrival()) && !isAuthorizedLateArrival){
|
||||
if (firstEnterTime.isAfter(dailyReport.getShift().getMaxTimeLateArrival())
|
||||
&& !isAuthorizedLateArrival) {
|
||||
Absence absence = new Absence();
|
||||
absence.setEmployee(employee);
|
||||
absence.setAbsenceType(20); // Retard irrégulier
|
||||
absence.setStartDate(reportDate.atTime(shiftStartHour));
|
||||
absence.setEndDate(dailyReport.getEnter1());
|
||||
BigDecimal totalAbsenceHours = Beans.get(AbsenceServiceImpl.class).calculateTotalAbsenceMinutes(reportDate.atTime(shiftStartHour),dailyReport.getEnter1());
|
||||
BigDecimal totalAbsenceHours =
|
||||
Beans.get(AbsenceServiceImpl.class)
|
||||
.calculateTotalAbsenceMinutes(
|
||||
reportDate.atTime(shiftStartHour), dailyReport.getEnter1());
|
||||
absence.setTotalAbsenceHours(totalAbsenceHours);
|
||||
absenceRepository.save(absence);
|
||||
dailyReport.addAbsenceSetItem(absence);
|
||||
}
|
||||
if(dailyReport.getLastQuit() != null){
|
||||
if (dailyReport.getLastQuit() != null) {
|
||||
LocalTime lastQuitTime = dailyReport.getLastQuit().toLocalTime();
|
||||
if(lastQuitTime.isBefore(dailyReport.getShift().getMaxTimeEarlyDeparture()) && !isAuthorizedEarlyDeparture){
|
||||
if (lastQuitTime.isBefore(dailyReport.getShift().getMaxTimeEarlyDeparture())
|
||||
&& !isAuthorizedEarlyDeparture) {
|
||||
Absence absence = new Absence();
|
||||
absence.setEmployee(employee);
|
||||
absence.setAbsenceType(21); // Départ irrégulier
|
||||
absence.setStartDate(dailyReport.getLastQuit());
|
||||
absence.setEndDate(reportDate.atTime(shiftEndHour));
|
||||
BigDecimal totalAbsenceHours = Beans.get(AbsenceServiceImpl.class).calculateTotalAbsenceMinutes(dailyReport.getLastQuit(),reportDate.atTime(shiftEndHour));
|
||||
BigDecimal totalAbsenceHours =
|
||||
Beans.get(AbsenceServiceImpl.class)
|
||||
.calculateTotalAbsenceMinutes(
|
||||
dailyReport.getLastQuit(), reportDate.atTime(shiftEndHour));
|
||||
absence.setTotalAbsenceHours(totalAbsenceHours);
|
||||
absenceRepository.save(absence);
|
||||
dailyReport.addAbsenceSetItem(absence);
|
||||
@@ -431,24 +490,24 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void determineShift(DailyReport dailyReport){
|
||||
public void determineShift(DailyReport dailyReport) {
|
||||
LocalDateTime enters1 = dailyReport.getEnter1();
|
||||
if(enters1 != null){
|
||||
if (enters1 != null) {
|
||||
// Extract time from enters1
|
||||
LocalTime firstTime = enters1.toLocalTime();
|
||||
|
||||
|
||||
// Define shifts
|
||||
Shift shift;
|
||||
if (firstTime.isAfter(SHIFT_6h14_min) && firstTime.isBefore(SHIFT_6h14_max)) {
|
||||
shift = Beans.get(ShiftRepository.class).find(3L); // Shift 6h14
|
||||
shift = Beans.get(ShiftRepository.class).find(3L); // Shift 6h14
|
||||
} else if (firstTime.isAfter(SHIFT_8h16_min) && firstTime.isBefore(SHIFT_8h16_max)) {
|
||||
shift = Beans.get(ShiftRepository.class).find(4L); // Shift 8h16
|
||||
shift = Beans.get(ShiftRepository.class).find(4L); // Shift 8h16
|
||||
} else if (firstTime.isAfter(SHIFT_14h22_min) && firstTime.isBefore(SHIFT_14h22_max)) {
|
||||
shift = Beans.get(ShiftRepository.class).find(1L); // Shift 14h22
|
||||
shift = Beans.get(ShiftRepository.class).find(1L); // Shift 14h22
|
||||
} else if (firstTime.isAfter(SHIFT_22h6_min) || firstTime.isBefore(SHIFT_22h6_max)) {
|
||||
shift = Beans.get(ShiftRepository.class).find(2L); // Shift 22h6
|
||||
shift = Beans.get(ShiftRepository.class).find(2L); // Shift 22h6
|
||||
} else {
|
||||
shift = Beans.get(ShiftRepository.class).find(50L); // N/A
|
||||
shift = Beans.get(ShiftRepository.class).find(50L); // N/A
|
||||
}
|
||||
dailyReport.setShift(shift);
|
||||
dailyReportRepository.save(dailyReport);
|
||||
@@ -499,7 +558,8 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
return nightDuration1;
|
||||
}
|
||||
|
||||
private Duration calculateSupplementaryHours(LocalDateTime enter, LocalDateTime quit, int shift, LocalDate reportDate) {
|
||||
private Duration calculateSupplementaryHours(
|
||||
LocalDateTime enter, LocalDateTime quit, int shift, LocalDate reportDate) {
|
||||
|
||||
// Calculate Supp hours for (0,1,2,3) shifts
|
||||
Shift shiftInstance =
|
||||
@@ -549,18 +609,22 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
return breakDuration;
|
||||
}
|
||||
|
||||
private boolean areBreaksInAllowedRange(LocalDateTime[] enters, LocalDateTime[] quits, LocalTime allowedStartTime, LocalTime allowedEndTime) {
|
||||
private boolean areBreaksInAllowedRange(
|
||||
LocalDateTime[] enters,
|
||||
LocalDateTime[] quits,
|
||||
LocalTime allowedStartTime,
|
||||
LocalTime allowedEndTime) {
|
||||
|
||||
for (int i = 1; i < quits.length; i++) {
|
||||
if (enters[i] != null && quits[i - 1] != null) {
|
||||
LocalTime breakStartTime = quits[i - 1].toLocalTime();
|
||||
LocalTime breakEndTime = enters[i].toLocalTime();
|
||||
if (enters[i] != null && quits[i - 1] != null) {
|
||||
LocalTime breakStartTime = quits[i - 1].toLocalTime();
|
||||
LocalTime breakEndTime = enters[i].toLocalTime();
|
||||
|
||||
// Check if the break falls outside the allowed range
|
||||
if (breakStartTime.isBefore(allowedStartTime) || breakEndTime.isAfter(allowedEndTime)) {
|
||||
return false;
|
||||
}
|
||||
// Check if the break falls outside the allowed range
|
||||
if (breakStartTime.isBefore(allowedStartTime) || breakEndTime.isAfter(allowedEndTime)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -568,11 +632,9 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
|
||||
private BigDecimal calculateItp(BigDecimal totalHours, Integer shift, Boolean hasItp) {
|
||||
// Shift 0 (no itp)
|
||||
if (hasItp == true && shift != 0)
|
||||
return totalHours.min(BigDecimal.valueOf(8));
|
||||
else
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
if (hasItp == true && shift != 0) return totalHours.min(BigDecimal.valueOf(8));
|
||||
else return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
private void createOffDayWork(LocalDate reportDate, Employee employee) {
|
||||
|
||||
@@ -651,35 +713,38 @@ public class DailyReportServiceImpl implements DailyReportService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void deducePrimes(DailyReport dailyReport, Integer primeSelection, BigDecimal valueToDeduce) throws AxelorException {
|
||||
public void deducePrimes(
|
||||
DailyReport dailyReport, Integer primeSelection, BigDecimal valueToDeduce)
|
||||
throws AxelorException {
|
||||
switch (primeSelection) {
|
||||
case 1: // ITP
|
||||
dailyReport.setDeduceItp(true);
|
||||
dailyReport.setItpToDeduce(valueToDeduce);
|
||||
break;
|
||||
dailyReport.setDeduceItp(true);
|
||||
dailyReport.setItpToDeduce(valueToDeduce);
|
||||
break;
|
||||
case 2: // Nuissance
|
||||
dailyReport.setDeduceNuissance(true);
|
||||
dailyReport.setItpToDeduce(valueToDeduce);
|
||||
break;
|
||||
dailyReport.setDeduceNuissance(true);
|
||||
dailyReport.setItpToDeduce(valueToDeduce);
|
||||
break;
|
||||
case 3: // HS 50
|
||||
dailyReport.setDeduceSupHours50(true);
|
||||
dailyReport.setSupHours50ToDeduce(valueToDeduce);
|
||||
break;
|
||||
dailyReport.setDeduceSupHours50(true);
|
||||
dailyReport.setSupHours50ToDeduce(valueToDeduce);
|
||||
break;
|
||||
case 4: // HS 100
|
||||
dailyReport.setDeduceSupHours100(true);
|
||||
dailyReport.setSupHours100ToDeduce(valueToDeduce);
|
||||
break;
|
||||
dailyReport.setDeduceSupHours100(true);
|
||||
dailyReport.setSupHours100ToDeduce(valueToDeduce);
|
||||
break;
|
||||
default:
|
||||
return; // Invalid configSelect, stop processing
|
||||
return; // Invalid configSelect, stop processing
|
||||
}
|
||||
Beans.get(DailyReportRepository.class).save(dailyReport);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void massDeducePrimes(List<DailyReport> dailyReportList, Integer primeSelection, BigDecimal valueToDeduce) throws AxelorException {
|
||||
public void massDeducePrimes(
|
||||
List<DailyReport> dailyReportList, Integer primeSelection, BigDecimal valueToDeduce)
|
||||
throws AxelorException {
|
||||
for (DailyReport dailyReport : dailyReportList) {
|
||||
this.deducePrimes(dailyReport, primeSelection, valueToDeduce);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.axelor.apps.hr.service;
|
||||
|
||||
import com.axelor.apps.base.db.Period;
|
||||
import com.axelor.apps.hr.db.Absence;
|
||||
import com.axelor.apps.hr.db.Authorization;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.LeaveRequest;
|
||||
import com.axelor.apps.hr.db.MonthlyReport;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.repo.AbsenceRepository;
|
||||
import com.axelor.apps.hr.db.repo.AuthorizationRepository;
|
||||
import com.axelor.apps.hr.db.repo.MonthlyReportRepository;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.db.repo.MonthlyReportRepository;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
@@ -18,7 +17,6 @@ import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import com.axelor.inject.Beans;
|
||||
|
||||
public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
|
||||
@@ -42,8 +40,13 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
|
||||
public void createMensuelReport(Employee employee, Period period, LocalDate startDate, LocalDate endDate, List<DailyReport> employeeDailyReports, List<Absence> employeeAbsences) {
|
||||
public void createMensuelReport(
|
||||
Employee employee,
|
||||
Period period,
|
||||
LocalDate startDate,
|
||||
LocalDate endDate,
|
||||
List<DailyReport> employeeDailyReports,
|
||||
List<Absence> employeeAbsences) {
|
||||
|
||||
Boolean hasNuissance = employee.getHasNuissance();
|
||||
LocalDate firstDayOfMonth = endDate.with(TemporalAdjusters.firstDayOfMonth());
|
||||
@@ -61,7 +64,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
BigDecimal totalNuissance = BigDecimal.ZERO;
|
||||
BigDecimal totalAbsence = BigDecimal.ZERO;
|
||||
BigDecimal totalWorkHours = BigDecimal.ZERO;
|
||||
|
||||
|
||||
BigDecimal breastfeedingAbsenceMonth = BigDecimal.ZERO;
|
||||
BigDecimal authorizedPaidAbsenceMonth = BigDecimal.ZERO;
|
||||
BigDecimal recuperationLeaveAbsenceMonth = BigDecimal.ZERO;
|
||||
@@ -83,7 +86,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
BigDecimal militaryServiceAbsence = BigDecimal.ZERO;
|
||||
BigDecimal irregularAbsenceMonth = BigDecimal.ZERO;
|
||||
|
||||
//monthlyAllowance = monthlyAllowance + remainingDateToLastOfMonth;
|
||||
// monthlyAllowance = monthlyAllowance + remainingDateToLastOfMonth;
|
||||
|
||||
// Calculate totals for DailyReport
|
||||
for (DailyReport dailyReport : employeeDailyReports) {
|
||||
@@ -94,35 +97,49 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
monthlyAllowance = monthlyAllowance + 1;
|
||||
}*/
|
||||
|
||||
monthlyAllowance = monthlyAllowance + dailyReport.getAllowance();;
|
||||
monthlyAllowance = monthlyAllowance + dailyReport.getAllowance();
|
||||
;
|
||||
monthlyAllowanceRecall = monthlyAllowanceRecall + dailyReport.getAllowanceRecall();
|
||||
monthlyNightHours = monthlyNightHours.add(dailyReport.getNightHours());
|
||||
totalWorkHours = totalWorkHours.add(dailyReport.getWorkHours());
|
||||
|
||||
BigDecimal heureSup50 = dailyReport.getExtraHours50() != null ? dailyReport.getExtraHours50() : BigDecimal.ZERO;
|
||||
BigDecimal heureSup100 = dailyReport.getExtraHours100() != null ? dailyReport.getExtraHours100() : BigDecimal.ZERO;
|
||||
BigDecimal heureSup50 =
|
||||
dailyReport.getExtraHours50() != null ? dailyReport.getExtraHours50() : BigDecimal.ZERO;
|
||||
BigDecimal heureSup100 =
|
||||
dailyReport.getExtraHours100() != null ? dailyReport.getExtraHours100() : BigDecimal.ZERO;
|
||||
BigDecimal itp = dailyReport.getItp() != null ? dailyReport.getItp() : BigDecimal.ZERO;
|
||||
BigDecimal nuissance = dailyReport.getNuissance() != null ? dailyReport.getNuissance() : BigDecimal.ZERO;
|
||||
BigDecimal nuissance =
|
||||
dailyReport.getNuissance() != null ? dailyReport.getNuissance() : BigDecimal.ZERO;
|
||||
|
||||
BigDecimal supHours50ToDeduce = dailyReport.getSupHours50ToDeduce() != null ? dailyReport.getSupHours50ToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal supHours100ToDeduce = dailyReport.getSupHours100ToDeduce() != null ? dailyReport.getSupHours100ToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal itpToDeduce = dailyReport.getItpToDeduce() != null ? dailyReport.getItpToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal nuissanceToDeduce = dailyReport.getNuissanceToDeduce() != null ? dailyReport.getNuissanceToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal supHours50ToDeduce =
|
||||
dailyReport.getSupHours50ToDeduce() != null
|
||||
? dailyReport.getSupHours50ToDeduce()
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal supHours100ToDeduce =
|
||||
dailyReport.getSupHours100ToDeduce() != null
|
||||
? dailyReport.getSupHours100ToDeduce()
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal itpToDeduce =
|
||||
dailyReport.getItpToDeduce() != null ? dailyReport.getItpToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal nuissanceToDeduce =
|
||||
dailyReport.getNuissanceToDeduce() != null
|
||||
? dailyReport.getNuissanceToDeduce()
|
||||
: BigDecimal.ZERO;
|
||||
|
||||
if (dailyReport.getDeduceSupHours50() && heureSup50.compareTo(supHours50ToDeduce) > 0) {
|
||||
heureSup50 = heureSup50.subtract(supHours50ToDeduce);
|
||||
if (dailyReport.getDeduceSupHours50() && heureSup50.compareTo(supHours50ToDeduce) > 0) {
|
||||
heureSup50 = heureSup50.subtract(supHours50ToDeduce);
|
||||
}
|
||||
|
||||
if (dailyReport.getDeduceSupHours100() && heureSup100.compareTo(supHours100ToDeduce) > 0) {
|
||||
heureSup100 = heureSup100.subtract(supHours100ToDeduce);
|
||||
heureSup100 = heureSup100.subtract(supHours100ToDeduce);
|
||||
}
|
||||
|
||||
if (dailyReport.getDeduceItp() && itp.compareTo(itpToDeduce) > 0) {
|
||||
itp = itp.subtract(itpToDeduce);
|
||||
itp = itp.subtract(itpToDeduce);
|
||||
}
|
||||
|
||||
if (dailyReport.getDeduceNuissance() && nuissance.compareTo(nuissanceToDeduce) > 0) {
|
||||
nuissance = nuissance.subtract(nuissanceToDeduce);
|
||||
if (dailyReport.getDeduceNuissance() && nuissance.compareTo(nuissanceToDeduce) > 0) {
|
||||
nuissance = nuissance.subtract(nuissanceToDeduce);
|
||||
}
|
||||
|
||||
monthlyITP = monthlyITP.add(itp);
|
||||
@@ -130,7 +147,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
|
||||
// Sup Hours
|
||||
if (dailyReport.getIsValidSupHours()) {
|
||||
|
||||
|
||||
// Handle HeureSup50
|
||||
if (heureSup50 != null) {
|
||||
if (totalSupHours.add(heureSup50).compareTo(new BigDecimal(32)) <= 0) {
|
||||
@@ -177,19 +194,25 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
LeaveRequest leaveRequest = dailyReport.getLeaveRequest();
|
||||
Set<Absence> absences = dailyReport.getAbsenceSet();
|
||||
|
||||
if (dailyReport.getAbsenceHours() != null && dailyReport.getAbsenceHours().compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (isAuthorizedAbsence == false && isAuthorizedLateArrival == false && isAuthorizedEarlyDeparture == false && leaveRequest == null && absences == null) {
|
||||
if (dailyReport.getAbsenceHours() != null
|
||||
&& dailyReport.getAbsenceHours().compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (isAuthorizedAbsence == false
|
||||
&& isAuthorizedLateArrival == false
|
||||
&& isAuthorizedEarlyDeparture == false
|
||||
&& leaveRequest == null
|
||||
&& absences == null) {
|
||||
irregularAbsenceMonth = irregularAbsenceMonth.add(dailyReport.getAbsenceHours());
|
||||
} else if(isAuthorizedAbsence){
|
||||
} else if (isAuthorizedAbsence) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getAbsenceHours());
|
||||
} else if(isAuthorizedLateArrival){
|
||||
} else if (isAuthorizedLateArrival) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getLateArrival());
|
||||
} else if(isAuthorizedEarlyDeparture){
|
||||
} else if (isAuthorizedEarlyDeparture) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
} else if(leaveRequest != null){
|
||||
recuperationLeaveAbsenceMonth = recuperationLeaveAbsenceMonth.add(dailyReport.getAbsenceHours());
|
||||
} else if(absences != null){
|
||||
for(Absence absence:absences){
|
||||
} else if (leaveRequest != null) {
|
||||
recuperationLeaveAbsenceMonth =
|
||||
recuperationLeaveAbsenceMonth.add(dailyReport.getAbsenceHours());
|
||||
} else if (absences != null) {
|
||||
for (Absence absence : absences) {
|
||||
totalAbsence = dailyReport.getAbsenceHours();
|
||||
switch (absence.getAbsenceType()) {
|
||||
case 0:
|
||||
@@ -250,24 +273,26 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
militaryServiceAbsence = militaryServiceAbsence.add(totalAbsence);
|
||||
break;
|
||||
case 19:
|
||||
if(dailyReport.getIsAuthorizedAbsence()){
|
||||
if (dailyReport.getIsAuthorizedAbsence()) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(totalAbsence);
|
||||
} else {
|
||||
irregularAbsenceMonth = irregularAbsenceMonth.add(totalAbsence);
|
||||
}
|
||||
break;
|
||||
case 20:
|
||||
if(dailyReport.getIsAuthorizedLateArrival()){
|
||||
if (dailyReport.getIsAuthorizedLateArrival()) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getLateArrival());
|
||||
} else {
|
||||
irregularAbsenceMonth = irregularAbsenceMonth.add(dailyReport.getLateArrival());
|
||||
}
|
||||
break;
|
||||
case 21:
|
||||
if(dailyReport.getIsAuthorizedEarlyDeparture()){
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
if (dailyReport.getIsAuthorizedEarlyDeparture()) {
|
||||
justifiedAbsenceMonth =
|
||||
justifiedAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
} else {
|
||||
irregularAbsenceMonth = irregularAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
irregularAbsenceMonth =
|
||||
irregularAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -276,7 +301,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update or create MonthlyReport instance with calculated values
|
||||
@@ -321,7 +346,14 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
monthlyReportRepository.save(monthlyReport);
|
||||
}
|
||||
|
||||
public void updateMensuelReport(MonthlyReport monthlyReport, Employee employee, Period period, LocalDate startDate, LocalDate endDate, List<DailyReport> employeeDailyReports, List<Absence> employeeAbsences) {
|
||||
public void updateMensuelReport(
|
||||
MonthlyReport monthlyReport,
|
||||
Employee employee,
|
||||
Period period,
|
||||
LocalDate startDate,
|
||||
LocalDate endDate,
|
||||
List<DailyReport> employeeDailyReports,
|
||||
List<Absence> employeeAbsences) {
|
||||
|
||||
Boolean hasNuissance = employee.getHasNuissance();
|
||||
LocalDate firstDayOfMonth = endDate.with(TemporalAdjusters.firstDayOfMonth());
|
||||
@@ -339,7 +371,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
BigDecimal totalNuissance = BigDecimal.ZERO;
|
||||
BigDecimal totalAbsence = BigDecimal.ZERO;
|
||||
BigDecimal totalWorkHours = BigDecimal.ZERO;
|
||||
|
||||
|
||||
BigDecimal breastfeedingAbsenceMonth = BigDecimal.ZERO;
|
||||
BigDecimal authorizedPaidAbsenceMonth = BigDecimal.ZERO;
|
||||
BigDecimal recuperationLeaveAbsenceMonth = BigDecimal.ZERO;
|
||||
@@ -361,7 +393,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
BigDecimal militaryServiceAbsence = BigDecimal.ZERO;
|
||||
BigDecimal irregularAbsenceMonth = BigDecimal.ZERO;
|
||||
|
||||
//monthlyAllowance = monthlyAllowance + remainingDateToLastOfMonth;
|
||||
// monthlyAllowance = monthlyAllowance + remainingDateToLastOfMonth;
|
||||
|
||||
// Calculate totals for DailyReport
|
||||
for (DailyReport dailyReport : employeeDailyReports) {
|
||||
@@ -372,35 +404,49 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
monthlyAllowance = monthlyAllowance + 1;
|
||||
}*/
|
||||
|
||||
monthlyAllowance = monthlyAllowance + dailyReport.getAllowance();;
|
||||
monthlyAllowance = monthlyAllowance + dailyReport.getAllowance();
|
||||
;
|
||||
monthlyAllowanceRecall = monthlyAllowanceRecall + dailyReport.getAllowanceRecall();
|
||||
monthlyNightHours = monthlyNightHours.add(dailyReport.getNightHours());
|
||||
totalWorkHours = totalWorkHours.add(dailyReport.getWorkHours());
|
||||
|
||||
BigDecimal heureSup50 = dailyReport.getExtraHours50() != null ? dailyReport.getExtraHours50() : BigDecimal.ZERO;
|
||||
BigDecimal heureSup100 = dailyReport.getExtraHours100() != null ? dailyReport.getExtraHours100() : BigDecimal.ZERO;
|
||||
BigDecimal heureSup50 =
|
||||
dailyReport.getExtraHours50() != null ? dailyReport.getExtraHours50() : BigDecimal.ZERO;
|
||||
BigDecimal heureSup100 =
|
||||
dailyReport.getExtraHours100() != null ? dailyReport.getExtraHours100() : BigDecimal.ZERO;
|
||||
BigDecimal itp = dailyReport.getItp() != null ? dailyReport.getItp() : BigDecimal.ZERO;
|
||||
BigDecimal nuissance = dailyReport.getNuissance() != null ? dailyReport.getNuissance() : BigDecimal.ZERO;
|
||||
BigDecimal nuissance =
|
||||
dailyReport.getNuissance() != null ? dailyReport.getNuissance() : BigDecimal.ZERO;
|
||||
|
||||
BigDecimal supHours50ToDeduce = dailyReport.getSupHours50ToDeduce() != null ? dailyReport.getSupHours50ToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal supHours100ToDeduce = dailyReport.getSupHours100ToDeduce() != null ? dailyReport.getSupHours100ToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal itpToDeduce = dailyReport.getItpToDeduce() != null ? dailyReport.getItpToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal nuissanceToDeduce = dailyReport.getNuissanceToDeduce() != null ? dailyReport.getNuissanceToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal supHours50ToDeduce =
|
||||
dailyReport.getSupHours50ToDeduce() != null
|
||||
? dailyReport.getSupHours50ToDeduce()
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal supHours100ToDeduce =
|
||||
dailyReport.getSupHours100ToDeduce() != null
|
||||
? dailyReport.getSupHours100ToDeduce()
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal itpToDeduce =
|
||||
dailyReport.getItpToDeduce() != null ? dailyReport.getItpToDeduce() : BigDecimal.ZERO;
|
||||
BigDecimal nuissanceToDeduce =
|
||||
dailyReport.getNuissanceToDeduce() != null
|
||||
? dailyReport.getNuissanceToDeduce()
|
||||
: BigDecimal.ZERO;
|
||||
|
||||
if (dailyReport.getDeduceSupHours50() && heureSup50.compareTo(supHours50ToDeduce) > 0) {
|
||||
heureSup50 = heureSup50.subtract(supHours50ToDeduce);
|
||||
if (dailyReport.getDeduceSupHours50() && heureSup50.compareTo(supHours50ToDeduce) > 0) {
|
||||
heureSup50 = heureSup50.subtract(supHours50ToDeduce);
|
||||
}
|
||||
|
||||
if (dailyReport.getDeduceSupHours100() && heureSup100.compareTo(supHours100ToDeduce) > 0) {
|
||||
heureSup100 = heureSup100.subtract(supHours100ToDeduce);
|
||||
heureSup100 = heureSup100.subtract(supHours100ToDeduce);
|
||||
}
|
||||
|
||||
if (dailyReport.getDeduceItp() && itp.compareTo(itpToDeduce) > 0) {
|
||||
itp = itp.subtract(itpToDeduce);
|
||||
itp = itp.subtract(itpToDeduce);
|
||||
}
|
||||
|
||||
if (dailyReport.getDeduceNuissance() && nuissance.compareTo(nuissanceToDeduce) > 0) {
|
||||
nuissance = nuissance.subtract(nuissanceToDeduce);
|
||||
if (dailyReport.getDeduceNuissance() && nuissance.compareTo(nuissanceToDeduce) > 0) {
|
||||
nuissance = nuissance.subtract(nuissanceToDeduce);
|
||||
}
|
||||
|
||||
monthlyITP = monthlyITP.add(itp);
|
||||
@@ -408,7 +454,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
|
||||
// Sup Hours
|
||||
if (dailyReport.getIsValidSupHours()) {
|
||||
|
||||
|
||||
// Handle HeureSup50
|
||||
if (heureSup50 != null) {
|
||||
if (totalSupHours.add(heureSup50).compareTo(new BigDecimal(32)) <= 0) {
|
||||
@@ -455,19 +501,25 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
LeaveRequest leaveRequest = dailyReport.getLeaveRequest();
|
||||
Set<Absence> absences = dailyReport.getAbsenceSet();
|
||||
|
||||
if (dailyReport.getAbsenceHours() != null && dailyReport.getAbsenceHours().compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (isAuthorizedAbsence == false && isAuthorizedLateArrival == false && isAuthorizedEarlyDeparture == false && leaveRequest == null && absences == null) {
|
||||
if (dailyReport.getAbsenceHours() != null
|
||||
&& dailyReport.getAbsenceHours().compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (isAuthorizedAbsence == false
|
||||
&& isAuthorizedLateArrival == false
|
||||
&& isAuthorizedEarlyDeparture == false
|
||||
&& leaveRequest == null
|
||||
&& absences == null) {
|
||||
irregularAbsenceMonth = irregularAbsenceMonth.add(dailyReport.getAbsenceHours());
|
||||
} else if(isAuthorizedAbsence){
|
||||
} else if (isAuthorizedAbsence) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getAbsenceHours());
|
||||
} else if(isAuthorizedLateArrival){
|
||||
} else if (isAuthorizedLateArrival) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getLateArrival());
|
||||
} else if(isAuthorizedEarlyDeparture){
|
||||
} else if (isAuthorizedEarlyDeparture) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
} else if(leaveRequest != null){
|
||||
recuperationLeaveAbsenceMonth = recuperationLeaveAbsenceMonth.add(dailyReport.getAbsenceHours());
|
||||
} else if(absences != null){
|
||||
for(Absence absence:absences){
|
||||
} else if (leaveRequest != null) {
|
||||
recuperationLeaveAbsenceMonth =
|
||||
recuperationLeaveAbsenceMonth.add(dailyReport.getAbsenceHours());
|
||||
} else if (absences != null) {
|
||||
for (Absence absence : absences) {
|
||||
totalAbsence = dailyReport.getAbsenceHours();
|
||||
switch (absence.getAbsenceType()) {
|
||||
case 0:
|
||||
@@ -528,24 +580,26 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
militaryServiceAbsence = militaryServiceAbsence.add(totalAbsence);
|
||||
break;
|
||||
case 19:
|
||||
if(dailyReport.getIsAuthorizedAbsence()){
|
||||
if (dailyReport.getIsAuthorizedAbsence()) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(totalAbsence);
|
||||
} else {
|
||||
irregularAbsenceMonth = irregularAbsenceMonth.add(totalAbsence);
|
||||
}
|
||||
break;
|
||||
case 20:
|
||||
if(dailyReport.getIsAuthorizedLateArrival()){
|
||||
if (dailyReport.getIsAuthorizedLateArrival()) {
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getLateArrival());
|
||||
} else {
|
||||
irregularAbsenceMonth = irregularAbsenceMonth.add(dailyReport.getLateArrival());
|
||||
}
|
||||
break;
|
||||
case 21:
|
||||
if(dailyReport.getIsAuthorizedEarlyDeparture()){
|
||||
justifiedAbsenceMonth = justifiedAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
if (dailyReport.getIsAuthorizedEarlyDeparture()) {
|
||||
justifiedAbsenceMonth =
|
||||
justifiedAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
} else {
|
||||
irregularAbsenceMonth = irregularAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
irregularAbsenceMonth =
|
||||
irregularAbsenceMonth.add(dailyReport.getEarlyDeparture());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -554,7 +608,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update or create MonthlyReport instance with calculated values
|
||||
|
||||
@@ -253,7 +253,7 @@ public class EmployeeServiceImpl extends UserServiceImpl implements EmployeeServ
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void setEmployeeEnrolled(Employee employee){
|
||||
public void setEmployeeEnrolled(Employee employee) {
|
||||
employee.setIsEnrolled(true);
|
||||
Beans.get(EmployeeRepository.class).save(employee);
|
||||
}
|
||||
@@ -263,29 +263,27 @@ public class EmployeeServiceImpl extends UserServiceImpl implements EmployeeServ
|
||||
public void updateEmployeeConfig(Employee employee, Integer configSelect, Boolean status)
|
||||
throws AxelorException {
|
||||
switch (configSelect) {
|
||||
case 1: // ITP
|
||||
employee.setHasItp(status);
|
||||
break;
|
||||
case 2: // Nuissance
|
||||
employee.setHasNuissance(status);
|
||||
break;
|
||||
case 3: // Transfaire
|
||||
employee.setIsTransfaire(status);
|
||||
break;
|
||||
default:
|
||||
return; // Invalid configSelect, stop processing
|
||||
}
|
||||
case 1: // ITP
|
||||
employee.setHasItp(status);
|
||||
break;
|
||||
case 2: // Nuissance
|
||||
employee.setHasNuissance(status);
|
||||
break;
|
||||
case 3: // Transfaire
|
||||
employee.setIsTransfaire(status);
|
||||
break;
|
||||
default:
|
||||
return; // Invalid configSelect, stop processing
|
||||
}
|
||||
Beans.get(EmployeeRepository.class).save(employee);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void massUpdateEmployeeConfig(List<Long> employeesIds, Integer configSelect, Boolean status) throws AxelorException{
|
||||
public void massUpdateEmployeeConfig(
|
||||
List<Long> employeesIds, Integer configSelect, Boolean status) throws AxelorException {
|
||||
List<Employee> employees =
|
||||
Beans.get(EmployeeRepository.class)
|
||||
.all()
|
||||
.filter("self.id in (?1)", employeesIds)
|
||||
.fetch();
|
||||
Beans.get(EmployeeRepository.class).all().filter("self.id in (?1)", employeesIds).fetch();
|
||||
|
||||
if (employeesIds != null || !employeesIds.isEmpty()) {
|
||||
for (Employee employee : employees) {
|
||||
|
||||
@@ -17,17 +17,16 @@
|
||||
*/
|
||||
package com.axelor.apps.hr.service.extra.hours;
|
||||
|
||||
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.repo.EmployeeRepository;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.repo.CompanyRepository;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.ExtraHours;
|
||||
import com.axelor.apps.hr.db.ExtraHoursLine;
|
||||
import com.axelor.apps.hr.db.HRConfig;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.db.repo.EmployeeRepository;
|
||||
import com.axelor.apps.hr.db.repo.ExtraHoursRepository;
|
||||
import com.axelor.apps.hr.service.config.HRConfigService;
|
||||
import com.axelor.apps.message.db.Message;
|
||||
@@ -37,13 +36,13 @@ import com.axelor.exception.AxelorException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import javax.mail.MessagingException;
|
||||
import wslite.json.JSONException;
|
||||
@@ -201,16 +200,17 @@ public class ExtraHoursServiceImpl implements ExtraHoursService {
|
||||
String heureDebut = jsonObject.getString("heure_debut");
|
||||
String heureFin = jsonObject.getString("heure_fin");
|
||||
String lieuTravail = jsonObject.getString("lieu_travail");
|
||||
int validation_status = jsonObject.optInt("validation_status",2);
|
||||
String validateByUser = jsonObject.optString("validate_by_user",null);
|
||||
String dateValidation = jsonObject.optString("validation_date",null);
|
||||
int validation_status = jsonObject.optInt("validation_status", 2);
|
||||
String validateByUser = jsonObject.optString("validate_by_user", null);
|
||||
String dateValidation = jsonObject.optString("validation_date", null);
|
||||
|
||||
// GET EMPLOYEES
|
||||
Employee employee = employeeRepo
|
||||
.all()
|
||||
.filter("self.registrationNumber = :matricule")
|
||||
.bind("matricule", matricule)
|
||||
.fetchOne();
|
||||
Employee employee =
|
||||
employeeRepo
|
||||
.all()
|
||||
.filter("self.registrationNumber = :matricule")
|
||||
.bind("matricule", matricule)
|
||||
.fetchOne();
|
||||
|
||||
if (employee == null) {
|
||||
System.err.println("Employee with matricule " + matricule + " not found.");
|
||||
@@ -219,29 +219,31 @@ public class ExtraHoursServiceImpl implements ExtraHoursService {
|
||||
|
||||
Employee validatedByEmployee = null;
|
||||
|
||||
if(validateByUser != null){
|
||||
validatedByEmployee = employeeRepo
|
||||
.all()
|
||||
.filter("self.registrationNumber = :matricule")
|
||||
.bind("matricule", validateByUser)
|
||||
.fetchOne();
|
||||
if (validateByUser != null) {
|
||||
validatedByEmployee =
|
||||
employeeRepo
|
||||
.all()
|
||||
.filter("self.registrationNumber = :matricule")
|
||||
.bind("matricule", validateByUser)
|
||||
.fetchOne();
|
||||
|
||||
if (validatedByEmployee == null) {
|
||||
System.err.println("Validator employee with matricule " + validateByUser + " not found.");
|
||||
return;
|
||||
}
|
||||
if (validatedByEmployee == null) {
|
||||
System.err.println("Validator employee with matricule " + validateByUser + " not found.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse validation date (handle null case)
|
||||
LocalDate validationDate = null;
|
||||
if (dateValidation != null && !dateValidation.isEmpty()) {
|
||||
try {
|
||||
OffsetDateTime offsetDateTime = OffsetDateTime.parse(dateValidation, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
validationDate = offsetDateTime.toLocalDate(); // Extract only the date part
|
||||
} catch (DateTimeParseException e) {
|
||||
System.out.println("Error parsing dateValidation: " + dateValidation);
|
||||
validationDate = null;
|
||||
}
|
||||
try {
|
||||
OffsetDateTime offsetDateTime =
|
||||
OffsetDateTime.parse(dateValidation, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
validationDate = offsetDateTime.toLocalDate(); // Extract only the date part
|
||||
} catch (DateTimeParseException e) {
|
||||
System.out.println("Error parsing dateValidation: " + dateValidation);
|
||||
validationDate = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse Requisition Date
|
||||
@@ -254,46 +256,49 @@ public class ExtraHoursServiceImpl implements ExtraHoursService {
|
||||
}
|
||||
|
||||
// Check if Authorization exists by ticketId
|
||||
ExtraHours extraHours = extraHoursRepo
|
||||
.all()
|
||||
.filter("self.ticketId = :ticketId")
|
||||
.bind("ticketId", idInt)
|
||||
.fetchOne();
|
||||
ExtraHours extraHours =
|
||||
extraHoursRepo
|
||||
.all()
|
||||
.filter("self.ticketId = :ticketId")
|
||||
.bind("ticketId", idInt)
|
||||
.fetchOne();
|
||||
|
||||
if (extraHours != null) {
|
||||
// Authorization exists, compare previous and new status
|
||||
int previousStatus = extraHours.getStatusSelect(); // Previous status
|
||||
int newStatus = validation_status; // New status
|
||||
// Authorization exists, compare previous and new status
|
||||
int previousStatus = extraHours.getStatusSelect(); // Previous status
|
||||
int newStatus = validation_status; // New status
|
||||
|
||||
if (previousStatus == 2 && newStatus == 3) {
|
||||
System.out.println("Tickets :" + idInt + " Status changed from " + previousStatus + " to " + newStatus);
|
||||
// Update the fields of the existing Authorization
|
||||
extraHours.setValidatedByEmployee(validatedByEmployee);
|
||||
extraHours.setValidationDate(validationDate);
|
||||
extraHours.setStatusSelect(newStatus);
|
||||
// Save the updated Authorization
|
||||
extraHoursRepo.save(extraHours);
|
||||
if (previousStatus == 2 && newStatus == 3) {
|
||||
System.out.println(
|
||||
"Tickets :" + idInt + " Status changed from " + previousStatus + " to " + newStatus);
|
||||
// Update the fields of the existing Authorization
|
||||
extraHours.setValidatedByEmployee(validatedByEmployee);
|
||||
extraHours.setValidationDate(validationDate);
|
||||
extraHours.setStatusSelect(newStatus);
|
||||
// Save the updated Authorization
|
||||
extraHoursRepo.save(extraHours);
|
||||
|
||||
// Get Daily report
|
||||
DailyReport dailyReport =
|
||||
dailyReportRepo
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.reportDate = :reportDate")
|
||||
.bind("employee", employee)
|
||||
.bind("reportDate", requisitionDate)
|
||||
.fetchOne();
|
||||
// Get Daily report
|
||||
DailyReport dailyReport =
|
||||
dailyReportRepo
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.reportDate = :reportDate")
|
||||
.bind("employee", employee)
|
||||
.bind("reportDate", requisitionDate)
|
||||
.fetchOne();
|
||||
|
||||
if (dailyReport != null) {
|
||||
dailyReport.setIsValidSupHours(true);
|
||||
}
|
||||
} else if (previousStatus == 2 && newStatus == 4) {
|
||||
System.out.println("Tickets :" + idInt + " Status changed from " + previousStatus + " to " + newStatus);
|
||||
extraHours.setRefusedByEmployee(validatedByEmployee);
|
||||
extraHours.setRefusalDate(validationDate);
|
||||
extraHours.setStatusSelect(newStatus);
|
||||
// Save the updated Authorization
|
||||
extraHoursRepo.save(extraHours);
|
||||
}
|
||||
if (dailyReport != null) {
|
||||
dailyReport.setIsValidSupHours(true);
|
||||
}
|
||||
} else if (previousStatus == 2 && newStatus == 4) {
|
||||
System.out.println(
|
||||
"Tickets :" + idInt + " Status changed from " + previousStatus + " to " + newStatus);
|
||||
extraHours.setRefusedByEmployee(validatedByEmployee);
|
||||
extraHours.setRefusalDate(validationDate);
|
||||
extraHours.setStatusSelect(newStatus);
|
||||
// Save the updated Authorization
|
||||
extraHoursRepo.save(extraHours);
|
||||
}
|
||||
} else {
|
||||
// Create an instance of ExtraHours
|
||||
extraHours = new ExtraHours();
|
||||
@@ -325,14 +330,13 @@ public class ExtraHoursServiceImpl implements ExtraHoursService {
|
||||
}
|
||||
|
||||
if (validation_status == 3) {
|
||||
extraHours.setValidatedByEmployee(validatedByEmployee);
|
||||
extraHours.setValidationDate(validationDate);
|
||||
extraHours.setValidatedByEmployee(validatedByEmployee);
|
||||
extraHours.setValidationDate(validationDate);
|
||||
} else if (validation_status == 4) {
|
||||
extraHours.setRefusedByEmployee(validatedByEmployee);
|
||||
extraHours.setRefusalDate(validationDate);
|
||||
extraHours.setRefusedByEmployee(validatedByEmployee);
|
||||
extraHours.setRefusalDate(validationDate);
|
||||
}
|
||||
|
||||
|
||||
// Save the ExtraHours entity
|
||||
extraHoursRepo.save(extraHours);
|
||||
|
||||
@@ -356,8 +360,7 @@ public class ExtraHoursServiceImpl implements ExtraHoursService {
|
||||
|
||||
// Add the new ExtraHours to the list
|
||||
supHoursList.add(extraHours);
|
||||
if (validation_status == 3)
|
||||
dailyReport.setIsValidSupHours(true);
|
||||
if (validation_status == 3) dailyReport.setIsValidSupHours(true);
|
||||
// Set the updated list back to dailyReport
|
||||
dailyReport.setSupHoursList(supHoursList);
|
||||
}
|
||||
@@ -369,5 +372,4 @@ public class ExtraHoursServiceImpl implements ExtraHoursService {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ import com.axelor.apps.base.db.repo.ICalendarEventRepository;
|
||||
import com.axelor.apps.base.ical.ICalendarService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.base.service.weeklyplanning.WeeklyPlanningService;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.HRConfig;
|
||||
import com.axelor.apps.hr.db.LeaveLine;
|
||||
import com.axelor.apps.hr.db.LeaveReason;
|
||||
import com.axelor.apps.hr.db.LeaveRequest;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.repo.EmployeeRepository;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.db.repo.EmployeeRepository;
|
||||
import com.axelor.apps.hr.db.repo.LeaveLineRepository;
|
||||
import com.axelor.apps.hr.db.repo.LeaveReasonRepository;
|
||||
import com.axelor.apps.hr.db.repo.LeaveRequestRepository;
|
||||
@@ -57,14 +57,13 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.List;
|
||||
import javax.mail.MessagingException;
|
||||
import wslite.json.JSONException;
|
||||
import wslite.json.JSONObject;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
||||
|
||||
public class LeaveServiceImpl implements LeaveService {
|
||||
|
||||
@@ -945,47 +944,50 @@ public class LeaveServiceImpl implements LeaveService {
|
||||
String dateDebut = jsonObject.getString("de");
|
||||
String dateFin = jsonObject.getString("a");
|
||||
String commentaire = jsonObject.getString("commentaire");
|
||||
int validation_status = jsonObject.optInt("validation_status",2);
|
||||
String validateByUser = jsonObject.optString("validate_by_user",null);
|
||||
String dateValidation = jsonObject.optString("validation_date",null);
|
||||
int validation_status = jsonObject.optInt("validation_status", 2);
|
||||
String validateByUser = jsonObject.optString("validate_by_user", null);
|
||||
String dateValidation = jsonObject.optString("validation_date", null);
|
||||
|
||||
// GET EMPLOYEES
|
||||
Employee employee = employeeRepo
|
||||
.all()
|
||||
.filter("self.registrationNumber = :matricule")
|
||||
.bind("matricule", matricule)
|
||||
.fetchOne();
|
||||
Employee employee =
|
||||
employeeRepo
|
||||
.all()
|
||||
.filter("self.registrationNumber = :matricule")
|
||||
.bind("matricule", matricule)
|
||||
.fetchOne();
|
||||
|
||||
if (employee == null) {
|
||||
System.err.println("Employee with matricule " + matricule + " not found.");
|
||||
return;
|
||||
System.err.println("Employee with matricule " + matricule + " not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
Employee validatedByEmployee = null;
|
||||
|
||||
if(validateByUser != null){
|
||||
validatedByEmployee = employeeRepo
|
||||
.all()
|
||||
.filter("self.registrationNumber = :matricule")
|
||||
.bind("matricule", validateByUser)
|
||||
.fetchOne();
|
||||
if (validateByUser != null) {
|
||||
validatedByEmployee =
|
||||
employeeRepo
|
||||
.all()
|
||||
.filter("self.registrationNumber = :matricule")
|
||||
.bind("matricule", validateByUser)
|
||||
.fetchOne();
|
||||
|
||||
if (validatedByEmployee == null) {
|
||||
System.err.println("Validator employee with matricule " + validateByUser + " not found.");
|
||||
return;
|
||||
}
|
||||
if (validatedByEmployee == null) {
|
||||
System.err.println("Validator employee with matricule " + validateByUser + " not found.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse validation date (handle null case)
|
||||
LocalDate validationDate = null;
|
||||
if (dateValidation != null && !dateValidation.isEmpty()) {
|
||||
try {
|
||||
OffsetDateTime offsetDateTime = OffsetDateTime.parse(dateValidation, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
validationDate = offsetDateTime.toLocalDate(); // Extract only the date part
|
||||
} catch (DateTimeParseException e) {
|
||||
System.out.println("Error parsing dateValidation: " + dateValidation);
|
||||
validationDate = null;
|
||||
}
|
||||
try {
|
||||
OffsetDateTime offsetDateTime =
|
||||
OffsetDateTime.parse(dateValidation, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
validationDate = offsetDateTime.toLocalDate(); // Extract only the date part
|
||||
} catch (DateTimeParseException e) {
|
||||
System.out.println("Error parsing dateValidation: " + dateValidation);
|
||||
validationDate = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse Dates
|
||||
@@ -1008,18 +1010,20 @@ public class LeaveServiceImpl implements LeaveService {
|
||||
LocalDateTime debutDateTime = debutDate.atStartOfDay();
|
||||
LocalDateTime finDateTime = finDate.atStartOfDay();
|
||||
|
||||
LeaveRequest leaveRequest = leaveRequestRepo
|
||||
.all()
|
||||
.filter("self.ticketId = :ticketId")
|
||||
.bind("ticketId", idInt)
|
||||
.fetchOne();
|
||||
|
||||
if (leaveRequest != null) {
|
||||
LeaveRequest leaveRequest =
|
||||
leaveRequestRepo
|
||||
.all()
|
||||
.filter("self.ticketId = :ticketId")
|
||||
.bind("ticketId", idInt)
|
||||
.fetchOne();
|
||||
|
||||
if (leaveRequest != null) {
|
||||
// Authorization exists, compare previous and new status
|
||||
int previousStatus = leaveRequest.getStatusSelect(); // Previous status
|
||||
int newStatus = validation_status; // New status
|
||||
int previousStatus = leaveRequest.getStatusSelect(); // Previous status
|
||||
int newStatus = validation_status; // New status
|
||||
if (previousStatus == 2 && newStatus == 3) {
|
||||
System.out.println("Tickets :" + idInt + " Status changed from " + previousStatus + " to " + newStatus);
|
||||
System.out.println(
|
||||
"Tickets :" + idInt + " Status changed from " + previousStatus + " to " + newStatus);
|
||||
// Update the fields of the existing Authorization
|
||||
leaveRequest.setValidatedByEmployee(validatedByEmployee);
|
||||
leaveRequest.setValidationDate(validationDate);
|
||||
@@ -1027,27 +1031,30 @@ public class LeaveServiceImpl implements LeaveService {
|
||||
// Save the updated Authorization
|
||||
leaveRequestRepo.save(leaveRequest);
|
||||
// Get Daily report
|
||||
List<DailyReport> dailyReports = dailyReportRepo
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.reportDate >= :debutDate and self.reportDate <= :finDate")
|
||||
.bind("employee", employee)
|
||||
.bind("debutDate", debutDate)
|
||||
.bind("finDate", finDate)
|
||||
.fetch();
|
||||
List<DailyReport> dailyReports =
|
||||
dailyReportRepo
|
||||
.all()
|
||||
.filter(
|
||||
"self.employee = :employee and self.reportDate >= :debutDate and self.reportDate <= :finDate")
|
||||
.bind("employee", employee)
|
||||
.bind("debutDate", debutDate)
|
||||
.bind("finDate", finDate)
|
||||
.fetch();
|
||||
|
||||
if (dailyReports != null) {
|
||||
for (DailyReport dailyReport : dailyReports) {
|
||||
dailyReport.setIsAuthorizedAbsence(true);
|
||||
dailyReportRepo.save(dailyReport);
|
||||
dailyReport.setIsAuthorizedAbsence(true);
|
||||
dailyReportRepo.save(dailyReport);
|
||||
}
|
||||
}
|
||||
} else if (previousStatus == 2 && newStatus == 4) {
|
||||
System.out.println("Tickets :" + idInt + " Status changed from " + previousStatus + " to " + newStatus);
|
||||
leaveRequest.setRefusedByEmployee(validatedByEmployee);
|
||||
leaveRequest.setRefusalDate(validationDate);
|
||||
leaveRequest.setStatusSelect(newStatus);
|
||||
// Save the updated Authorization
|
||||
leaveRequestRepo.save(leaveRequest);
|
||||
System.out.println(
|
||||
"Tickets :" + idInt + " Status changed from " + previousStatus + " to " + newStatus);
|
||||
leaveRequest.setRefusedByEmployee(validatedByEmployee);
|
||||
leaveRequest.setRefusalDate(validationDate);
|
||||
leaveRequest.setStatusSelect(newStatus);
|
||||
// Save the updated Authorization
|
||||
leaveRequestRepo.save(leaveRequest);
|
||||
}
|
||||
} else {
|
||||
// Create an instance of ExtraHours
|
||||
@@ -1062,30 +1069,31 @@ public class LeaveServiceImpl implements LeaveService {
|
||||
leaveRequest.setCompany(company);
|
||||
|
||||
if (validation_status == 3) {
|
||||
leaveRequest.setValidatedByEmployee(validatedByEmployee);
|
||||
leaveRequest.setValidationDate(validationDate);
|
||||
leaveRequest.setValidatedByEmployee(validatedByEmployee);
|
||||
leaveRequest.setValidationDate(validationDate);
|
||||
} else if (validation_status == 4) {
|
||||
leaveRequest.setRefusedByEmployee(validatedByEmployee);
|
||||
leaveRequest.setRefusalDate(validationDate);
|
||||
leaveRequest.setRefusedByEmployee(validatedByEmployee);
|
||||
leaveRequest.setRefusalDate(validationDate);
|
||||
}
|
||||
|
||||
// Save the ExtraHours entity
|
||||
leaveRequestRepo.save(leaveRequest);
|
||||
|
||||
// Get Daily report
|
||||
List<DailyReport> dailyReports = dailyReportRepo
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.reportDate >= :debutDate and self.reportDate <= :finDate")
|
||||
.bind("employee", employee)
|
||||
.bind("debutDate", debutDate)
|
||||
.bind("finDate", finDate)
|
||||
.fetch();
|
||||
List<DailyReport> dailyReports =
|
||||
dailyReportRepo
|
||||
.all()
|
||||
.filter(
|
||||
"self.employee = :employee and self.reportDate >= :debutDate and self.reportDate <= :finDate")
|
||||
.bind("employee", employee)
|
||||
.bind("debutDate", debutDate)
|
||||
.bind("finDate", finDate)
|
||||
.fetch();
|
||||
|
||||
if (dailyReports != null) {
|
||||
for (DailyReport dailyReport : dailyReports) {
|
||||
dailyReport.setLeaveRequest(leaveRequest); // Set the recup leave for each report
|
||||
if(validation_status == 3)
|
||||
dailyReport.setIsAuthorizedAbsence(true);
|
||||
if (validation_status == 3) dailyReport.setIsAuthorizedAbsence(true);
|
||||
dailyReportRepo.save(dailyReport);
|
||||
}
|
||||
}
|
||||
@@ -1097,5 +1105,4 @@ public class LeaveServiceImpl implements LeaveService {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
package com.axelor.apps.hr.web;
|
||||
|
||||
import com.axelor.apps.hr.db.Absence;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.repo.AbsenceRepository;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.service.AbsenceServiceImpl;
|
||||
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 java.math.BigDecimal;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.meta.schema.actions.ActionView.ActionViewBuilder;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AbsenceController {
|
||||
@@ -32,35 +30,40 @@ public class AbsenceController {
|
||||
Employee employee = absence.getEmployee();
|
||||
|
||||
// Fetch all existing daily reports associated with this absence
|
||||
List<DailyReport> existingReports =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.absenceSet = :absence")
|
||||
.bind("absence", absence)
|
||||
.fetch();
|
||||
List<DailyReport> existingReports =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.absenceSet = :absence")
|
||||
.bind("absence", absence)
|
||||
.fetch();
|
||||
|
||||
if (existingReports != null && !existingReports.isEmpty()) {
|
||||
// Detach absence only from reports that are outside the new date range
|
||||
List<DailyReport> reportsToDetach = existingReports.stream()
|
||||
.filter(report -> report.getReportDate().isBefore(absenceStartDate) || report.getReportDate().isAfter(absenceEndDate))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<DailyReport> reportsToDetach =
|
||||
existingReports
|
||||
.stream()
|
||||
.filter(
|
||||
report ->
|
||||
report.getReportDate().isBefore(absenceStartDate)
|
||||
|| report.getReportDate().isAfter(absenceEndDate))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Detach absence from these specific reports
|
||||
if (!reportsToDetach.isEmpty()) {
|
||||
Beans.get(AbsenceServiceImpl.class).deAttachTheAbsenceWithDailyReport(absence, reportsToDetach, false);
|
||||
Beans.get(AbsenceServiceImpl.class)
|
||||
.deAttachTheAbsenceWithDailyReport(absence, reportsToDetach, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<DailyReport> newReports =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.employee = :employee and self.reportDate between :absenceStartDate and :absenceEndDate")
|
||||
.bind("employee", employee)
|
||||
.bind("absenceStartDate", absenceStartDate)
|
||||
.bind("absenceEndDate", absenceEndDate)
|
||||
.fetch();
|
||||
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.employee = :employee and self.reportDate between :absenceStartDate and :absenceEndDate")
|
||||
.bind("employee", employee)
|
||||
.bind("absenceStartDate", absenceStartDate)
|
||||
.bind("absenceEndDate", absenceEndDate)
|
||||
.fetch();
|
||||
|
||||
// Check if there are any reports
|
||||
if (newReports.isEmpty()) {
|
||||
@@ -108,25 +111,26 @@ public class AbsenceController {
|
||||
Long absenceId = (Long) request.getContext().asType(Absence.class).getId();
|
||||
Absence absence = Beans.get(AbsenceRepository.class).find(absenceId);
|
||||
|
||||
List<DailyReport> dailyreports = Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.absence = :absence")
|
||||
.bind("absence", absenceId)
|
||||
.fetch();
|
||||
List<DailyReport> dailyreports =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.absence = :absence")
|
||||
.bind("absence", absenceId)
|
||||
.fetch();
|
||||
|
||||
Beans.get(AbsenceServiceImpl.class).deAttachTheAbsenceWithDailyReport(absence, dailyreports, true);
|
||||
Beans.get(AbsenceServiceImpl.class)
|
||||
.deAttachTheAbsenceWithDailyReport(absence, dailyreports, true);
|
||||
ActionViewBuilder actionView =
|
||||
ActionView.define(I18n.get("Absences"))
|
||||
.model(Absence.class.getName())
|
||||
.add("grid", "absence-grid")
|
||||
.add("form", "absence-form");
|
||||
ActionView.define(I18n.get("Absences"))
|
||||
.model(Absence.class.getName())
|
||||
.add("grid", "absence-grid")
|
||||
.add("form", "absence-form");
|
||||
|
||||
response.setView(actionView.map());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void calculateTotalAbsenceHours(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
@@ -137,9 +141,10 @@ public class AbsenceController {
|
||||
LocalDateTime absenceEndDate = absence.getEndDate();
|
||||
if (absenceStartDate.isAfter(absenceEndDate)) {
|
||||
response.setAlert("Start date cannot be after end date.");
|
||||
}
|
||||
else {
|
||||
BigDecimal totalAbsenceHours = Beans.get(AbsenceServiceImpl.class).calculateTotalAbsenceHours(absenceStartDate,absenceEndDate);
|
||||
} else {
|
||||
BigDecimal totalAbsenceHours =
|
||||
Beans.get(AbsenceServiceImpl.class)
|
||||
.calculateTotalAbsenceHours(absenceStartDate, absenceEndDate);
|
||||
response.setValue("totalAbsenceHours", totalAbsenceHours);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -168,7 +168,8 @@ public class AuthorizationController {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// General catch for unexpected exceptions
|
||||
System.err.println("An error occurred while fetching Salary Authorization: " + e.getMessage());
|
||||
System.err.println(
|
||||
"An error occurred while fetching Salary Authorization: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -369,5 +370,4 @@ public class AuthorizationController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
package com.axelor.apps.hr.web;
|
||||
|
||||
import com.axelor.apps.hr.db.Shift;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.db.repo.ShiftRepository;
|
||||
import com.axelor.apps.hr.db.repo.EmployeeRepository;
|
||||
import com.axelor.apps.hr.service.DailyReportService;
|
||||
import com.axelor.apps.hr.service.DailyReportServiceImpl;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.time.LocalTime;
|
||||
import java.time.LocalDate;
|
||||
import java.math.BigDecimal;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
|
||||
public class DailyReportController {
|
||||
|
||||
@@ -32,14 +28,12 @@ public class DailyReportController {
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
|
||||
public void workingHours(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
Long dailyReportId = (Long) request.getContext().asType(DailyReport.class).getId();
|
||||
DailyReport DailyReport = Beans.get(DailyReportRepository.class).find(dailyReportId);
|
||||
if (DailyReport == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"DailyReport with ID " + dailyReportId + " not found.");
|
||||
throw new IllegalArgumentException("DailyReport with ID " + dailyReportId + " not found.");
|
||||
}
|
||||
Beans.get(DailyReportServiceImpl.class).determineShift(DailyReport);
|
||||
Beans.get(DailyReportServiceImpl.class).workingHours(DailyReport);
|
||||
@@ -55,8 +49,7 @@ public class DailyReportController {
|
||||
Long dailyReportId = (Long) request.getContext().asType(DailyReport.class).getId();
|
||||
DailyReport DailyReport = Beans.get(DailyReportRepository.class).find(dailyReportId);
|
||||
if (DailyReport == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"DailyReport with ID " + dailyReportId + " not found.");
|
||||
throw new IllegalArgumentException("DailyReport with ID " + dailyReportId + " not found.");
|
||||
}
|
||||
Beans.get(DailyReportServiceImpl.class).workingHours(DailyReport);
|
||||
response.setReload(true);
|
||||
@@ -95,34 +88,33 @@ public class DailyReportController {
|
||||
List<DailyReport> dailyReportList =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1 ",dailyReportIds)
|
||||
.filter("self.id in ?1 ", dailyReportIds)
|
||||
.fetch();
|
||||
|
||||
for(DailyReport dailyReport: dailyReportList){
|
||||
|
||||
for (DailyReport dailyReport : dailyReportList) {
|
||||
Beans.get(DailyReportServiceImpl.class).determineShift(dailyReport);
|
||||
}
|
||||
Beans.get(DailyReportServiceImpl.class).workingHoursForAll(dailyReportList);
|
||||
response.setFlash("Working hours calculated successfully.");
|
||||
} else {
|
||||
response.setFlash("No Daily report selected");
|
||||
response.setFlash("No Daily report selected");
|
||||
}
|
||||
}
|
||||
|
||||
public void workingHoursForChangedInstances(ActionRequest request, ActionResponse response) {
|
||||
List<DailyReport> dailyReportList =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.isCalculated = ? and self.isChanged = ?", false,true)
|
||||
.fetch();
|
||||
|
||||
for(DailyReport dailyReport: dailyReportList){
|
||||
Beans.get(DailyReportServiceImpl.class).determineShift(dailyReport);
|
||||
}
|
||||
List<DailyReport> dailyReportList =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.isCalculated = ? and self.isChanged = ?", false, true)
|
||||
.fetch();
|
||||
|
||||
Beans.get(DailyReportServiceImpl.class).workingHoursForAll(dailyReportList);
|
||||
response.setReload(true);
|
||||
response.setFlash("Working hours calculated successfully.");
|
||||
for (DailyReport dailyReport : dailyReportList) {
|
||||
Beans.get(DailyReportServiceImpl.class).determineShift(dailyReport);
|
||||
}
|
||||
|
||||
Beans.get(DailyReportServiceImpl.class).workingHoursForAll(dailyReportList);
|
||||
response.setReload(true);
|
||||
response.setFlash("Working hours calculated successfully.");
|
||||
}
|
||||
|
||||
public void massDeducePrime(ActionRequest request, ActionResponse response) {
|
||||
@@ -135,46 +127,49 @@ public class DailyReportController {
|
||||
LocalDate endDate = null;
|
||||
|
||||
try {
|
||||
if (startDateStr != null) {
|
||||
startDate = LocalDate.parse(startDateStr);
|
||||
}
|
||||
if (endDateStr != null) {
|
||||
endDate = LocalDate.parse(endDateStr);
|
||||
}
|
||||
if (startDateStr != null) {
|
||||
startDate = LocalDate.parse(startDateStr);
|
||||
}
|
||||
if (endDateStr != null) {
|
||||
endDate = LocalDate.parse(endDateStr);
|
||||
}
|
||||
|
||||
// Validate the dates
|
||||
if (startDate == null || endDate == null) {
|
||||
response.setFlash("Start date or end date is missing or invalid.");
|
||||
return;
|
||||
}
|
||||
// Validate the dates
|
||||
if (startDate == null || endDate == null) {
|
||||
response.setFlash("Start date or end date is missing or invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (startDate.isAfter(endDate)) {
|
||||
response.setFlash("Start date cannot be after end date.");
|
||||
return;
|
||||
}
|
||||
if (startDate.isAfter(endDate)) {
|
||||
response.setFlash("Start date cannot be after end date.");
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (DateTimeParseException e) {
|
||||
response.setFlash("Invalid date format for startDate or endDate. Expected format: yyyy-MM-dd.");
|
||||
return;
|
||||
response.setFlash(
|
||||
"Invalid date format for startDate or endDate. Expected format: yyyy-MM-dd.");
|
||||
return;
|
||||
}
|
||||
|
||||
Object valueToDeduceObj = request.getContext().get("valueToDeduce");
|
||||
|
||||
BigDecimal valueToDeduce = null;
|
||||
if (valueToDeduceObj instanceof Integer) {
|
||||
valueToDeduce = BigDecimal.valueOf((Integer) valueToDeduceObj);
|
||||
valueToDeduce = BigDecimal.valueOf((Integer) valueToDeduceObj);
|
||||
} else if (valueToDeduceObj instanceof BigDecimal) {
|
||||
valueToDeduce = (BigDecimal) valueToDeduceObj;
|
||||
valueToDeduce = (BigDecimal) valueToDeduceObj;
|
||||
} else if (valueToDeduceObj instanceof String) {
|
||||
try {
|
||||
valueToDeduce = new BigDecimal((String) valueToDeduceObj);
|
||||
} catch (NumberFormatException e) {
|
||||
response.setFlash("Value to deduce must be a valid number.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
response.setFlash("Invalid value to deduce: unsupported type " + (valueToDeduceObj != null ? valueToDeduceObj.getClass().getName() : "null"));
|
||||
try {
|
||||
valueToDeduce = new BigDecimal((String) valueToDeduceObj);
|
||||
} catch (NumberFormatException e) {
|
||||
response.setFlash("Value to deduce must be a valid number.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
response.setFlash(
|
||||
"Invalid value to deduce: unsupported type "
|
||||
+ (valueToDeduceObj != null ? valueToDeduceObj.getClass().getName() : "null"));
|
||||
return;
|
||||
}
|
||||
|
||||
Object employeesObject = request.getContext().get("employees");
|
||||
@@ -183,53 +178,56 @@ public class DailyReportController {
|
||||
List<Employee> employees = new ArrayList<>();
|
||||
|
||||
if (employeesObject instanceof List) {
|
||||
List<LinkedHashMap<String, Object>> employeesList = (List<LinkedHashMap<String, Object>>) employeesObject;
|
||||
List<LinkedHashMap<String, Object>> employeesList =
|
||||
(List<LinkedHashMap<String, Object>>) employeesObject;
|
||||
|
||||
for (LinkedHashMap<String, Object> employeeMap : employeesList) {
|
||||
Integer employeeIdInt = (Integer) employeeMap.get("id");
|
||||
for (LinkedHashMap<String, Object> employeeMap : employeesList) {
|
||||
Integer employeeIdInt = (Integer) employeeMap.get("id");
|
||||
|
||||
if (employeeIdInt != null) {
|
||||
Long employeeId = employeeIdInt.longValue();
|
||||
Employee employee = Beans.get(EmployeeRepository.class).find(employeeId);
|
||||
if (employeeIdInt != null) {
|
||||
Long employeeId = employeeIdInt.longValue();
|
||||
Employee employee = Beans.get(EmployeeRepository.class).find(employeeId);
|
||||
|
||||
if (employee != null) {
|
||||
employees.add(employee);
|
||||
}
|
||||
}
|
||||
if (employee != null) {
|
||||
employees.add(employee);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (employees.isEmpty()) {
|
||||
response.setFlash("No employees selected.");
|
||||
return;
|
||||
response.setFlash("No employees selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Integer> employeeIds = new ArrayList<>();
|
||||
for (Employee employee : employees) {
|
||||
employeeIds.add(employee.getId().intValue());
|
||||
employeeIds.add(employee.getId().intValue());
|
||||
}
|
||||
|
||||
// Fetch all rapport journaliers within the date range for all employees
|
||||
List<DailyReport> dailyReportList = Beans.get(DailyReportRepository.class)
|
||||
List<DailyReport> dailyReportList =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.employee.id in :employeeIds and self.reportDate >= :startDate and self.reportDate <= :endDate")
|
||||
.filter(
|
||||
"self.employee.id in :employeeIds and self.reportDate >= :startDate and self.reportDate <= :endDate")
|
||||
.bind("startDate", startDate)
|
||||
.bind("endDate", endDate)
|
||||
.bind("employeeIds", employeeIds)
|
||||
.fetch();
|
||||
|
||||
try {
|
||||
if (!dailyReportList.isEmpty()) {
|
||||
Beans.get(DailyReportService.class).massDeducePrimes(dailyReportList, primeSelection, valueToDeduce);
|
||||
response.setReload(true);
|
||||
response.setFlash("Prime deductions processed successfully.");
|
||||
} else {
|
||||
response.setFlash("No reports found for the selected date range.");
|
||||
}
|
||||
if (!dailyReportList.isEmpty()) {
|
||||
Beans.get(DailyReportService.class)
|
||||
.massDeducePrimes(dailyReportList, primeSelection, valueToDeduce);
|
||||
response.setReload(true);
|
||||
response.setFlash("Prime deductions processed successfully.");
|
||||
} else {
|
||||
response.setFlash("No reports found for the selected date range.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
response.setFlash("An error occurred while processing the request.");
|
||||
TraceBackService.trace(response, e);
|
||||
response.setFlash("An error occurred while processing the request.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
*/
|
||||
package com.axelor.apps.hr.web;
|
||||
|
||||
import com.axelor.apps.hr.db.Granding;
|
||||
import com.axelor.apps.hr.db.repo.GrandingRepository;
|
||||
import com.axelor.app.AppSettings;
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.axelor.apps.base.db.Partner;
|
||||
import com.axelor.apps.hr.db.DPAE;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.Granding;
|
||||
import com.axelor.apps.hr.db.repo.EmployeeRepository;
|
||||
import com.axelor.apps.hr.db.repo.GrandingRepository;
|
||||
import com.axelor.apps.hr.report.IReport;
|
||||
import com.axelor.apps.hr.service.employee.EmployeeService;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
@@ -38,17 +39,16 @@ import com.axelor.meta.schema.actions.ActionView.ActionViewBuilder;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import wslite.json.JSONException;
|
||||
import wslite.json.JSONObject;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import com.axelor.app.AppSettings;
|
||||
|
||||
@Singleton
|
||||
public class EmployeeController {
|
||||
@@ -149,22 +149,21 @@ public class EmployeeController {
|
||||
|
||||
response.setReload(true);
|
||||
}
|
||||
public void enrollEmployee(ActionRequest request, ActionResponse response){
|
||||
|
||||
public void enrollEmployee(ActionRequest request, ActionResponse response) {
|
||||
Long employeeId = (Long) request.getContext().asType(Employee.class).getId();
|
||||
Employee employee = Beans.get(EmployeeRepository.class).find(employeeId);
|
||||
|
||||
Granding granding = Beans.get(GrandingRepository.class)
|
||||
.all()
|
||||
.filter("self.name = 'POINTEUSE-RDC'")
|
||||
.fetchOne();
|
||||
Granding granding =
|
||||
Beans.get(GrandingRepository.class).all().filter("self.name = 'POINTEUSE-RDC'").fetchOne();
|
||||
|
||||
String ipAdress = granding.getIpAdress();
|
||||
String code = granding.getCode().toString();
|
||||
|
||||
if(employee.getIsEnrolled()) {
|
||||
if (employee.getIsEnrolled()) {
|
||||
response.setFlash("Employee is already enrolled.");
|
||||
} else {
|
||||
if (employee.getContactPartner() != null){
|
||||
if (employee.getContactPartner() != null) {
|
||||
String employeeRegistrationNumber = employee.getRegistrationNumber();
|
||||
String employeeName = employee.getContactPartner().getName();
|
||||
|
||||
@@ -172,54 +171,61 @@ public class EmployeeController {
|
||||
LOG.error("Pythons script path is not configured in AppSettings.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
String[] args = {
|
||||
"python",
|
||||
pythonScriptDir + "\\Attendance\\main.py",
|
||||
"--commande", "create",
|
||||
"--ip_address", ipAdress,
|
||||
"--code", code,
|
||||
"--user_id", employeeRegistrationNumber,
|
||||
"--name", employeeName
|
||||
"--commande",
|
||||
"create",
|
||||
"--ip_address",
|
||||
ipAdress,
|
||||
"--code",
|
||||
code,
|
||||
"--user_id",
|
||||
employeeRegistrationNumber,
|
||||
"--name",
|
||||
employeeName
|
||||
};
|
||||
|
||||
|
||||
Process p = Runtime.getRuntime().exec(args);
|
||||
|
||||
|
||||
// Capture the output stream (standard output)
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
LOG.info("Python script (Employee Enrolling) output: " + line);
|
||||
}
|
||||
|
||||
|
||||
// Capture the error stream (standard error)
|
||||
BufferedReader errorReader = new BufferedReader(new InputStreamReader(p.getErrorStream()));
|
||||
BufferedReader errorReader =
|
||||
new BufferedReader(new InputStreamReader(p.getErrorStream()));
|
||||
while ((line = errorReader.readLine()) != null) {
|
||||
LOG.error("Python script (Employee Enrolling) error: " + line);
|
||||
}
|
||||
|
||||
|
||||
// Wait for the process to complete and check the exit value
|
||||
int exitCode = p.waitFor();
|
||||
|
||||
|
||||
// Check if the process ran successfully
|
||||
if (exitCode == 0) {
|
||||
LOG.info("Python script executed successfully (Employee Enrolling).");
|
||||
Beans.get(EmployeeService.class).setEmployeeEnrolled(employee);
|
||||
response.setFlash("Employee enrolled successfully.");
|
||||
} else {
|
||||
LOG.error("Python script execution (Employee Enrolling) failed with exit code: " + exitCode);
|
||||
LOG.error(
|
||||
"Python script execution (Employee Enrolling) failed with exit code: " + exitCode);
|
||||
response.setFlash("Failed to enroll the Employee.");
|
||||
}
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
// Check if the file is not found based on the message or error code
|
||||
if (e.getMessage().contains("The system cannot find the file specified")) {
|
||||
LOG.error("Python script file (Employee Enrolling) not found: " + e.getMessage());
|
||||
} else {
|
||||
LOG.error("An error occurred while executing the Python script (Employee Enrolling).", e);
|
||||
LOG.error(
|
||||
"An error occurred while executing the Python script (Employee Enrolling).", e);
|
||||
}
|
||||
response.setFlash("Failed to enroll the Employee.");
|
||||
TraceBackService.trace(e);
|
||||
@@ -246,7 +252,7 @@ public class EmployeeController {
|
||||
}
|
||||
try {
|
||||
if (!employeeIds.isEmpty()) {
|
||||
Beans.get(EmployeeService.class).massUpdateEmployeeConfig(employeeIds, configSelect,true);
|
||||
Beans.get(EmployeeService.class).massUpdateEmployeeConfig(employeeIds, configSelect, true);
|
||||
response.setReload(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -267,13 +273,12 @@ public class EmployeeController {
|
||||
}
|
||||
try {
|
||||
if (!employeeIds.isEmpty()) {
|
||||
Beans.get(EmployeeService.class).massUpdateEmployeeConfig(employeeIds, configSelect,false);
|
||||
Beans.get(EmployeeService.class).massUpdateEmployeeConfig(employeeIds, configSelect, false);
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
package com.axelor.apps.hr.web;
|
||||
|
||||
|
||||
import com.axelor.apps.hr.db.Granding;
|
||||
import com.axelor.apps.hr.db.repo.GrandingRepository;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class GrandingController {
|
||||
|
||||
@@ -31,15 +26,18 @@ public class GrandingController {
|
||||
String code = granding.getCode().toString();
|
||||
|
||||
try {
|
||||
|
||||
|
||||
String[] args = {
|
||||
"python",
|
||||
"C:\\Users\\administrator\\Desktop\\attendance\\main.py",
|
||||
"--commande", "ping",
|
||||
"--ip_address", ipAdress,
|
||||
"--code", code
|
||||
"--commande",
|
||||
"ping",
|
||||
"--ip_address",
|
||||
ipAdress,
|
||||
"--code",
|
||||
code
|
||||
};
|
||||
|
||||
|
||||
Process p = Runtime.getRuntime().exec(args);
|
||||
|
||||
// Capture the output stream (standard output)
|
||||
@@ -83,4 +81,4 @@ public class GrandingController {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,26 +3,26 @@ package com.axelor.apps.hr.web;
|
||||
import com.axelor.apps.base.db.Period;
|
||||
import com.axelor.apps.base.db.repo.PeriodRepository;
|
||||
import com.axelor.apps.hr.db.Absence;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.DailyReport;
|
||||
import com.axelor.apps.hr.db.Employee;
|
||||
import com.axelor.apps.hr.db.MonthlyReport;
|
||||
import com.axelor.apps.hr.db.repo.AbsenceRepository;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.db.repo.EmployeeRepository;
|
||||
import com.axelor.apps.hr.db.repo.MonthlyReportRepository;
|
||||
import com.axelor.apps.hr.db.repo.DailyReportRepository;
|
||||
import com.axelor.apps.hr.service.MonthlyReportServiceImpl;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MonthlyReportController {
|
||||
LocalDate startDate = period.getFromDate();
|
||||
LocalDate endDate = period.getToDate();
|
||||
|
||||
//int remainingDateToLastOfMonth = calculateDaysExcludingFridaysAndThursdays(endDate);
|
||||
// int remainingDateToLastOfMonth = calculateDaysExcludingFridaysAndThursdays(endDate);
|
||||
|
||||
// Get active employees in this period
|
||||
List<Employee> employees =
|
||||
@@ -72,29 +72,28 @@ public class MonthlyReportController {
|
||||
// Iterate over employees and calculate/update MonthlyReport instances
|
||||
for (Employee employee : employees) {
|
||||
// Filter rapport journaliers for the current employee
|
||||
List<DailyReport> employeeDailyReports = allDailyReports
|
||||
.stream()
|
||||
.filter(r -> r.getEmployee().equals(employee))
|
||||
.collect(Collectors.toList());
|
||||
List<DailyReport> employeeDailyReports =
|
||||
allDailyReports
|
||||
.stream()
|
||||
.filter(r -> r.getEmployee().equals(employee))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Filter absences for the current employee
|
||||
List<Absence> employeeAbsences = allAbsences
|
||||
.stream()
|
||||
.filter(a -> a.getEmployee().equals(employee))
|
||||
.collect(Collectors.toList());
|
||||
List<Absence> employeeAbsences =
|
||||
allAbsences
|
||||
.stream()
|
||||
.filter(a -> a.getEmployee().equals(employee))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!employeeDailyReports.isEmpty() || !employeeAbsences.isEmpty()) {
|
||||
System.out.println("Create monthly report for employee: "+ employee.getRegistrationNumber());
|
||||
System.out.println(
|
||||
"Create monthly report for employee: " + employee.getRegistrationNumber());
|
||||
// Process the employee's monthly report using filtered rapport and absences
|
||||
Beans.get(MonthlyReportServiceImpl.class).createMensuelReport(
|
||||
employee,
|
||||
period,
|
||||
startDate,
|
||||
endDate,
|
||||
employeeDailyReports,
|
||||
employeeAbsences);
|
||||
Beans.get(MonthlyReportServiceImpl.class)
|
||||
.createMensuelReport(
|
||||
employee, period, startDate, endDate, employeeDailyReports, employeeAbsences);
|
||||
} else {
|
||||
log.error("No Daily Reports exist for employee: "+ employee.getRegistrationNumber());
|
||||
log.error("No Daily Reports exist for employee: " + employee.getRegistrationNumber());
|
||||
}
|
||||
}
|
||||
// Indicate that the action was successful and a reload is needed
|
||||
@@ -126,35 +125,36 @@ public class MonthlyReportController {
|
||||
|
||||
// Check if employeesObject is not null and cast it to a list
|
||||
if (employeesObject instanceof List) {
|
||||
List<LinkedHashMap<String, Object>> employeesList = (List<LinkedHashMap<String, Object>>) employeesObject;
|
||||
List<LinkedHashMap<String, Object>> employeesList =
|
||||
(List<LinkedHashMap<String, Object>>) employeesObject;
|
||||
|
||||
// Loop through each employee in the list
|
||||
for (LinkedHashMap<String, Object> employeeMap : employeesList) {
|
||||
Integer employeeIdInt = (Integer) employeeMap.get("id");
|
||||
|
||||
// Check for null ID to avoid potential NullPointerException
|
||||
if (employeeIdInt != null) {
|
||||
Long employeeId = employeeIdInt.longValue();
|
||||
|
||||
// Retrieve the employee from the repository
|
||||
Employee employee = Beans.get(EmployeeRepository.class).find(employeeId);
|
||||
|
||||
if (employee != null) {
|
||||
employees.add(employee); // Use add() instead of append()
|
||||
} else {
|
||||
System.out.println("Employee with ID " + employeeId + " not found.");
|
||||
}
|
||||
} else {
|
||||
System.out.println("Employee ID is missing in the employeeMap.");
|
||||
}
|
||||
// Loop through each employee in the list
|
||||
for (LinkedHashMap<String, Object> employeeMap : employeesList) {
|
||||
Integer employeeIdInt = (Integer) employeeMap.get("id");
|
||||
|
||||
// Check for null ID to avoid potential NullPointerException
|
||||
if (employeeIdInt != null) {
|
||||
Long employeeId = employeeIdInt.longValue();
|
||||
|
||||
// Retrieve the employee from the repository
|
||||
Employee employee = Beans.get(EmployeeRepository.class).find(employeeId);
|
||||
|
||||
if (employee != null) {
|
||||
employees.add(employee); // Use add() instead of append()
|
||||
} else {
|
||||
System.out.println("Employee with ID " + employeeId + " not found.");
|
||||
}
|
||||
} else {
|
||||
System.out.println("Employee ID is missing in the employeeMap.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response.setFlash("No employees Selected.");
|
||||
}
|
||||
|
||||
//int remainingDateToLastOfMonth = calculateDaysExcludingFridaysAndThursdays(endDate);
|
||||
// int remainingDateToLastOfMonth = calculateDaysExcludingFridaysAndThursdays(endDate);
|
||||
List<Integer> employeesIds = new ArrayList<>();
|
||||
for(Employee e:employees){
|
||||
for (Employee e : employees) {
|
||||
employeesIds.add(e.getId().intValue());
|
||||
}
|
||||
|
||||
@@ -162,7 +162,8 @@ public class MonthlyReportController {
|
||||
List<DailyReport> allDailyReports =
|
||||
Beans.get(DailyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.employee in :employeesIds and self.reportDate >= :startDate and self.reportDate <= :endDate")
|
||||
.filter(
|
||||
"self.employee in :employeesIds and self.reportDate >= :startDate and self.reportDate <= :endDate")
|
||||
.bind("startDate", startDate)
|
||||
.bind("endDate", endDate)
|
||||
.bind("employeesIds", employeesIds)
|
||||
@@ -172,7 +173,8 @@ public class MonthlyReportController {
|
||||
List<Absence> allAbsences =
|
||||
Beans.get(AbsenceRepository.class)
|
||||
.all()
|
||||
.filter("self.employee in :employeesIds and DATE(self.startDate) >= :startDate and DATE(self.startDate) <= :endDate")
|
||||
.filter(
|
||||
"self.employee in :employeesIds and DATE(self.startDate) >= :startDate and DATE(self.startDate) <= :endDate")
|
||||
.bind("startDate", startDate)
|
||||
.bind("endDate", endDate)
|
||||
.bind("employeesIds", employeesIds)
|
||||
@@ -180,42 +182,59 @@ public class MonthlyReportController {
|
||||
|
||||
for (Employee employee : employees) {
|
||||
// Check if a MonthlyReport exists for this employee in the specified period
|
||||
MonthlyReport monthlyReport = Beans.get(MonthlyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.period = :period")
|
||||
.bind("employee", employee)
|
||||
.bind("period", period)
|
||||
.fetchOne();
|
||||
MonthlyReport monthlyReport =
|
||||
Beans.get(MonthlyReportRepository.class)
|
||||
.all()
|
||||
.filter("self.employee = :employee and self.period = :period")
|
||||
.bind("employee", employee)
|
||||
.bind("period", period)
|
||||
.fetchOne();
|
||||
|
||||
Optional<MonthlyReport> monthlyReportOpt = Optional.ofNullable(monthlyReport);
|
||||
|
||||
// Filter daily reports for the current employee
|
||||
List<DailyReport> employeeDailyReports = allDailyReports.stream()
|
||||
.filter(r -> r.getEmployee().equals(employee))
|
||||
.collect(Collectors.toList());
|
||||
List<DailyReport> employeeDailyReports =
|
||||
allDailyReports
|
||||
.stream()
|
||||
.filter(r -> r.getEmployee().equals(employee))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Filter absences for the current employee
|
||||
List<Absence> employeeAbsences = allAbsences.stream()
|
||||
.filter(a -> a.getEmployee().equals(employee))
|
||||
.collect(Collectors.toList());
|
||||
List<Absence> employeeAbsences =
|
||||
allAbsences
|
||||
.stream()
|
||||
.filter(a -> a.getEmployee().equals(employee))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!employeeDailyReports.isEmpty() || !employeeAbsences.isEmpty()) {
|
||||
if (monthlyReportOpt.isPresent()) {
|
||||
MonthlyReport existingReport = monthlyReportOpt.get();
|
||||
System.out.println("Update monthly report for employee: " + employee.getRegistrationNumber());
|
||||
// Update the existing monthly report
|
||||
Beans.get(MonthlyReportServiceImpl.class).updateMensuelReport(existingReport, employee, period, startDate, endDate, employeeDailyReports, employeeAbsences);
|
||||
} else {
|
||||
System.out.println("Create monthly report for employee: " + employee.getRegistrationNumber());
|
||||
// Create a new monthly report
|
||||
Beans.get(MonthlyReportServiceImpl.class).createMensuelReport(employee, period, startDate, endDate, employeeDailyReports, employeeAbsences);
|
||||
}
|
||||
if (monthlyReportOpt.isPresent()) {
|
||||
MonthlyReport existingReport = monthlyReportOpt.get();
|
||||
System.out.println(
|
||||
"Update monthly report for employee: " + employee.getRegistrationNumber());
|
||||
// Update the existing monthly report
|
||||
Beans.get(MonthlyReportServiceImpl.class)
|
||||
.updateMensuelReport(
|
||||
existingReport,
|
||||
employee,
|
||||
period,
|
||||
startDate,
|
||||
endDate,
|
||||
employeeDailyReports,
|
||||
employeeAbsences);
|
||||
} else {
|
||||
System.out.println(
|
||||
"Create monthly report for employee: " + employee.getRegistrationNumber());
|
||||
// Create a new monthly report
|
||||
Beans.get(MonthlyReportServiceImpl.class)
|
||||
.createMensuelReport(
|
||||
employee, period, startDate, endDate, employeeDailyReports, employeeAbsences);
|
||||
}
|
||||
} else {
|
||||
System.err.println("No Daily Reports exist for employee: " + employee.getRegistrationNumber());
|
||||
System.err.println(
|
||||
"No Daily Reports exist for employee: " + employee.getRegistrationNumber());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Indicate that the action was successful and a reload is needed
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -51,8 +51,6 @@ import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
@@ -502,5 +500,4 @@ public class LeaveController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.axelor.apps.message.service;
|
||||
|
||||
import com.axelor.apps.message.db.Message;
|
||||
import com.axelor.apps.message.db.Template;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.db.Model;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.meta.db.MetaFile;
|
||||
@@ -26,8 +27,6 @@ import com.axelor.tool.template.TemplateMaker;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import javax.mail.MessagingException;
|
||||
import com.axelor.auth.db.User;
|
||||
import java.util.List;
|
||||
|
||||
public interface TemplateMessageService {
|
||||
|
||||
@@ -44,8 +43,8 @@ public interface TemplateMessageService {
|
||||
InstantiationException, IllegalAccessException;
|
||||
|
||||
public Message generateAndSendMessageToBulkUsers(Model model, Template template, Set<User> users)
|
||||
throws MessagingException, IOException, AxelorException, ClassNotFoundException,
|
||||
InstantiationException, IllegalAccessException;
|
||||
throws MessagingException, IOException, AxelorException, ClassNotFoundException,
|
||||
InstantiationException, IllegalAccessException;
|
||||
|
||||
public Set<MetaFile> getMetaFiles(Template template) throws AxelorException, IOException;
|
||||
|
||||
|
||||
@@ -22,10 +22,12 @@ import com.axelor.apps.message.db.EmailAddress;
|
||||
import com.axelor.apps.message.db.Message;
|
||||
import com.axelor.apps.message.db.Template;
|
||||
import com.axelor.apps.message.db.TemplateContext;
|
||||
import com.axelor.apps.message.db.repo.EmailAccountRepository;
|
||||
import com.axelor.apps.message.db.repo.EmailAddressRepository;
|
||||
import com.axelor.apps.message.db.repo.MessageRepository;
|
||||
import com.axelor.apps.message.db.repo.TemplateRepository;
|
||||
import com.axelor.apps.message.exception.IExceptionMessage;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.db.EntityHelper;
|
||||
import com.axelor.db.JPA;
|
||||
import com.axelor.db.Model;
|
||||
@@ -50,21 +52,20 @@ import com.google.inject.persist.Transactional;
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import javax.mail.MessagingException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.axelor.auth.db.User;
|
||||
|
||||
public class TemplateMessageServiceImpl implements TemplateMessageService {
|
||||
|
||||
private static final String RECIPIENT_SEPARATOR = ";|,";
|
||||
private static final char TEMPLATE_DELIMITER = '$';
|
||||
@Inject protected EmailAccountRepository mailAccountRepo;
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@@ -235,7 +236,7 @@ public class TemplateMessageServiceImpl implements TemplateMessageService {
|
||||
// Set recipients as sets
|
||||
message.setToEmailAddressSet(emailAddresses);
|
||||
message.setCcEmailAddressSet(emailAddresses);
|
||||
|
||||
|
||||
messageService.sendMessage(message);
|
||||
|
||||
return message;
|
||||
@@ -350,6 +351,33 @@ public class TemplateMessageServiceImpl implements TemplateMessageService {
|
||||
return mailAccount;
|
||||
}
|
||||
|
||||
System.out.println("getMailAccount");
|
||||
// EmailAccount mailAccount = Beans.get(MailAccountService.class).getDefaultSender();
|
||||
EmailAccount mail = getDefaultSender();
|
||||
|
||||
// if (mailAccount != null) {
|
||||
// log.debug("Email account ::: {}", mailAccount);
|
||||
// return mailAccount;
|
||||
// }
|
||||
if (mail != null) {
|
||||
log.debug("Email ::: {}", mail);
|
||||
return mail;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected EmailAccount getDefaultSender() {
|
||||
EmailAccount mail =
|
||||
mailAccountRepo
|
||||
.all()
|
||||
.filter(
|
||||
"self.isDefault = true AND self.serverTypeSelect = ?1",
|
||||
EmailAccountRepository.SERVER_TYPE_SMTP)
|
||||
.fetchOne();
|
||||
if (mail != null) {
|
||||
log.debug("Email ::: {}", mail);
|
||||
return mail;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,4 +147,6 @@ public interface IExceptionMessage {
|
||||
|
||||
static final String UNIT_COST_CALCULATION_NO_PRODUCT = /*$$(*/
|
||||
"Please select an element (a product, a product category or a product family) to run calculation" /*)*/;
|
||||
|
||||
static final String STOCK_MOVE_NOT_VALIDATED = /*$$(*/ "Stock move not validated by SCH" /*)*/;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,11 @@ 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.ManufOrder;
|
||||
import com.axelor.apps.production.db.TempBomTree;
|
||||
import com.axelor.apps.production.db.repo.BillOfMaterialConsumptionRepository;
|
||||
import com.axelor.apps.production.db.repo.BillOfMaterialRepository;
|
||||
import com.axelor.apps.production.db.repo.ManufOrderRepository;
|
||||
import com.axelor.apps.production.db.repo.TempBomTreeRepository;
|
||||
import com.axelor.apps.production.exceptions.IExceptionMessage;
|
||||
import com.axelor.apps.production.report.IReport;
|
||||
@@ -50,7 +53,6 @@ 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 {
|
||||
|
||||
@@ -373,23 +375,67 @@ public class BillOfMaterialServiceImpl implements BillOfMaterialService {
|
||||
return newBom;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public BillOfMaterialConsumption createBomConsumptionFromRawMaterial(BillOfMaterial bom) {
|
||||
public BillOfMaterialConsumption createBomConsumptionFromRawMaterial(
|
||||
BillOfMaterial bom, ManufOrder manufOrder) {
|
||||
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.setUnit(bom.getUnit());
|
||||
newBom.setName(bom.getName());
|
||||
newBom.setFullName(bom.getFullName());
|
||||
// billOfMaterialConsumptionRepository.save(newBom);
|
||||
|
||||
newBom.setManufOrder(manufOrder);
|
||||
return newBom;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void createBomAndAttachToManufOrder(ManufOrder manufOrder) {
|
||||
if (manufOrder.getBillOfMaterial() != null
|
||||
&& manufOrder.getBillOfMaterialConsumptionList().size() == 0) {
|
||||
for (BillOfMaterial bom : manufOrder.getBillOfMaterial().getBillOfMaterialSet()) {
|
||||
BillOfMaterialConsumption newBom =
|
||||
Beans.get(BillOfMaterialServiceImpl.class)
|
||||
.createBomConsumptionFromRawMaterial(bom, manufOrder);
|
||||
manufOrder.addBillOfMaterialConsumptionListItem(newBom);
|
||||
}
|
||||
log.debug(
|
||||
"Bill of Material Consumption List size: {}",
|
||||
manufOrder.getBillOfMaterialConsumptionList().size());
|
||||
Beans.get(ManufOrderRepository.class).save(manufOrder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the Bill of Material consumption line into two lines.
|
||||
*
|
||||
* @param manufOrder
|
||||
* @param billConsumptionList
|
||||
* @param splitQty
|
||||
*/
|
||||
@Transactional
|
||||
public void splitBillOfMaterialConsumption(
|
||||
ManufOrder manufOrder,
|
||||
List<BillOfMaterialConsumption> billConsumptionList,
|
||||
BigDecimal splitQty) {
|
||||
|
||||
for (BillOfMaterialConsumption billOfMaterialConsumption : billConsumptionList) {
|
||||
|
||||
BigDecimal totalQty = billOfMaterialConsumption.getQty();
|
||||
totalQty = totalQty.subtract(splitQty);
|
||||
BillOfMaterialConsumption newLine =
|
||||
Beans.get(BillOfMaterialConsumptionRepository.class)
|
||||
.copy(billOfMaterialConsumption, true);
|
||||
newLine.setProduct(billOfMaterialConsumption.getProduct());
|
||||
newLine.setRealQty(splitQty);
|
||||
newLine.setQty(splitQty);
|
||||
newLine.setUnit(billOfMaterialConsumption.getUnit());
|
||||
newLine.setName(billOfMaterialConsumption.getName());
|
||||
newLine.setTrackingNumber(billOfMaterialConsumption.getTrackingNumber());
|
||||
billOfMaterialConsumption.setQty(totalQty);
|
||||
manufOrder.addBillOfMaterialConsumptionListItem(newLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,13 +41,11 @@ 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;
|
||||
@@ -65,15 +63,9 @@ 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;
|
||||
|
||||
@@ -475,9 +467,7 @@ public class MrpServiceProductionImpl extends MrpServiceImpl {
|
||||
Map<Long, Double> productQty)
|
||||
throws AxelorException {
|
||||
|
||||
|
||||
log.debug("****** FORTHUPPER ******** {} {}",product,qty);
|
||||
|
||||
log.debug("****** FORTHUPPER ******** {} {}", product, qty);
|
||||
|
||||
if (mrp.getIncludeBOM()) {
|
||||
|
||||
@@ -487,16 +477,20 @@ public class MrpServiceProductionImpl extends MrpServiceImpl {
|
||||
|
||||
super.createdProductionMasterPlan(product, mrp, qty, defaultBillOfMaterial.getQty());
|
||||
|
||||
|
||||
for (BillOfMaterial billOfMaterial : defaultBillOfMaterial.getBillOfMaterialSet()) {
|
||||
List<ProductionMasterPlan> productionMasterPlans = Beans.get(ProductionMasterPlanRepository.class).all().fetchStream()
|
||||
.filter(t -> t.getProduct() == product && t.getMrp() == mrp).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();
|
||||
|
||||
if (this.isMrpProduct(subProduct)) {
|
||||
|
||||
Double prodQty = productQty.get(subProduct.getId()) == null
|
||||
Double prodQty =
|
||||
productQty.get(subProduct.getId()) == null
|
||||
? Double.parseDouble("0")
|
||||
: productQty.get(subProduct.getId());
|
||||
|
||||
@@ -512,8 +506,6 @@ public class MrpServiceProductionImpl extends MrpServiceImpl {
|
||||
productionMasterPlans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
super.createMrpLineSophal(mrp, product, unit, qty, mrpForecastList, productQty);
|
||||
@@ -528,113 +520,119 @@ public class MrpServiceProductionImpl extends MrpServiceImpl {
|
||||
BigDecimal qty,
|
||||
BillOfMaterial billOfMaterial,
|
||||
BigDecimal defaultQty,
|
||||
List<ProductionMasterPlan> productionMasterPlans ) throws AxelorException {
|
||||
List<ProductionMasterPlan> productionMasterPlans)
|
||||
throws AxelorException {
|
||||
MrpLineSophal mrpLineSophal = new MrpLineSophal();
|
||||
|
||||
log.debug("****** FORTH ******** {} {}",product,qty);
|
||||
|
||||
log.debug("****** FORTH ******** {} {}", product, qty);
|
||||
|
||||
BigDecimal qtyReqPerBatch = billOfMaterial.getQty();
|
||||
int currentMonth = LocalDate.now().getMonth().getValue();
|
||||
BigDecimal currentProductionPlan = BigDecimal.ZERO;
|
||||
BigDecimal remaining= 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);
|
||||
|
||||
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);
|
||||
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)));
|
||||
}
|
||||
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);
|
||||
totalQtyUsed.add(qtyReqForProd);
|
||||
log.debug("totalQtyUsed**************** {}", totalQtyUsed);
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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 (remaining.compareTo(BigDecimal.ZERO) > 0) {
|
||||
decreasingQty = decreasingQty.add(remaining);
|
||||
} else {
|
||||
decreasingQty = BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mrpLineSophal.setQty(qty);
|
||||
mrpLineSophal.setTotalQtyUsed(totalQtyUsed);
|
||||
mrpLineSophal.setInitialQty(initialQty);
|
||||
@@ -648,56 +646,58 @@ public class MrpServiceProductionImpl extends MrpServiceImpl {
|
||||
Beans.get(MrpLineSophalRepository.class).save(mrpLineSophal);
|
||||
}
|
||||
|
||||
private BigDecimal getCurrentProductionPlan(Product product, Mrp mrp, int monthSelect) {
|
||||
|
||||
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);
|
||||
|
||||
ProductionMasterPlan productionMasterPlan = Beans.get(ProductionMasterPlanRepository.class).all().fetchStream().filter(t -> t.getProduct() == product && t.getMrp() == mrp).findFirst().orElse(null);
|
||||
log.debug("productionMasterPlan >>>>>>>>>>>> {}", productionMasterPlan);
|
||||
|
||||
log.debug("productionMasterPlan >>>>>>>>>>>> {}" , productionMasterPlan);
|
||||
if (productionMasterPlan != null) {
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,50 +1,34 @@
|
||||
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()));
|
||||
public static void main(String[] args) throws IOException {
|
||||
String s = null;
|
||||
|
||||
BufferedReader stdError = new BufferedReader(new
|
||||
InputStreamReader(p.getErrorStream()));
|
||||
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()));
|
||||
|
||||
// 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ public class StockMoveProductionServiceImpl extends StockMoveServiceSupplychainI
|
||||
|
||||
@Override
|
||||
public void checkExpirationDates(StockMove stockMove) throws AxelorException {
|
||||
if (stockMove.getInManufOrder() != null) {
|
||||
stockMoveLineService.checkExpirationDates(stockMove);
|
||||
} else {
|
||||
super.checkExpirationDates(stockMove);
|
||||
}
|
||||
// if (stockMove.getInManufOrder() != null) {
|
||||
// stockMoveLineService.checkExpirationDates(stockMove);
|
||||
// } else {
|
||||
super.checkExpirationDates(stockMove);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,10 @@ public interface ManufOrderService {
|
||||
|
||||
public void createToConsumeProdProductList(ManufOrder manufOrder);
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public StockMove createToConsumeProdProductList(ManufOrder manufOrder, int size)
|
||||
throws AxelorException;
|
||||
|
||||
/**
|
||||
* Compute the quantity on generated prod product line. If the quantity of the bill of material is
|
||||
* equal to the quantity of manuf order then the prod product line will have the same quantity as
|
||||
@@ -239,4 +243,7 @@ public interface ManufOrderService {
|
||||
* @return the query.
|
||||
*/
|
||||
public String getBuildingQtyForAProduct(Long productId, Long companyId, Long stockLocationId);
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public StockMove createOutgoinfStockMove(ManufOrder manufOrder) throws AxelorException;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,6 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
}
|
||||
|
||||
Company company = billOfMaterial.getCompany();
|
||||
|
||||
|
||||
// BigDecimal bomQty = billOfMaterial.getQty();
|
||||
// BigDecimal qty = qtyRequested.divide(bomQty, 0, RoundingMode.CEILING).multiply(bomQty);
|
||||
@@ -150,6 +149,100 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public StockMove createToConsumeProdProductList(ManufOrder manufOrder, int times)
|
||||
throws AxelorException {
|
||||
|
||||
BigDecimal manufOrderQty = manufOrder.getQty();
|
||||
|
||||
BillOfMaterial billOfMaterial = manufOrder.getBillOfMaterial();
|
||||
|
||||
BigDecimal bomQty = billOfMaterial.getQty();
|
||||
|
||||
StockMove stockMove =
|
||||
Beans.get(ManufOrderStockMoveService.class)
|
||||
._createToConsumeStockMove(manufOrder, manufOrder.getCompany());
|
||||
|
||||
if (billOfMaterial.getBillOfMaterialSet() != null) {
|
||||
|
||||
for (BillOfMaterial billOfMaterialLine :
|
||||
getSortedBillsOfMaterials(billOfMaterial.getBillOfMaterialSet())) {
|
||||
|
||||
if (!billOfMaterialLine.getHasNoManageStock()) {
|
||||
|
||||
Product product =
|
||||
productVariantService.getProductVariant(
|
||||
manufOrder.getProduct(), billOfMaterialLine.getProduct());
|
||||
|
||||
BigDecimal qty =
|
||||
computeToConsumeProdProductLineQuantity(
|
||||
bomQty, manufOrderQty, billOfMaterialLine.getQty())
|
||||
.multiply(new BigDecimal(times));
|
||||
|
||||
ProdProduct prodProduct = new ProdProduct(product, qty, billOfMaterialLine.getUnit());
|
||||
StockMoveLine stockMoveline =
|
||||
Beans.get(ManufOrderStockMoveService.class)
|
||||
._createStockMoveLine(
|
||||
prodProduct, stockMove, StockMoveLineService.TYPE_IN_PRODUCTIONS);
|
||||
stockMove.addStockMoveLineListItem(stockMoveline);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Beans.get(StockMoveRepository.class).save(stockMove);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public StockMove createOutgoinfStockMove(ManufOrder manufOrder) throws AxelorException {
|
||||
|
||||
BigDecimal manufOrderQty = manufOrder.getQty();
|
||||
BillOfMaterial billOfMaterial = manufOrder.getBillOfMaterial();
|
||||
BigDecimal bomQty = billOfMaterial.getQty();
|
||||
|
||||
StockConfigProductionService stockConfigService = Beans.get(StockConfigProductionService.class);
|
||||
StockConfig stockConfig = stockConfigService.getStockConfig(manufOrder.getCompany());
|
||||
StockLocation virtualStockLocation =
|
||||
stockConfigService.getProductionVirtualStockLocation(stockConfig);
|
||||
|
||||
StockMove stockMove =
|
||||
Beans.get(ManufOrderStockMoveService.class)
|
||||
._createToConsumeStockMove(manufOrder, manufOrder.getCompany());
|
||||
|
||||
stockMove.setPartner(manufOrder.getCompany().getPartner());
|
||||
stockMove.setTypeSelect(StockMoveRepository.TYPE_OUTGOING);
|
||||
stockMove.setFromStockLocation(manufOrder.getWorkshopStockLocation());
|
||||
stockMove.setToStockLocation(virtualStockLocation);
|
||||
|
||||
if (billOfMaterial.getBillOfMaterialSet() != null) {
|
||||
|
||||
for (BillOfMaterial billOfMaterialLine :
|
||||
getSortedBillsOfMaterials(billOfMaterial.getBillOfMaterialSet())) {
|
||||
|
||||
if (!billOfMaterialLine.getHasNoManageStock()) {
|
||||
|
||||
Product product =
|
||||
productVariantService.getProductVariant(
|
||||
manufOrder.getProduct(), billOfMaterialLine.getProduct());
|
||||
|
||||
BigDecimal qty =
|
||||
computeToConsumeProdProductLineQuantity(
|
||||
bomQty, manufOrderQty, billOfMaterialLine.getQty());
|
||||
|
||||
ProdProduct prodProduct = new ProdProduct(product, qty, billOfMaterialLine.getUnit());
|
||||
StockMoveLine stockMoveline =
|
||||
Beans.get(ManufOrderStockMoveService.class)
|
||||
._createStockMoveLine(
|
||||
prodProduct, stockMove, StockMoveLineService.TYPE_IN_PRODUCTIONS);
|
||||
stockMove.addStockMoveLineListItem(stockMoveline);
|
||||
manufOrder.addConsumedStockMoveLineListItem(stockMoveline);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Beans.get(StockMoveRepository.class).save(stockMove);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void createToConsumeProdProductList(ManufOrder manufOrder) {
|
||||
|
||||
BigDecimal manufOrderQty = manufOrder.getQty();
|
||||
@@ -180,6 +273,38 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
public void createToConsumeProdProductListFromSelectedManufOrder(
|
||||
List<ManufOrder> manufOrderList) {
|
||||
|
||||
BigDecimal manufOrderQty =
|
||||
manufOrderList.stream().map(ManufOrder::getQty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
BillOfMaterial billOfMaterial = manufOrderList.get(0).getBillOfMaterial();
|
||||
|
||||
BigDecimal bomQty = billOfMaterial.getQty();
|
||||
|
||||
if (billOfMaterial.getBillOfMaterialSet() != null) {
|
||||
|
||||
for (BillOfMaterial billOfMaterialLine :
|
||||
getSortedBillsOfMaterials(billOfMaterial.getBillOfMaterialSet())) {
|
||||
|
||||
if (!billOfMaterialLine.getHasNoManageStock()) {
|
||||
|
||||
Product product =
|
||||
productVariantService.getProductVariant(
|
||||
manufOrderList.get(0).getProduct(), billOfMaterialLine.getProduct());
|
||||
|
||||
BigDecimal qty =
|
||||
computeToConsumeProdProductLineQuantity(
|
||||
bomQty, manufOrderQty, billOfMaterialLine.getQty());
|
||||
ProdProduct prodProduct = new ProdProduct(product, qty, billOfMaterialLine.getUnit());
|
||||
manufOrderList.get(0).addToConsumeProdProductListItem(prodProduct);
|
||||
prodProductRepo.persist(prodProduct); // id by order of creation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal computeToConsumeProdProductLineQuantity(
|
||||
BigDecimal bomQty, BigDecimal manufOrderQty, BigDecimal lineQty) {
|
||||
@@ -294,11 +419,11 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
}
|
||||
|
||||
if (!manufOrder.getIsConsProOnOperation()) {
|
||||
//bachir temp
|
||||
// bachir temp
|
||||
// this.createToConsumeProdProductList(manufOrder);
|
||||
}
|
||||
|
||||
//bachir temp
|
||||
// bachir temp
|
||||
// this.createToProduceProdProductList(manufOrder);
|
||||
|
||||
return manufOrder;
|
||||
@@ -328,10 +453,12 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
if(manufOrder.getBillOfMaterial() != null){
|
||||
if (manufOrder.getBillOfMaterial() != null) {
|
||||
for (BillOfMaterial bom : manufOrder.getBillOfMaterial().getBillOfMaterialSet()) {
|
||||
BillOfMaterialConsumption newBom = Beans.get(BillOfMaterialServiceImpl.class).createBomConsumptionFromRawMaterial(bom);
|
||||
manufOrder.addBillOfMaterialConsumptionListItem(newBom);
|
||||
BillOfMaterialConsumption newBom =
|
||||
Beans.get(BillOfMaterialServiceImpl.class)
|
||||
.createBomConsumptionFromRawMaterial(bom, manufOrder);
|
||||
manufOrder.addBillOfMaterialConsumptionListItem(newBom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,6 +466,10 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
|
||||
manufOrder.setPlannedEndDateT(manufOrderWorkflowService.computePlannedEndDateT(manufOrder));
|
||||
|
||||
System.out.println("***************************");
|
||||
System.out.println("yessssssssssssssssss");
|
||||
System.out.println("***************************");
|
||||
|
||||
manufOrderRepo.save(manufOrder);
|
||||
}
|
||||
|
||||
@@ -373,6 +504,10 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
productionConfigService.getManufOrderSequence(
|
||||
productionConfig, manufOrder.getWorkshopStockLocation());
|
||||
|
||||
if (manufOrder.getStypeSelect() == ManufOrderRepository.STYPE_PACKAGING_ORDER) {
|
||||
sequence = productionConfig.getPackagingOrderSequence();
|
||||
}
|
||||
|
||||
String seq = sequenceService.getSequenceNumber(sequence);
|
||||
|
||||
if (seq == null) {
|
||||
@@ -618,12 +753,13 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
if (stockMoveOpt.isPresent()) {
|
||||
stockMove = stockMoveOpt.get();
|
||||
} else {
|
||||
stockMove =
|
||||
manufOrderStockMoveService._createToConsumeStockMove(manufOrder, manufOrder.getCompany());
|
||||
manufOrder.addInStockMoveListItem(stockMove);
|
||||
Beans.get(StockMoveService.class).plan(stockMove);
|
||||
// stockMove =
|
||||
// manufOrderStockMoveService._createToConsumeStockMove(manufOrder,
|
||||
// manufOrder.getCompany());
|
||||
// manufOrder.addInStockMoveListItem(stockMove);
|
||||
// Beans.get(StockMoveService.class).plan(stockMove);
|
||||
}
|
||||
updateStockMoveFromManufOrder(consumedStockMoveLineList, stockMove);
|
||||
// updateStockMoveFromManufOrder(consumedStockMoveLineList, stockMove);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -741,11 +877,11 @@ public class ManufOrderServiceImpl implements ManufOrderService {
|
||||
.convert(
|
||||
stockMoveLine.getUnit(),
|
||||
prodProduct.getUnit(),
|
||||
stockMoveLine.getQty(),
|
||||
stockMoveLine.getQty().scale(),
|
||||
stockMoveLine.getRealQty(),
|
||||
stockMoveLine.getRealQty().scale(),
|
||||
product));
|
||||
} else {
|
||||
consumedQty = consumedQty.add(stockMoveLine.getQty());
|
||||
consumedQty = consumedQty.add(stockMoveLine.getRealQty());
|
||||
}
|
||||
}
|
||||
return consumedQty.subtract(prodProduct.getQty());
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.axelor.apps.production.service.manuforder;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
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;
|
||||
@@ -33,6 +34,7 @@ import com.axelor.apps.stock.db.StockConfig;
|
||||
import com.axelor.apps.stock.db.StockLocation;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockMoveLine;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveLineRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveRepository;
|
||||
import com.axelor.apps.stock.service.StockMoveLineService;
|
||||
import com.axelor.apps.stock.service.StockMoveService;
|
||||
@@ -49,6 +51,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -92,7 +95,34 @@ public class ManufOrderStockMoveService {
|
||||
// case where we had to split tracked stock move lines
|
||||
if (stockMove.getStockMoveLineList() != null) {
|
||||
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
|
||||
manufOrder.addConsumedStockMoveLineListItem(stockMoveLine);
|
||||
manufOrder.addTransferedStockMoveLineListItem(stockMoveLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void createToTransferStockMove(ManufOrder manufOrder) throws AxelorException {
|
||||
Company company = manufOrder.getCompany();
|
||||
|
||||
if (manufOrder.getToConsumeProdProductList() != null && company != null) {
|
||||
|
||||
StockMove stockMove = this._createToConsumeStockMove(manufOrder, company);
|
||||
|
||||
for (ProdProduct prodProduct : manufOrder.getToConsumeProdProductList()) {
|
||||
|
||||
this._createStockMoveLine(prodProduct, stockMove, StockMoveLineService.TYPE_IN_PRODUCTIONS);
|
||||
}
|
||||
|
||||
if (stockMove.getStockMoveLineList() != null && !stockMove.getStockMoveLineList().isEmpty()) {
|
||||
stockMoveService.plan(stockMove);
|
||||
manufOrder.addInStockMoveListItem(stockMove);
|
||||
}
|
||||
|
||||
// fill here the consumed stock move line list item to manage the
|
||||
// case where we had to split tracked stock move lines
|
||||
if (stockMove.getStockMoveLineList() != null) {
|
||||
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
|
||||
manufOrder.addTransferedStockMoveLineListItem(stockMoveLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,8 +144,8 @@ public class ManufOrderStockMoveService {
|
||||
null,
|
||||
null,
|
||||
company,
|
||||
fromStockLocation,
|
||||
virtualStockLocation,
|
||||
manufOrder.getProdProcess().getStockLocation(),
|
||||
manufOrder.getWorkshopStockLocation(),
|
||||
null,
|
||||
manufOrder.getPlannedStartDateT().toLocalDate(),
|
||||
null,
|
||||
@@ -205,6 +235,9 @@ public class ManufOrderStockMoveService {
|
||||
|
||||
if (stockMove.getStockMoveLineList() != null) {
|
||||
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
|
||||
if (manufOrder.getTrackingNumber() != null) {
|
||||
stockMoveLine.setTrackingNumber(manufOrder.getTrackingNumber());
|
||||
}
|
||||
manufOrder.addProducedStockMoveLineListItem(stockMoveLine);
|
||||
}
|
||||
}
|
||||
@@ -219,7 +252,52 @@ public class ManufOrderStockMoveService {
|
||||
*/
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void consumeInStockMoves(ManufOrder manufOrder) throws AxelorException {
|
||||
StockConfigProductionService stockConfigService = Beans.get(StockConfigProductionService.class);
|
||||
StockConfig stockConfig = stockConfigService.getStockConfig(manufOrder.getCompany());
|
||||
StockLocation virtualStockLocation =
|
||||
stockConfigService.getProductionVirtualStockLocation(stockConfig);
|
||||
|
||||
for (StockMove stockMove : manufOrder.getInStockMoveList()) {
|
||||
if (stockMove.getStatusSelect() == StockMoveRepository.STATUS_REALIZED) {
|
||||
StockMove move = Beans.get(StockMoveRepository.class).copy(stockMove, true);
|
||||
move.setPartner(manufOrder.getCompany().getPartner());
|
||||
move.setTypeSelect(StockMoveRepository.TYPE_OUTGOING);
|
||||
move.setFromStockLocation(manufOrder.getWorkshopStockLocation());
|
||||
move.setToStockLocation(virtualStockLocation);
|
||||
// move.setInManufOrder(null);
|
||||
move.setOutManufOrder(manufOrder);
|
||||
Beans.get(StockMoveRepository.class).save(move);
|
||||
if (move.getStockMoveLineList() != null) {
|
||||
for (StockMoveLine stockMoveLine : move.getStockMoveLineList()) {
|
||||
stockMoveLine.setTransferedManufOrder(null);
|
||||
stockMoveLine.setConsumedManufOrder(manufOrder);
|
||||
manufOrder.addConsumedStockMoveLineListItem(stockMoveLine);
|
||||
}
|
||||
}
|
||||
// stockMoveService.plan(move);
|
||||
}
|
||||
finishStockMove(stockMove);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void validateOutStockMoves(ManufOrder manufOrder) throws AxelorException {
|
||||
|
||||
for (StockMove stockMove : manufOrder.getOutStockMoveList()) {
|
||||
System.out.println("***************************");
|
||||
System.out.println(stockMove.getStockMoveSeq());
|
||||
stockMoveService.plan(stockMove);
|
||||
finishStockMove(stockMove);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void validateInStockMoves(ManufOrder manufOrder) throws AxelorException {
|
||||
|
||||
for (StockMove stockMove : manufOrder.getInStockMoveList()) {
|
||||
System.out.println("***************************");
|
||||
System.out.println(stockMove.getStockMoveSeq());
|
||||
stockMoveService.plan(stockMove);
|
||||
finishStockMove(stockMove);
|
||||
}
|
||||
}
|
||||
@@ -270,7 +348,7 @@ public class ManufOrderStockMoveService {
|
||||
return stockMove;
|
||||
}
|
||||
|
||||
protected StockMoveLine _createStockMoveLine(
|
||||
public StockMoveLine _createStockMoveLine(
|
||||
ProdProduct prodProduct, StockMove stockMove, int inOrOutType) throws AxelorException {
|
||||
|
||||
return _createStockMoveLine(prodProduct, stockMove, inOrOutType, prodProduct.getQty());
|
||||
@@ -318,9 +396,11 @@ public class ManufOrderStockMoveService {
|
||||
for (StockMove stockMove : manufOrder.getInStockMoveList()) {
|
||||
this.finishStockMove(stockMove);
|
||||
}
|
||||
for (StockMove stockMove : manufOrder.getOutStockMoveList()) {
|
||||
updateRealPrice(manufOrder, stockMove);
|
||||
this.finishStockMove(stockMove);
|
||||
if (manufOrder.getStypeSelect() == ManufOrderRepository.STYPE_PACKAGING_ORDER) {
|
||||
for (StockMove stockMove : manufOrder.getOutStockMoveList()) {
|
||||
updateRealPrice(manufOrder, stockMove);
|
||||
// this.finishStockMove(stockMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +427,7 @@ public class ManufOrderStockMoveService {
|
||||
|
||||
if (stockMove != null && stockMove.getStatusSelect() == StockMoveRepository.STATUS_PLANNED) {
|
||||
stockMove.setIsWithBackorder(false);
|
||||
stockMoveService.copyQtyToRealQty(stockMove);
|
||||
// stockMoveService.copyQtyToRealQty(stockMove);
|
||||
stockMoveService.realize(stockMove);
|
||||
}
|
||||
}
|
||||
@@ -393,7 +473,7 @@ public class ManufOrderStockMoveService {
|
||||
|
||||
StockLocation fromStockLocation;
|
||||
StockLocation toStockLocation;
|
||||
List<StockMove> stockMoveList;
|
||||
Set<StockMove> stockMoveList;
|
||||
|
||||
if (inOrOut == PART_FINISH_IN) {
|
||||
stockMoveList = manufOrder.getInStockMoveList();
|
||||
@@ -455,6 +535,13 @@ public class ManufOrderStockMoveService {
|
||||
* ManufOrder#outStockMoveList}
|
||||
* @return an optional stock move
|
||||
*/
|
||||
public Optional<StockMove> getPlannedStockMove(Set<StockMove> stockMoveList) {
|
||||
return stockMoveList
|
||||
.stream()
|
||||
.filter(stockMove -> stockMove.getStatusSelect() == StockMoveRepository.STATUS_PLANNED)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
public Optional<StockMove> getPlannedStockMove(List<StockMove> stockMoveList) {
|
||||
return stockMoveList
|
||||
.stream()
|
||||
@@ -533,6 +620,7 @@ public class ManufOrderStockMoveService {
|
||||
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
|
||||
|
||||
stockMoveLine.setProducedManufOrder(null);
|
||||
stockMoveLine.setTransferedManufOrder(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -562,6 +650,13 @@ public class ManufOrderStockMoveService {
|
||||
stockMoveLine ->
|
||||
stockMoveLine.getStockMove().getStatusSelect()
|
||||
== StockMoveRepository.STATUS_CANCELED);
|
||||
// clear all lists from planned lines
|
||||
manufOrder
|
||||
.getTransferedStockMoveLineList()
|
||||
.removeIf(
|
||||
stockMoveLine ->
|
||||
stockMoveLine.getStockMove().getStatusSelect()
|
||||
== StockMoveRepository.STATUS_CANCELED);
|
||||
stockMove.clearStockMoveLineList();
|
||||
|
||||
// create a new list
|
||||
@@ -641,4 +736,84 @@ public class ManufOrderStockMoveService {
|
||||
|
||||
return qtyToUpdate.multiply(prodProductQty).divide(manufOrderQty, 2, RoundingMode.HALF_EVEN);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void createToReturnStockMove(ManufOrder manufOrder) throws AxelorException {
|
||||
|
||||
Company company = manufOrder.getCompany();
|
||||
|
||||
if (manufOrder.getConsumedStockMoveLineList() != null && company != null) {
|
||||
StockMove outStockMove = manufOrder.getConsumedStockMoveLineList().get(0).getStockMove();
|
||||
|
||||
StockMove stockMove = Beans.get(StockMoveRepository.class).copy(outStockMove, false);
|
||||
StockLocation fromLocation = manufOrder.getWorkshopStockLocation();
|
||||
StockLocation toLocation = manufOrder.getProdProcess().getStockLocation();
|
||||
stockMove.setFromStockLocation(fromLocation);
|
||||
stockMove.setToStockLocation(toLocation);
|
||||
stockMove.setPartner(null);
|
||||
stockMove.setTypeSelect(StockMoveRepository.TYPE_INTERNAL);
|
||||
|
||||
for (StockMoveLine stockMoveLine : manufOrder.getConsumedStockMoveLineList()) {
|
||||
BigDecimal diff = stockMoveLine.getQty().subtract(stockMoveLine.getRealQty());
|
||||
StockMoveLine stockMoveLine2 =
|
||||
Beans.get(StockMoveLineRepository.class).copy(stockMoveLine, false);
|
||||
|
||||
if (diff.compareTo(BigDecimal.ZERO) > 0) {
|
||||
stockMoveLine2.setQty(diff);
|
||||
stockMoveLine2.setRealQty(diff);
|
||||
stockMoveLine2.setConsumedManufOrder(null);
|
||||
stockMoveLine2.setReturnedManufOrder(manufOrder);
|
||||
stockMove.addStockMoveLineListItem(stockMoveLine2);
|
||||
}
|
||||
}
|
||||
|
||||
stockMoveService.plan(stockMove);
|
||||
manufOrder.addOutStockMoveListItem(stockMove);
|
||||
|
||||
// fill here the consumed stock move line list item to manage the
|
||||
// case where we had to split tracked stock move lines
|
||||
if (stockMove.getStockMoveLineList() != null) {
|
||||
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
|
||||
stockMoveLine.setConsumedManufOrder(null);
|
||||
manufOrder.addToReturnStockMoveLineListItem(stockMoveLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void createTempStockMove(ManufOrder manufOrder) throws AxelorException {
|
||||
StockMove stockMove = this._createToConsumeStockMove(manufOrder, manufOrder.getCompany());
|
||||
stockMove.setTypeSelect(StockMoveRepository.TYPE_OUTGOING);
|
||||
stockMove.setFromStockLocation(manufOrder.getWorkshopStockLocation());
|
||||
StockConfigProductionService stockConfigService = Beans.get(StockConfigProductionService.class);
|
||||
StockConfig stockConfig = stockConfigService.getStockConfig(manufOrder.getCompany());
|
||||
StockLocation virtualStockLocation =
|
||||
stockConfigService.getProductionVirtualStockLocation(stockConfig);
|
||||
stockMove.setToStockLocation(virtualStockLocation);
|
||||
stockMove.setPartner(manufOrder.getCompany().getPartner());
|
||||
for (BillOfMaterialConsumption billOfMaterialConsumption : manufOrder.getBillOfMaterialConsumptionList()) {
|
||||
StockMoveLine stockMoveLine = stockMoveLineService.createStockMoveLine(
|
||||
billOfMaterialConsumption.getProduct(),
|
||||
billOfMaterialConsumption.getProduct().getName(),
|
||||
billOfMaterialConsumption.getProduct().getDescription(),
|
||||
billOfMaterialConsumption.getRealQty(),
|
||||
BigDecimal.ZERO,
|
||||
BigDecimal.ZERO,
|
||||
billOfMaterialConsumption.getProduct().getUnit(),
|
||||
stockMove,
|
||||
StockMoveLineService.TYPE_OUT_PRODUCTIONS,
|
||||
false,
|
||||
BigDecimal.ZERO);
|
||||
stockMoveLine.setTrackingNumber(billOfMaterialConsumption.getTrackingNumber());
|
||||
stockMove.addStockMoveLineListItem(stockMoveLine);
|
||||
}
|
||||
|
||||
if (stockMove.getStockMoveLineList() != null && !stockMove.getStockMoveLineList().isEmpty()) {
|
||||
stockMoveService.plan(stockMove);
|
||||
manufOrder.addOutStockMoveListItem(stockMove);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,20 +26,30 @@ import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.message.db.Template;
|
||||
import com.axelor.apps.message.db.repo.EmailAccountRepository;
|
||||
import com.axelor.apps.message.service.TemplateMessageService;
|
||||
import com.axelor.apps.production.db.BillOfMaterial;
|
||||
import com.axelor.apps.production.db.BillOfMaterialConsumption;
|
||||
import com.axelor.apps.production.db.DocumentationManufOrder;
|
||||
import com.axelor.apps.production.db.ManufOrder;
|
||||
import com.axelor.apps.production.db.OperationOrder;
|
||||
import com.axelor.apps.production.db.ProdProcess;
|
||||
import com.axelor.apps.production.db.ProdProcessLine;
|
||||
import com.axelor.apps.production.db.ProductionConfig;
|
||||
import com.axelor.apps.production.db.repo.BillOfMaterialRepository;
|
||||
import com.axelor.apps.production.db.repo.CostSheetRepository;
|
||||
import com.axelor.apps.production.db.repo.DocumentationManufOrderRepository;
|
||||
import com.axelor.apps.production.db.repo.ManufOrderRepository;
|
||||
import com.axelor.apps.production.db.repo.OperationOrderRepository;
|
||||
import com.axelor.apps.production.db.repo.ProdProcessRepository;
|
||||
import com.axelor.apps.production.db.repo.ProductionConfigRepository;
|
||||
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.costsheet.CostSheetService;
|
||||
import com.axelor.apps.production.service.operationorder.OperationOrderService;
|
||||
import com.axelor.apps.production.service.operationorder.OperationOrderWorkflowService;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.TrackingNumber;
|
||||
import com.axelor.apps.stock.db.repo.TrackingNumberRepository;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
@@ -49,8 +59,11 @@ import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -101,11 +114,16 @@ public class ManufOrderWorkflowService {
|
||||
}
|
||||
if (!manufOrder.getIsConsProOnOperation()
|
||||
&& CollectionUtils.isEmpty(manufOrder.getToConsumeProdProductList())) {
|
||||
// manufOrderService.createToConsumeProdProductList(manufOrder);
|
||||
manufOrderService.createToConsumeProdProductList(manufOrder);
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"*********************************************CollectionUtils.isEmpty(manufOrder.getToProduceProdProductList())");
|
||||
System.out.println(CollectionUtils.isEmpty(manufOrder.getToProduceProdProductList()));
|
||||
System.out.println(
|
||||
"*********************************************CollectionUtils.isEmpty(manufOrder.getToProduceProdProductList())");
|
||||
if (CollectionUtils.isEmpty(manufOrder.getToProduceProdProductList())) {
|
||||
// manufOrderService.createToProduceProdProductList(manufOrder);
|
||||
manufOrderService.createToProduceProdProductList(manufOrder);
|
||||
}
|
||||
|
||||
if (manufOrder.getPlannedStartDateT() == null && manufOrder.getPlannedEndDateT() == null) {
|
||||
@@ -132,11 +150,21 @@ public class ManufOrderWorkflowService {
|
||||
manufOrder.setUnit(manufOrder.getBillOfMaterial().getUnit());
|
||||
}
|
||||
|
||||
if (!manufOrder.getIsConsProOnOperation()) {
|
||||
// manufOrderStockMoveService.createToConsumeStockMove(manufOrder);
|
||||
// if (!manufOrder.getIsConsProOnOperation()) {
|
||||
System.out.println("manufOrder<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
|
||||
System.out.println();
|
||||
System.out.println(manufOrder);
|
||||
System.out.println(manufOrder.getStypeSelect());
|
||||
System.out.println("manufOrder<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
|
||||
if (manufOrder.getStypeSelect() == ManufOrderRepository.STYPE_PACKAGING_ORDER) {
|
||||
manufOrderStockMoveService.createToConsumeStockMove(manufOrder);
|
||||
}
|
||||
manufOrderService.createOutgoinfStockMove(manufOrder);
|
||||
// }
|
||||
|
||||
manufOrderStockMoveService.createToProduceStockMove(manufOrder);
|
||||
if (manufOrder.getStypeSelect() == ManufOrderRepository.STYPE_PACKAGING_ORDER) {
|
||||
manufOrderStockMoveService.createToProduceStockMove(manufOrder);
|
||||
}
|
||||
manufOrder.setStatusSelect(ManufOrderRepository.STATUS_PLANNED);
|
||||
manufOrder.setCancelReason(null);
|
||||
manufOrder.setCancelReasonStr(null);
|
||||
@@ -147,15 +175,30 @@ 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);
|
||||
if (!stockMove.getIsValidatedProduction()) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_NOT_VALIDATED));
|
||||
}
|
||||
manufOrderStockMoveService.finishStockMove(stockMove);
|
||||
}
|
||||
}
|
||||
|
||||
if (manufOrder.getBillOfMaterial() != null) {
|
||||
for (BillOfMaterial bom : manufOrder.getBillOfMaterial().getBillOfMaterialSet()) {
|
||||
BillOfMaterialConsumption newBom =
|
||||
Beans.get(BillOfMaterialServiceImpl.class)
|
||||
.createBomConsumptionFromRawMaterial(bom, manufOrder);
|
||||
manufOrder.addBillOfMaterialConsumptionListItem(newBom);
|
||||
}
|
||||
}
|
||||
|
||||
manufOrder.setStatusSelect(ManufOrderRepository.STATUS_IN_PROGRESS);
|
||||
manufOrderRepo.save(manufOrder);
|
||||
}
|
||||
@@ -234,8 +277,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(
|
||||
@@ -325,6 +368,11 @@ public class ManufOrderWorkflowService {
|
||||
.getProducedStockMoveLineList()
|
||||
.forEach(stockMoveLine -> stockMoveLine.setProducedManufOrder(null));
|
||||
}
|
||||
if (manufOrder.getTransferedStockMoveLineList() != null) {
|
||||
manufOrder
|
||||
.getTransferedStockMoveLineList()
|
||||
.forEach(stockMoveLine -> stockMoveLine.setTransferedManufOrder(null));
|
||||
}
|
||||
if (manufOrder.getDiffConsumeProdProductList() != null) {
|
||||
manufOrder.clearDiffConsumeProdProductList();
|
||||
}
|
||||
@@ -449,4 +497,108 @@ public class ManufOrderWorkflowService {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public Long createDocumentationManufOrder(ManufOrder manufOrder) throws AxelorException {
|
||||
DocumentationManufOrder documentationManufOrder = new DocumentationManufOrder();
|
||||
documentationManufOrder.setStatusSelect(1);
|
||||
documentationManufOrder.setProduct(manufOrder.getProduct());
|
||||
documentationManufOrder.setTrackingNumber(manufOrder.getTrackingNumber());
|
||||
documentationManufOrder.setManufOrder(manufOrder);
|
||||
|
||||
ProdProcess prodProcess = Beans.get(ProdProcessRepository.class).findByName("DOCUMENTATION");
|
||||
|
||||
for (ProdProcessLine prodProcessLine :
|
||||
Beans.get(ManufOrderServiceImpl.class)
|
||||
._sortProdProcessLineByPriority(prodProcess.getProdProcessLineList())) {
|
||||
documentationManufOrder.addOperationOrderListItem(
|
||||
Beans.get(OperationOrderService.class).createOperationOrder(manufOrder, prodProcessLine));
|
||||
}
|
||||
|
||||
DocumentationManufOrder savedocumentationManufOrder =
|
||||
Beans.get(DocumentationManufOrderRepository.class).save(documentationManufOrder);
|
||||
return savedocumentationManufOrder.getId();
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public Long createPackagingOrder(ManufOrder manufOrder) throws AxelorException {
|
||||
|
||||
ManufOrderService manufOrderService = Beans.get(ManufOrderService.class);
|
||||
// ProdProcess prodProcess = Beans.get(ProdProcessRepository.class).all().filter("self.product =
|
||||
// ?1 and self.typeSelect = ?2",manufOrder.getProduct(),
|
||||
// ManufOrderRepository.STYPE_PACKAGING_ORDER).fetchOne();
|
||||
BillOfMaterial billOfMaterial =
|
||||
Beans.get(BillOfMaterialRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.product = ?1 and self.typeSelect = ?2",
|
||||
manufOrder.getProduct(),
|
||||
ManufOrderRepository.STYPE_PACKAGING_ORDER)
|
||||
.fetchOne();
|
||||
|
||||
ManufOrder packagingOrder =
|
||||
manufOrderService.generateManufOrder(
|
||||
manufOrder.getProduct(),
|
||||
manufOrder.getQty(),
|
||||
ManufOrderService.DEFAULT_PRIORITY,
|
||||
ManufOrderService.IS_TO_INVOICE,
|
||||
billOfMaterial,
|
||||
manufOrder.getRealEndDateT(),
|
||||
null,
|
||||
ManufOrderService.ORIGIN_TYPE_OTHER);
|
||||
|
||||
packagingOrder.setTrackingNumber(manufOrder.getTrackingNumber());
|
||||
packagingOrder.setStypeSelect(ManufOrderRepository.STYPE_PACKAGING_ORDER);
|
||||
packagingOrder.setOriginManufOrder(manufOrder);
|
||||
packagingOrder.setProductionOrder(manufOrder.getProductionOrder());
|
||||
|
||||
ManufOrder packOrder = Beans.get(ManufOrderRepository.class).save(packagingOrder);
|
||||
|
||||
return packOrder.getId();
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void createAndAssignTrackingNumber(OperationOrder operationOrder) throws AxelorException {
|
||||
|
||||
ManufOrderService manufOrderService = Beans.get(ManufOrderService.class);
|
||||
// Optional<OperationOrder> operationOrder1 =
|
||||
// manufOrder.getOperationOrderList().stream().filter(op
|
||||
// ->op.getOperationName().equals("MELANGE")).findFirst();
|
||||
// Optional<OperationOrder> operationOrder2 =
|
||||
// manufOrder.getOperationOrderList().stream().filter(op
|
||||
// ->op.getOperationName().equals("GRANULATION")).findFirst();
|
||||
// ProdProcess prodProcess = Beans.get(ProdProcessRepository.class).all().filter("self.product =
|
||||
// ?1 and self.typeSelect = ?2",manufOrder.getProduct(),
|
||||
// ManufOrderRepository.STYPE_PACKAGING_ORDER).fetchOne();
|
||||
ManufOrder manufOrder = operationOrder.getManufOrder();
|
||||
BillOfMaterial billOfMaterial = manufOrder.getBillOfMaterial();
|
||||
Product product = billOfMaterial.getProduct();
|
||||
Integer lifeTime = billOfMaterial.getProductLifeTimeInMonth();
|
||||
Integer seq = billOfMaterial.getProducedTrackingNumberSeq();
|
||||
String workShopName = billOfMaterial.getWorkshopStockLocation().getName();
|
||||
String lastYear = String.valueOf(LocalDate.now().getYear()).substring(2);
|
||||
String workShopCode = "";
|
||||
if (workShopName.length() >= 6) {
|
||||
workShopCode = Character.toString(workShopName.charAt(5));
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat("000");
|
||||
String formattedseq = df.format(seq);
|
||||
|
||||
String sequence = workShopCode + lastYear + formattedseq;
|
||||
|
||||
LocalDate perishableDate =
|
||||
LocalDate.now().plusMonths(lifeTime).with(TemporalAdjusters.lastDayOfMonth());
|
||||
|
||||
TrackingNumber trackingNumber = new TrackingNumber();
|
||||
trackingNumber.setProduct(product);
|
||||
trackingNumber.setPerishableExpirationDate(perishableDate);
|
||||
trackingNumber.setTrackingNumberSeq(sequence);
|
||||
manufOrder.setTrackingNumber(Beans.get(TrackingNumberRepository.class).save(trackingNumber));
|
||||
|
||||
Integer nextSeq = billOfMaterial.getProducedTrackingNumberSeq() + 1;
|
||||
billOfMaterial.setProducedTrackingNumberSeq(nextSeq);
|
||||
Beans.get(BillOfMaterialRepository.class).save(billOfMaterial);
|
||||
Beans.get(ManufOrderRepository.class).save(manufOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,10 @@ public class OperationOrderServiceImpl implements OperationOrderService {
|
||||
OperationOrderRepository.STATUS_DRAFT,
|
||||
prodProcessLine);
|
||||
|
||||
operationOrder.setProduct(prodProcessLine.getProduct());
|
||||
operationOrder.setQty(prodProcessLine.getQty());
|
||||
operationOrder.setUnit(prodProcessLine.getUnit());
|
||||
|
||||
this._createHumanResourceList(operationOrder, machineWorkCenter);
|
||||
|
||||
return Beans.get(OperationOrderRepository.class).save(operationOrder);
|
||||
|
||||
@@ -92,10 +92,10 @@ public class OperationOrderWorkflowService {
|
||||
// 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,9 +261,9 @@ 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);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -23,19 +23,27 @@ import com.axelor.apps.base.service.administration.SequenceService;
|
||||
import com.axelor.apps.production.db.BillOfMaterial;
|
||||
import com.axelor.apps.production.db.ManufOrder;
|
||||
import com.axelor.apps.production.db.ProductionOrder;
|
||||
import com.axelor.apps.production.db.repo.ManufOrderRepository;
|
||||
import com.axelor.apps.production.db.repo.ProductionOrderRepository;
|
||||
import com.axelor.apps.production.exceptions.IExceptionMessage;
|
||||
import com.axelor.apps.production.service.manuforder.ManufOrderService;
|
||||
import com.axelor.apps.production.service.manuforder.ManufOrderServiceImpl;
|
||||
import com.axelor.apps.sale.db.SaleOrder;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockMoveLine;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveRepository;
|
||||
import com.axelor.apps.stock.service.StockMoveService;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
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 java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -127,13 +135,11 @@ public class ProductionOrderServiceImpl implements ProductionOrderService {
|
||||
int originType)
|
||||
throws AxelorException {
|
||||
|
||||
|
||||
BigDecimal bomQty = billOfMaterial.getQty();
|
||||
BigDecimal manufCount = qtyRequested.divide(bomQty, 0, RoundingMode.CEILING);
|
||||
|
||||
|
||||
for (int index = 0; index < manufCount.intValue(); index++) {
|
||||
ManufOrder manufOrder =
|
||||
for (int index = 0; index < manufCount.intValue(); index++) {
|
||||
ManufOrder manufOrder =
|
||||
manufOrderService.generateManufOrder(
|
||||
product,
|
||||
bomQty,
|
||||
@@ -143,17 +149,49 @@ for (int index = 0; index < manufCount.intValue(); index++) {
|
||||
startDate,
|
||||
endDate,
|
||||
originType);
|
||||
|
||||
|
||||
if (manufOrder != null) {
|
||||
if (saleOrder != null) {
|
||||
manufOrder.setSaleOrder(saleOrder);
|
||||
manufOrder.setClientPartner(saleOrder.getClientPartner());
|
||||
}
|
||||
manufOrder.setStypeSelect(ManufOrderRepository.STYPE_MANUF_ORDER);
|
||||
productionOrder.addManufOrderListItem(manufOrder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return productionOrderRepo.save(productionOrder);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public StockMove generateConsumeStockMoveFromSelectedManufOrder(
|
||||
ProductionOrder productionOrder, List<ManufOrder> manufOrderList) throws AxelorException {
|
||||
|
||||
ManufOrder manufOrder = manufOrderList.get(0);
|
||||
StockMove stockMove =
|
||||
Beans.get(ManufOrderServiceImpl.class)
|
||||
.createToConsumeProdProductList(manufOrder, manufOrderList.size());
|
||||
|
||||
for (ManufOrder manufOrder2 : manufOrderList) {
|
||||
if (stockMove.getStockMoveLineList() != null && !stockMove.getStockMoveLineList().isEmpty()) {
|
||||
Beans.get(ManufOrderServiceImpl.class).createToConsumeProdProductList(manufOrder2);
|
||||
Beans.get(StockMoveService.class).plan(stockMove);
|
||||
}
|
||||
|
||||
if (stockMove.getStockMoveLineList() != null) {
|
||||
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
|
||||
manufOrder2.addTransferedStockMoveLineListItem(stockMoveLine);
|
||||
}
|
||||
}
|
||||
|
||||
manufOrder2.addInStockMoveListItem(stockMove);
|
||||
Beans.get(ProductionOrderRepository.class).save(productionOrder);
|
||||
}
|
||||
|
||||
stockMove.setOrigin(productionOrder.getProductionOrderSeq());
|
||||
stockMove.setOriginId(productionOrder.getId());
|
||||
stockMove.setOriginTypeSelect(StockMoveRepository.ORIGIN_PRODUCTION_ORDER);
|
||||
|
||||
return Beans.get(StockMoveRepository.class).save(stockMove);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,24 @@ package com.axelor.apps.production.web;
|
||||
|
||||
import com.axelor.apps.ReportFactory;
|
||||
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.CostSheet;
|
||||
import com.axelor.apps.production.db.DocumentationManufOrder;
|
||||
import com.axelor.apps.production.db.ManufOrder;
|
||||
import com.axelor.apps.production.db.OperationOrder;
|
||||
import com.axelor.apps.production.db.repo.BillOfMaterialConsumptionRepository;
|
||||
import com.axelor.apps.production.db.repo.CostSheetRepository;
|
||||
import com.axelor.apps.production.db.repo.ManufOrderRepository;
|
||||
import com.axelor.apps.production.exceptions.IExceptionMessage;
|
||||
import com.axelor.apps.production.report.IReport;
|
||||
import com.axelor.apps.production.service.BillOfMaterialServiceImpl;
|
||||
import com.axelor.apps.production.service.costsheet.CostSheetService;
|
||||
import com.axelor.apps.production.service.manuforder.ManufOrderService;
|
||||
import com.axelor.apps.production.service.manuforder.ManufOrderStockMoveService;
|
||||
import com.axelor.apps.production.service.manuforder.ManufOrderWorkflowService;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
import com.axelor.db.mapper.Mapper;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.i18n.I18n;
|
||||
@@ -45,7 +52,10 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.eclipse.birt.core.exception.BirtException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -107,7 +117,6 @@ public class ManufOrderController {
|
||||
response.setNotify(I18n.get(IExceptionMessage.MANUF_ORDER_EMAIL_NOT_SENT));
|
||||
}
|
||||
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
@@ -185,9 +194,7 @@ public class ManufOrderController {
|
||||
manufOrders =
|
||||
Beans.get(ManufOrderRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1",
|
||||
context.get("_ids"))
|
||||
.filter("self.id in ?1", context.get("_ids"))
|
||||
.fetch();
|
||||
}
|
||||
for (ManufOrder manufOrder : manufOrders) {
|
||||
@@ -211,9 +218,7 @@ public class ManufOrderController {
|
||||
manufOrders =
|
||||
Beans.get(ManufOrderRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1",
|
||||
context.get("_ids"))
|
||||
.filter("self.id in ?1", context.get("_ids"))
|
||||
.fetch();
|
||||
}
|
||||
for (ManufOrder manufOrder : manufOrders) {
|
||||
@@ -237,9 +242,7 @@ public class ManufOrderController {
|
||||
manufOrders =
|
||||
Beans.get(ManufOrderRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1",
|
||||
context.get("_ids"))
|
||||
.filter("self.id in ?1", context.get("_ids"))
|
||||
.fetch();
|
||||
}
|
||||
for (ManufOrder manufOrder : manufOrders) {
|
||||
@@ -263,9 +266,7 @@ public class ManufOrderController {
|
||||
manufOrders =
|
||||
Beans.get(ManufOrderRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.id in ?1",
|
||||
context.get("_ids"))
|
||||
.filter("self.id in ?1", context.get("_ids"))
|
||||
.fetch();
|
||||
}
|
||||
for (ManufOrder manufOrder : manufOrders) {
|
||||
@@ -297,6 +298,26 @@ public class ManufOrderController {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called from manuf order form on clicking realize button. Call {@link
|
||||
* ManufOrderStockMoveService#consumeInStockMoves(ManufOrder)} to consume material used in manuf
|
||||
* order.
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
public void validateOutStockMove(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
|
||||
ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
|
||||
manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
|
||||
|
||||
Beans.get(ManufOrderStockMoveService.class).validateOutStockMoves(manufOrder);
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that generate a Pdf file for an manufacturing order
|
||||
@@ -581,4 +602,186 @@ public class ManufOrderController {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void createPackagingOrder(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderId);
|
||||
|
||||
if (!Beans.get(ManufOrderWorkflowService.class).finish(manufOrder)) {
|
||||
response.setNotify(I18n.get(IExceptionMessage.MANUF_ORDER_EMAIL_NOT_SENT));
|
||||
}
|
||||
|
||||
// response.setReload(true);
|
||||
ManufOrder manufOrder2 = Beans.get(ManufOrderRepository.class).find(manufOrderId);
|
||||
if (manufOrder.getStypeSelect() == ManufOrderRepository.STYPE_MANUF_ORDER) {
|
||||
|
||||
Long packagingOrderid =
|
||||
Beans.get(ManufOrderWorkflowService.class).createPackagingOrder(manufOrder2);
|
||||
|
||||
response.setView(
|
||||
ActionView.define("Pckaging order")
|
||||
.model(ManufOrder.class.getName())
|
||||
.add("form", "manuf-order-form")
|
||||
.add("grid", "manuf-order-grid")
|
||||
.context("_showRecord", String.valueOf(packagingOrderid))
|
||||
.domain("self.id = " + packagingOrderid)
|
||||
.map());
|
||||
} else if (manufOrder2.getStypeSelect() == ManufOrderRepository.STYPE_PACKAGING_ORDER) {
|
||||
Long docManufOrderid =
|
||||
Beans.get(ManufOrderWorkflowService.class).createDocumentationManufOrder(manufOrder2);
|
||||
|
||||
response.setView(
|
||||
ActionView.define("Documentation order")
|
||||
.model(DocumentationManufOrder.class.getName())
|
||||
.add("form", "documentation-manuf-order-form")
|
||||
.add("grid", "documentation-manuf-order-grid")
|
||||
.context("_showRecord", String.valueOf(docManufOrderid))
|
||||
.domain("self.id = " + docManufOrderid)
|
||||
.map());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void createTrackingNumberAndAssign(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderId);
|
||||
|
||||
Optional<OperationOrder> operationOrder1 =
|
||||
manufOrder
|
||||
.getOperationOrderList()
|
||||
.stream()
|
||||
.filter(op -> op.getOperationName().equals("MELANGE"))
|
||||
.findFirst();
|
||||
Optional<OperationOrder> operationOrder2 =
|
||||
manufOrder
|
||||
.getOperationOrderList()
|
||||
.stream()
|
||||
.filter(op -> op.getOperationName().equals("GRANULATION"))
|
||||
.findFirst();
|
||||
|
||||
if (operationOrder1 != null) {
|
||||
if (operationOrder1.isPresent()) {
|
||||
Beans.get(ManufOrderWorkflowService.class)
|
||||
.createAndAssignTrackingNumber(operationOrder1.get());
|
||||
}
|
||||
} else if (operationOrder2 != null) {
|
||||
if (operationOrder2.isPresent()) {
|
||||
Beans.get(ManufOrderWorkflowService.class)
|
||||
.createAndAssignTrackingNumber(operationOrder2.get());
|
||||
}
|
||||
}
|
||||
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
public void createToReturnStockMove(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderId);
|
||||
Beans.get(ManufOrderStockMoveService.class).createToReturnStockMove(manufOrder);
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
public void planOF(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
try {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderId);
|
||||
|
||||
if (manufOrder.getBillOfMaterial() != null) {
|
||||
for (BillOfMaterial bom : manufOrder.getBillOfMaterial().getBillOfMaterialSet()) {
|
||||
BillOfMaterialConsumption newBom =
|
||||
Beans.get(BillOfMaterialServiceImpl.class)
|
||||
.createBomConsumptionFromRawMaterial(bom, manufOrder);
|
||||
manufOrder.addBillOfMaterialConsumptionListItem(newBom);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void prefillConsumption(ActionRequest request, ActionResponse response) {
|
||||
|
||||
try {
|
||||
Long manufOrderId = (Long) request.getContext().get("id");
|
||||
ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderId);
|
||||
if (manufOrder.getBillOfMaterial() != null) {
|
||||
Beans.get(BillOfMaterialServiceImpl.class).createBomAndAttachToManufOrder(manufOrder);
|
||||
response.setReload(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void splitBillConsumption(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
List<HashMap> selectedBillConsumptionMapList =
|
||||
(List<HashMap>) request.getContext().get("billOfMaterialConsumptionList");
|
||||
Map manufOrderMap = (Map<String, Object>) request.getContext().get("manufOrder");
|
||||
if (selectedBillConsumptionMapList == null) {
|
||||
response.setFlash(I18n.get("Please select at least one line."));
|
||||
return;
|
||||
}
|
||||
|
||||
List<BillOfMaterialConsumption> billConsumptionList = new ArrayList<>();
|
||||
BillOfMaterialConsumptionRepository billConsumptionRepo =
|
||||
Beans.get(BillOfMaterialConsumptionRepository.class);
|
||||
for (HashMap map : selectedBillConsumptionMapList) {
|
||||
BillOfMaterialConsumption billConsumption =
|
||||
(BillOfMaterialConsumption) Mapper.toBean(BillOfMaterialConsumption.class, map);
|
||||
billConsumptionList.add(billConsumptionRepo.find(billConsumption.getId()));
|
||||
}
|
||||
|
||||
if (billConsumptionList.isEmpty()) {
|
||||
response.setFlash(I18n.get("Please select at least one line."));
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal splitQty = new BigDecimal(request.getContext().get("splitQty").toString());
|
||||
if (splitQty == null || splitQty.compareTo(BigDecimal.ZERO) < 1) {
|
||||
response.setFlash(I18n.get("Please enter a valid quantity."));
|
||||
return;
|
||||
}
|
||||
|
||||
ManufOrder manufOrder = Mapper.toBean(ManufOrder.class, manufOrderMap);
|
||||
manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
|
||||
Beans.get(BillOfMaterialServiceImpl.class)
|
||||
.splitBillOfMaterialConsumption(manufOrder, billConsumptionList, splitQty);
|
||||
response.setCanClose(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void consumeStockMoveTemp(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(ManufOrderStockMoveService.class).createTempStockMove(manufOrder);
|
||||
}
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,23 @@ public class OperationOrderController {
|
||||
try {
|
||||
OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
|
||||
operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
|
||||
|
||||
System.out.println("*******************************************");
|
||||
System.out.println(operationOrder.getManufOrder().getTrackingNumber());
|
||||
System.out.println(operationOrder.getOperationName());
|
||||
System.out.println(operationOrder.getManufOrder().getTrackingNumber() == null);
|
||||
System.out.println(operationOrder.getOperationName() == "MELANGE");
|
||||
|
||||
if (operationOrder.getManufOrder().getTrackingNumber() == null) {
|
||||
System.out.println("***is null****99999");
|
||||
if (operationOrder.getOperationName().equals("MELANGE")) {
|
||||
System.out.println("*******************************************99999");
|
||||
Beans.get(ManufOrderWorkflowService.class).createAndAssignTrackingNumber(operationOrder);
|
||||
} else if (operationOrder.getOperationName().equals("GRANULATION")) {
|
||||
Beans.get(ManufOrderWorkflowService.class).createAndAssignTrackingNumber(operationOrder);
|
||||
}
|
||||
}
|
||||
|
||||
Beans.get(OperationOrderWorkflowService.class).start(operationOrder);
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -21,13 +21,19 @@ import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.production.db.BillOfMaterial;
|
||||
import com.axelor.apps.production.db.ManufOrder;
|
||||
import com.axelor.apps.production.db.ProductionOrder;
|
||||
import com.axelor.apps.production.db.repo.BillOfMaterialRepository;
|
||||
import com.axelor.apps.production.db.repo.ManufOrderRepository;
|
||||
import com.axelor.apps.production.db.repo.ProductionOrderRepository;
|
||||
import com.axelor.apps.production.exceptions.IExceptionMessage;
|
||||
import com.axelor.apps.production.service.manuforder.ManufOrderService;
|
||||
import com.axelor.apps.production.service.productionorder.ProductionOrderService;
|
||||
import com.axelor.apps.production.service.productionorder.ProductionOrderServiceImpl;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
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.rpc.ActionRequest;
|
||||
@@ -38,6 +44,9 @@ import java.math.BigDecimal;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
@@ -104,4 +113,40 @@ public class ProductionOrderController {
|
||||
response.setCanClose(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void generateConsumeStockMoveFromSelectedManufOrder(
|
||||
ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
List<HashMap> selectedManufOrderMapList =
|
||||
(List<HashMap>) request.getContext().get("manufOrderList");
|
||||
Map productionOrderMap = (Map<String, Object>) request.getContext().get("productionOrder");
|
||||
if (selectedManufOrderMapList == null) {
|
||||
response.setFlash(I18n.get(IExceptionMessage.UNIT_COST_CALCULATION_IMPORT_FAIL_ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
List<ManufOrder> manufOrderList = new ArrayList<>();
|
||||
ManufOrderRepository manufOrderRepository = Beans.get(ManufOrderRepository.class);
|
||||
for (HashMap map : selectedManufOrderMapList) {
|
||||
ManufOrder manufOrder = (ManufOrder) Mapper.toBean(ManufOrder.class, map);
|
||||
manufOrderList.add(manufOrderRepository.find(manufOrder.getId()));
|
||||
}
|
||||
|
||||
if (manufOrderList.isEmpty()) {
|
||||
response.setFlash(I18n.get(IExceptionMessage.UNIT_COST_CALCULATION_IMPORT_FAIL_ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
ProductionOrder productionOrder = Mapper.toBean(ProductionOrder.class, productionOrderMap);
|
||||
productionOrder = Beans.get(ProductionOrderRepository.class).find(productionOrder.getId());
|
||||
StockMove stockMove =
|
||||
Beans.get(ProductionOrderServiceImpl.class)
|
||||
.generateConsumeStockMoveFromSelectedManufOrder(productionOrder, manufOrderList);
|
||||
response.setCanClose(true);
|
||||
response.setFlash("Generated successfully : " + stockMove.getStockMoveSeq());
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,15 @@
|
||||
<many-to-one name="originalBillOfMaterial" ref="com.axelor.apps.production.db.BillOfMaterial" title="Original bill of material" />
|
||||
<one-to-many name="bomChildTreeList" ref="TempBomTree" mappedBy="parentBom"/>
|
||||
<one-to-many name="bomTreeList" ref="TempBomTree" mappedBy="bom"/>
|
||||
|
||||
|
||||
<integer name="typeSelect" title="Bom type" selection="production.bill.of.material.type.select" default="1"/>
|
||||
|
||||
<integer name="productLifeTimeInMonth" title="Product lifetime in months" />
|
||||
<integer name="producedTrackingNumberSeq" title="Produced tracking number seq" />
|
||||
|
||||
<string name="note" large="true"/>
|
||||
|
||||
<finder-method name="findByProductAndTypeSelect" using="product,typeSelect" all="true"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
@@ -42,6 +49,9 @@
|
||||
public static final int STATUS_APPLICABLE = 3;
|
||||
public static final int STATUS_OBSOLETE = 4;
|
||||
|
||||
public static final int MANUF_TYPE_SELECT = 1;
|
||||
public static final int PACKAGING_TYPE_SELECT = 2;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
<track>
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
<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="fullName" namecolumn="true" title="Label"/>
|
||||
<many-to-one name="trackingNumber" ref="com.axelor.apps.stock.db.TrackingNumber" title="Tracking Nbr."/>
|
||||
<many-to-one ref="ManufOrder" name="manufOrder" />
|
||||
<string name="note" large="true"/>
|
||||
|
||||
<track>
|
||||
|
||||
@@ -7,6 +7,19 @@
|
||||
|
||||
<entity name="DocumentationManufOrder" lang="java">
|
||||
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" initParam="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" />
|
||||
<many-to-one name="manufOrder" ref="com.axelor.apps.production.db.ManufOrder" title="ManufOrder"/>
|
||||
<string name="noteconformityCertificateFile" large="true" multiline="true" title="Conformity certificate file note"/>
|
||||
<integer name="stypeSelect" title="Typeselect" selection="production.documentation.manuf.order.typeselect" />
|
||||
<integer name="statusSelect" title="Status select" selection="production.documentation.manuf.order.statusSelect" />
|
||||
<decimal name="qty" title="Qty" initParam="true"/>
|
||||
<one-to-many name="operationOrderList" ref="com.axelor.apps.production.db.OperationOrder" title="Operation orders" orderBy="priority"/>
|
||||
|
||||
<track>
|
||||
<field name="statusSelect" />
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -30,6 +30,8 @@
|
||||
<one-to-many name="producedStockMoveLineList" ref="com.axelor.apps.stock.db.StockMoveLine" mappedBy="producedManufOrder" title="Produced products" orphanRemoval="false"/>
|
||||
<one-to-many name="wasteProdProductList" ref="com.axelor.apps.production.db.ProdProduct" mappedBy="wasteManufOrder" title="Waste"/>
|
||||
|
||||
<one-to-many name="transferedStockMoveLineList" ref="com.axelor.apps.stock.db.StockMoveLine" mappedBy="transferedManufOrder" title="Transfered products" orphanRemoval="false"/>
|
||||
<one-to-many name="toReturnStockMoveLineList" ref="com.axelor.apps.stock.db.StockMoveLine" mappedBy="returnedManufOrder" title="Returned products" orphanRemoval="false"/>
|
||||
|
||||
<boolean name="isConsProOnOperation" title="Manage consumed products on operations" initParam="true"/>
|
||||
|
||||
@@ -50,9 +52,9 @@
|
||||
<datetime name="realStartDateT" title="Real start date"/>
|
||||
<datetime name="realEndDateT" title="Real end date"/>
|
||||
<decimal name="endTimeDifference" title="Time difference (Minutes)"/>
|
||||
|
||||
<one-to-many name="inStockMoveList" ref="com.axelor.apps.stock.db.StockMove" title="Stock moves in" mappedBy="inManufOrder"/>
|
||||
<one-to-many name="outStockMoveList" ref="com.axelor.apps.stock.db.StockMove" title="Stock moves out" mappedBy="outManufOrder"/>
|
||||
<!-- mappedBy="inManufOrder" -->
|
||||
<many-to-many name="inStockMoveList" ref="com.axelor.apps.stock.db.StockMove" title="Stock moves in" />
|
||||
<many-to-many name="outStockMoveList" ref="com.axelor.apps.stock.db.StockMove" title="Stock moves out" mappedBy="outManufOrder"/>
|
||||
|
||||
<many-to-one name="wasteStockMove" ref="com.axelor.apps.stock.db.StockMove" title="Waste stock move"/>
|
||||
|
||||
@@ -75,6 +77,9 @@
|
||||
|
||||
<one-to-many name="billOfMaterialConsumptionList" title="Bom consumption list" ref="com.axelor.apps.production.db.BillOfMaterialConsumption" />
|
||||
|
||||
<many-to-one name="originManufOrder" ref="ManufOrder" title="Origin Manuf order" />
|
||||
|
||||
|
||||
<unique-constraint columns="manufOrderSeq,company"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
@@ -85,6 +90,11 @@
|
||||
public static final int STATUS_IN_PROGRESS = 4;
|
||||
public static final int STATUS_STANDBY = 5;
|
||||
public static final int STATUS_FINISHED = 6;
|
||||
|
||||
public static final int STYPE_MANUF_ORDER = 1;
|
||||
public static final int STYPE_PACKAGING_ORDER = 2;
|
||||
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
<track>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" />
|
||||
<decimal name="qty" title="Quantity"/>
|
||||
<many-to-one name="unit" ref="com.axelor.apps.base.db.Unit" title="mass" />
|
||||
|
||||
<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"/>
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
<integer name="stockMoveRealizeOrderSelect" default="1" massUpdate="true"
|
||||
selection="production.manuf.order.stock.move.realize.order.select"/>
|
||||
|
||||
<integer name="typeSelect" title="ProdProcess type" selection="production.prod.process.type.select" default="1"/>
|
||||
|
||||
<finder-method name="findByProductAndTypeSelect" using="product,typeSelect" all="true"/>
|
||||
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
// STATUS SELECT
|
||||
@@ -38,6 +43,9 @@
|
||||
public static final int STATUS_VALIDATED = 2;
|
||||
public static final int STATUS_APPLICABLE = 3;
|
||||
public static final int STATUS_OBSOLETE = 4;
|
||||
|
||||
public static final int MANUF_TYPE_SELECT = 1;
|
||||
public static final int PACKAGING_TYPE_SELECT = 2;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<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" />
|
||||
<many-to-one name="unit" ref="com.axelor.apps.base.db.Unit" title="Unit" />
|
||||
<decimal name="qty" title="Quantity"/>
|
||||
|
||||
<track>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<integer name="stockMoveRealizeOrderSelect" default="1"
|
||||
selection="production.manuf.order.stock.move.realize.order.select"/>
|
||||
<many-to-one name="manufOrderSequence" title="Default sequence" ref="com.axelor.apps.base.db.Sequence"/>
|
||||
<many-to-one name="packagingOrderSequence" title="Packaging order sequence" ref="com.axelor.apps.base.db.Sequence"/>
|
||||
<one-to-many name="workshopSequenceConfigLineList" title="Sequence by workshop" mappedBy="productionConfig" ref="com.axelor.apps.production.db.WorkshopSequenceConfigLine"/>
|
||||
<boolean name="finishMoAutomaticEmail" title="Send email when manufacturing order finished" default="false"/>
|
||||
<many-to-one name="finishMoMessageTemplate" title="Message template" ref="com.axelor.apps.message.db.Template"/>
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
<many-to-one name="saleOrder" ref="com.axelor.apps.sale.db.SaleOrder" title="Sale order" />
|
||||
|
||||
<one-to-many name="manufOrderList" ref="com.axelor.apps.production.db.ManufOrder" mappedBy="productionOrder" title="Manufacturing orders" orderBy="prioritySelect"/>
|
||||
|
||||
<one-to-many name="inStockMoveList" ref="com.axelor.apps.stock.db.StockMove" title="Stock moves in" mappedBy="inProductionOrder"/>
|
||||
|
||||
<string name="productionOrderSeqSelect" title="Production order Seq select" selection="production.order.sequence.select"/>
|
||||
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product"/>
|
||||
|
||||
<boolean name="isClosed" >
|
||||
<![CDATA[
|
||||
if(manufOrderList == null || manufOrderList.isEmpty())
|
||||
|
||||
@@ -7,14 +7,18 @@
|
||||
|
||||
<entity name="StockMove" lang="java">
|
||||
|
||||
<many-to-one name="inManufOrder" ref="com.axelor.apps.production.db.ManufOrder"/>
|
||||
<many-to-one name="inProductionOrder" ref="com.axelor.apps.production.db.ProductionOrder"/>
|
||||
<!-- <many-to-one name="inManufOrder" ref="com.axelor.apps.production.db.ManufOrder"/> -->
|
||||
<many-to-one name="outManufOrder" ref="com.axelor.apps.production.db.ManufOrder"/>
|
||||
<many-to-one name="inOperationOrder" ref="com.axelor.apps.production.db.OperationOrder"/>
|
||||
|
||||
<boolean name="isValidatedProduction" title="Is validated production" />
|
||||
|
||||
<extra-code>
|
||||
<![CDATA[
|
||||
public static final String ORIGIN_MANUF_ORDER = "com.axelor.apps.production.db.ManufOrder";
|
||||
public static final String ORIGIN_OPERATION_ORDER = "com.axelor.apps.production.db.OperationOrder";
|
||||
public static final String ORIGIN_PRODUCTION_ORDER = "com.axelor.apps.production.db.ProductionOrder";
|
||||
]]>
|
||||
</extra-code>
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
|
||||
<many-to-one name="consumedManufOrder" ref="com.axelor.apps.production.db.ManufOrder" title="Manufacturing order"/>
|
||||
<many-to-one name="producedManufOrder" ref="com.axelor.apps.production.db.ManufOrder" title="Manufacturing order"/>
|
||||
<many-to-one name="returnedManufOrder" ref="com.axelor.apps.production.db.ManufOrder" title="Manufacturing order"/>
|
||||
<many-to-one name="transferedManufOrder" ref="com.axelor.apps.production.db.ManufOrder" title="Manufacturing order"/>
|
||||
<many-to-one name="productionOrder" ref="com.axelor.apps.production.db.ProductionOrder" title="Production order"/>
|
||||
|
||||
<many-to-one name="consumedOperationOrder" ref="com.axelor.apps.production.db.OperationOrder" title="Operation order"/>
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ import com.axelor.apps.purchase.service.PurchaseRequestServiceImpl;
|
||||
import com.axelor.apps.purchase.service.app.AppPurchaseService;
|
||||
import com.axelor.apps.purchase.service.app.AppPurchaseServiceImpl;
|
||||
import com.axelor.apps.purchase.service.print.PurchaseOrderPrintService;
|
||||
import com.axelor.apps.purchase.service.print.PurchaseRequestPrintService;
|
||||
import com.axelor.apps.purchase.service.print.PurchaseOrderPrintServiceImpl;
|
||||
import com.axelor.apps.purchase.service.print.PurchaseRequestPrintService;
|
||||
import com.axelor.apps.purchase.service.print.PurchaseRequestPrintServiceImpl;
|
||||
|
||||
public class PurchaseModule extends AxelorModule {
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
package com.axelor.apps.purchase.service;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
|
||||
import com.axelor.apps.purchase.db.ImportationFolder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.exception.AxelorException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
import wslite.json.JSONException;
|
||||
|
||||
public interface ImportationFolderService {
|
||||
|
||||
public void draftImportationFolder(ImportationFolder importationFolder);
|
||||
public void draftImportationFolder(ImportationFolder importationFolder);
|
||||
|
||||
public void openImportationFolder(ImportationFolder importationFolder) throws AxelorException;
|
||||
public void openImportationFolder(ImportationFolder importationFolder) throws AxelorException;
|
||||
|
||||
public void closeImportationFolder(ImportationFolder importationFolder);
|
||||
public void closeImportationFolder(ImportationFolder importationFolder);
|
||||
|
||||
public void cancelImportationFolder(ImportationFolder importationFolder);
|
||||
public void cancelImportationFolder(ImportationFolder importationFolder);
|
||||
|
||||
public void calculateSum(List<PurchaseOrder> purchaseOrders,ImportationFolder importationFolder) throws MalformedURLException, JSONException, AxelorException;
|
||||
}
|
||||
public void calculateSum(List<PurchaseOrder> purchaseOrders, ImportationFolder importationFolder)
|
||||
throws MalformedURLException, JSONException, AxelorException;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.math.BigDecimal;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import wslite.json.JSONException;
|
||||
|
||||
public class ImportationFolderServiceImpl implements ImportationFolderService {
|
||||
@@ -88,30 +87,27 @@ public class ImportationFolderServiceImpl implements ImportationFolderService {
|
||||
importationFolderRepository.save(importationFolder);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void calculateAvgPrice(List<PurchaseOrderLine> purchaseOrderLines, ImportationFolder importationFolder)
|
||||
public void calculateAvgPrice(
|
||||
List<PurchaseOrderLine> purchaseOrderLines, ImportationFolder importationFolder)
|
||||
throws MalformedURLException, JSONException, AxelorException {
|
||||
|
||||
|
||||
for (PurchaseOrderLine purchaseOrderLine : purchaseOrderLines) {
|
||||
|
||||
purchaseOrderLine.setPrice(purchaseOrderLine.getPrice().multiply(importationFolder.getCurrencyRate()));
|
||||
|
||||
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());
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
importationFolderRepository.save(importationFolder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.Unit;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrderLine;
|
||||
import com.axelor.apps.purchase.db.PurchaseRequestLine;
|
||||
import com.axelor.apps.purchase.db.SupplierCatalog;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
@@ -83,6 +84,16 @@ public interface PurchaseOrderLineService {
|
||||
Unit unit)
|
||||
throws AxelorException;
|
||||
|
||||
public PurchaseOrderLine createPurchaseOrderLine(
|
||||
PurchaseOrder purchaseOrder,
|
||||
Product product,
|
||||
String productName,
|
||||
String description,
|
||||
BigDecimal qty,
|
||||
Unit unit,
|
||||
PurchaseRequestLine purchaseRequestLine)
|
||||
throws AxelorException;
|
||||
|
||||
public BigDecimal getQty(PurchaseOrder purchaseOrder, PurchaseOrderLine purchaseOrderLine);
|
||||
|
||||
public SupplierCatalog getSupplierCatalog(
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.axelor.apps.base.service.tax.AccountManagementService;
|
||||
import com.axelor.apps.base.service.tax.FiscalPositionService;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrder;
|
||||
import com.axelor.apps.purchase.db.PurchaseOrderLine;
|
||||
import com.axelor.apps.purchase.db.PurchaseRequestLine;
|
||||
import com.axelor.apps.purchase.db.SupplierCatalog;
|
||||
import com.axelor.apps.purchase.exception.IExceptionMessage;
|
||||
import com.axelor.apps.purchase.service.app.AppPurchaseService;
|
||||
@@ -158,7 +159,8 @@ public class PurchaseOrderLineServiceImpl implements PurchaseOrderLineService {
|
||||
BigDecimal amount =
|
||||
quantity
|
||||
.multiply(price)
|
||||
.setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS_SUPPLIER_LINE, 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 {} : {}",
|
||||
@@ -726,4 +728,12 @@ public class PurchaseOrderLineServiceImpl implements PurchaseOrderLineService {
|
||||
product.getAllowToForcePurchaseQty(),
|
||||
response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PurchaseOrderLine createPurchaseOrderLine(PurchaseOrder purchaseOrder, Product product, String productName,
|
||||
String description, BigDecimal qty, Unit unit, PurchaseRequestLine purchaseRequestLine) throws AxelorException {
|
||||
PurchaseOrderLine purchaseOrderLine = this.createPurchaseOrderLine(purchaseOrder, product, productName, description, qty, unit);
|
||||
return purchaseOrderLine;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ 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;
|
||||
@@ -60,7 +59,6 @@ import com.axelor.apps.purchase.service.app.AppPurchaseService;
|
||||
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;
|
||||
@@ -70,8 +68,6 @@ 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;
|
||||
@@ -590,7 +586,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
purchaseOrder.setValidatedByUser(AuthUtils.getUser());
|
||||
|
||||
purchaseOrder.setSupplierPartner(validateSupplier(purchaseOrder));
|
||||
|
||||
|
||||
updateCostPrice(purchaseOrder);
|
||||
|
||||
if (purchaseOrder.getImportationFolder() != null) {
|
||||
@@ -601,33 +597,28 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void addFareToImportationFolder(PurchaseOrder purchaseOrder,BigDecimal amount) throws AxelorException, MalformedURLException, JSONException {
|
||||
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"));
|
||||
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);
|
||||
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);
|
||||
validatePurchaseOrder(purchaseOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -130,7 +130,8 @@ public class PurchaseRequestServiceImpl implements PurchaseRequestService {
|
||||
: product.getName(),
|
||||
purchaseRequestLine.getNewProduct() ? null : product.getDescription(),
|
||||
purchaseRequestLine.getQuantity(),
|
||||
purchaseRequestLine.getUnit());
|
||||
purchaseRequestLine.getUnit(),
|
||||
purchaseRequestLine);
|
||||
purchaseOrder.addPurchaseOrderLineListItem(purchaseOrderLine);
|
||||
purchaseOrderLineList.add(purchaseOrderLine);
|
||||
purchaseOrderLineService.compute(purchaseOrderLine, purchaseOrder);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user