use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoicePaymentController method filterPaymentMode.
// filter the payment mode depending on the target invoice
@SuppressWarnings("unchecked")
public void filterPaymentMode(ActionRequest request, ActionResponse response) {
Map<String, Object> partialInvoice = (Map<String, Object>) request.getContext().get("_invoice");
Invoice invoice = Beans.get(InvoiceRepository.class).find(Long.valueOf(partialInvoice.get("id").toString()));
PaymentMode paymentMode = invoice.getPaymentMode();
if (invoice != null && paymentMode != null) {
if (paymentMode.getInOutSelect() != null) {
response.setAttr("paymentMode", "domain", "self.inOutSelect = " + paymentMode.getInOutSelect());
}
}
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class ImportInvoice method importInvoice.
@Transactional(rollbackOn = { Exception.class })
public Object importInvoice(Object bean, Map<String, Object> values) throws AxelorException {
assert bean instanceof Invoice;
Invoice invoice = (Invoice) bean;
if (invoice.getAddress() != null) {
invoice.setAddressStr(addressService.computeAddressStr(invoice.getAddress()));
}
invoiceRepo.save(invoice);
if (invoice.getStatusSelect() == InvoiceRepository.STATUS_DRAFT) {
invoiceService.setDraftSequence(invoice);
}
return invoice;
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class ImportPaymentVoucher method importPaymentVoucher.
@SuppressWarnings("rawtypes")
public Object importPaymentVoucher(Object bean, Map values) {
assert bean instanceof PaymentVoucher;
try {
PaymentVoucher paymentVoucher = (PaymentVoucher) bean;
Invoice invoiceToPay = getInvoice((String) values.get("orderImport"));
MoveLine moveLineToPay = this.getMoveLineToPay(paymentVoucher, invoiceToPay);
if (moveLineToPay != null) {
PayVoucherDueElement payVoucherDueElement = paymentVoucherLoadService.createPayVoucherDueElement(moveLineToPay);
paymentVoucher.addPayVoucherElementToPayListItem(paymentVoucherLoadService.createPayVoucherElementToPay(paymentVoucher, payVoucherDueElement, 1));
}
if (paymentVoucher.getStatusSelect() == PaymentVoucherRepository.STATUS_CONFIRMED) {
paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher);
}
return paymentVoucher;
} catch (Exception e) {
TraceBackService.trace(e);
}
return bean;
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class PaymentVoucherController method initFromInvoice.
public void initFromInvoice(ActionRequest request, ActionResponse response) {
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
@SuppressWarnings("unchecked") Invoice invoice = Mapper.toBean(Invoice.class, (Map<String, Object>) request.getContext().get("_invoice"));
invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
try {
Beans.get(PaymentVoucherLoadService.class).initFromInvoice(paymentVoucher, invoice);
response.setValues(paymentVoucher);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class SaleOrderComputeServiceSupplychainImpl method computeTotalInvoiceAdvancePayment.
protected BigDecimal computeTotalInvoiceAdvancePayment(SaleOrder saleOrder) {
BigDecimal total = BigDecimal.ZERO;
if (saleOrder.getId() == null) {
return total;
}
List<Invoice> advancePaymentInvoiceList = Beans.get(InvoiceRepository.class).all().filter("self.saleOrder.id = :saleOrderId AND self.operationSubTypeSelect = :operationSubTypeSelect").bind("saleOrderId", saleOrder.getId()).bind("operationSubTypeSelect", InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE).fetch();
if (advancePaymentInvoiceList == null || advancePaymentInvoiceList.isEmpty()) {
return total;
}
for (Invoice advance : advancePaymentInvoiceList) {
total = total.add(advance.getAmountPaid());
}
return total;
}
Aggregations