/** * Obtenir le compte comptable d'une TVA. * * @param product * @param company * @param isPurchase * @return * @throws AxelorException */ public Vat getProductVat(Product product, Company company, boolean isPurchase) throws AxelorException { LOG.debug( "Obtention du compte comptable pour le produit {} (société : {}, achat ? {})", new Object[] {product.getCode(), company, isPurchase}); return this.getProductVat(this.getAccountManagement(product, company), isPurchase); }
/** * Obtenir la version de TVA d'un produit. * * @param product * @param amendment * @return * @throws AxelorException */ public VatLine getVatLine(LocalDate date, Product product, Company company, boolean isPurchase) throws AxelorException { VatLine vatLine = vs.getVatLine(this.getProductVat(product, company, isPurchase), date); if (vatLine != null) { return vatLine; } throw new AxelorException( String.format("Aucune TVA trouvée pour le produit %s", product.getCode()), IException.CONFIGURATION_ERROR); }
@Transactional(rollbackOn = {AxelorException.class, Exception.class}) protected void generatePurchaseProposal(MrpLine mrpLine) throws AxelorException { Product product = mrpLine.getProduct(); Location location = mrpLine.getLocation(); LocalDate maturityDate = mrpLine.getMaturityDate(); Partner supplierPartner = product.getDefaultSupplierPartner(); if (supplierPartner == null) { throw new AxelorException( String.format(I18n.get(IExceptionMessage.MRP_LINE_1), product.getFullName()), IException.CONFIGURATION_ERROR); } Company company = location.getCompany(); PurchaseOrder purchaseOrder = purchaseOrderRepo.save( purchaseOrderServiceSupplychainImpl.createPurchaseOrder( this.user, company, null, supplierPartner.getCurrency(), maturityDate, "MRP-" + this.today.toString(), // TODO sequence on mrp null, location, this.today, supplierPartner.getPurchasePriceList(), supplierPartner)); Unit unit = product.getPurchasesUnit(); BigDecimal qty = mrpLine.getQty(); if (unit == null) { unit = product.getUnit(); } else { qty = Beans.get(UnitConversionService.class) .convertWithProduct(product.getUnit(), unit, qty, product); } purchaseOrder.addPurchaseOrderLineListItem( purchaseOrderLineService.createPurchaseOrderLine( purchaseOrder, product, product.getName(), qty, unit)); purchaseOrderServiceSupplychainImpl.computePurchaseOrder(purchaseOrder); }
/** * Obtenir la bonne configuration comptable en fonction du produit et de la société. * * @param product * @param company * @return * @throws AxelorException */ public AccountManagement getAccountManagement(Product product, Company company) throws AxelorException { AccountManagement accountManagement = null; if (product.getAccountManagementList() != null && !product.getAccountManagementList().isEmpty()) { accountManagement = this.getAccountManagement(product.getAccountManagementList(), company); } if (accountManagement == null && product.getProductFamily() != null) { accountManagement = this.getAccountManagement(product.getProductFamily(), company); } if (accountManagement == null) { throw new AxelorException( String.format( "Configuration comptable absente du produit : %s (société : %s)", product.getCode(), company.getName()), IException.CONFIGURATION_ERROR); } return accountManagement; }