use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderCreateServiceSupplychainImpl method mergeSaleOrders.
@Transactional(rollbackOn = { Exception.class })
public SaleOrder mergeSaleOrders(List<SaleOrder> saleOrderList, Currency currency, Partner clientPartner, Company company, StockLocation stockLocation, Partner contactPartner, PriceList priceList, Team team) throws AxelorException {
String numSeq = "";
String externalRef = "";
for (SaleOrder saleOrderLocal : saleOrderList) {
if (!numSeq.isEmpty()) {
numSeq += "-";
}
numSeq += saleOrderLocal.getSaleOrderSeq();
if (!externalRef.isEmpty()) {
externalRef += "|";
}
if (saleOrderLocal.getExternalReference() != null) {
externalRef += saleOrderLocal.getExternalReference();
}
}
SaleOrder saleOrderMerged = this.createSaleOrder(AuthUtils.getUser(), company, contactPartner, currency, null, numSeq, externalRef, stockLocation, priceList, clientPartner, team, null);
super.attachToNewSaleOrder(saleOrderList, saleOrderMerged);
saleOrderComputeService.computeSaleOrder(saleOrderMerged);
saleOrderRepository.save(saleOrderMerged);
super.removeOldSaleOrders(saleOrderList);
return saleOrderMerged;
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class OpportunitySaleOrderSupplychainServiceImpl method createSaleOrderFromOpportunity.
@Override
@Transactional(rollbackOn = { Exception.class })
public SaleOrder createSaleOrderFromOpportunity(Opportunity opportunity) throws AxelorException {
SaleOrder saleOrder = super.createSaleOrderFromOpportunity(opportunity);
// Set default invoiced and delivered partners and address in case of partner delegations
if (Beans.get(AppSupplychainService.class).getAppSupplychain().getActivatePartnerRelations()) {
Beans.get(SaleOrderSupplychainService.class).setDefaultInvoicedAndDeliveredPartnersAndAddresses(saleOrder);
}
saleOrderRepo.save(saleOrder);
return saleOrder;
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class InvoicePaymentToolServiceSupplychainImpl method updateAmountPaid.
@Override
@Transactional(rollbackOn = { Exception.class })
public void updateAmountPaid(Invoice invoice) throws AxelorException {
super.updateAmountPaid(invoice);
if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
return;
}
SaleOrder saleOrder = invoice.getSaleOrder();
if (saleOrder != null) {
// compute sale order totals
Beans.get(SaleOrderComputeService.class)._computeSaleOrder(saleOrder);
}
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class AccountingSituationSupplychainServiceImpl method computeUsedCredit.
@Override
public AccountingSituation computeUsedCredit(AccountingSituation accountingSituation) throws AxelorException {
BigDecimal sum = BigDecimal.ZERO;
List<SaleOrder> saleOrderList = saleOrderRepository.all().filter("self.company = ?1 AND self.clientPartner = ?2 AND self.statusSelect > ?3 AND self.statusSelect < ?4", accountingSituation.getCompany(), accountingSituation.getPartner(), SaleOrderRepository.STATUS_DRAFT_QUOTATION, SaleOrderRepository.STATUS_CANCELED).fetch();
for (SaleOrder saleOrder : saleOrderList) {
sum = sum.add(saleOrder.getInTaxTotal().subtract(getInTaxInvoicedAmount(saleOrder)));
}
// invoice payments
if (!accountConfigService.getAccountConfig(accountingSituation.getCompany()).getGenerateMoveForInvoicePayment()) {
List<InvoicePayment> invoicePaymentList = invoicePaymentRepository.all().filter("self.invoice.company = :company" + " AND self.invoice.partner = :partner" + " AND self.statusSelect = :validated" + " AND self.typeSelect != :imputation").bind("company", accountingSituation.getCompany()).bind("partner", accountingSituation.getPartner()).bind("validated", InvoicePaymentRepository.STATUS_VALIDATED).bind("imputation", InvoicePaymentRepository.TYPE_ADV_PAYMENT_IMPUTATION).fetch();
if (invoicePaymentList != null) {
for (InvoicePayment invoicePayment : invoicePaymentList) {
sum = sum.subtract(invoicePayment.getAmount());
}
}
}
sum = accountingSituation.getBalanceCustAccount().add(sum);
accountingSituation.setUsedCredit(sum.setScale(2, RoundingMode.HALF_UP));
return accountingSituation;
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderProjectController method updateLines.
public void updateLines(ActionRequest request, ActionResponse response) {
try {
SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrder.getId());
saleOrder = Beans.get(ProjectAnalyticMoveLineService.class).updateLines(saleOrder);
response.setValue("saleOrderLineList", saleOrder.getSaleOrderLineList());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations