/**
   * 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);
  }
  /**
   * 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;
  }