Program: 58922
Project: 58922
Buggy source:
@Transactional public SaleOrderLine generateSubscriptions(SaleOrderLine saleOrderLineIt,SaleOrderLine saleOrderLine) throws AxelorException {
  int iterator=0;
  if (saleOrderLine.getToSubDate() == null) {
    throw new AxelorException(I18n.get("String_Node_Str"),1);
  }
  for (  Subscription subscription : saleOrderLineIt.getSubscriptionList()) {
    if (!subscription.getInvoiced()) {
      subscription.setSaleOrderLine(null);
    }
  }
  while (iterator != saleOrderLine.getPeriodNumber()) {
    Subscription subscription=new Subscription();
    if (saleOrderLine.getInvoicingTypeSelect() == 1) {
      subscription.setInvoicingDate(saleOrderLine.getFromSubDate().plusMonths(saleOrderLine.getPeriodicity() * iterator));
    }
 else {
      subscription.setInvoicingDate(saleOrderLine.getFromSubDate().plusMonths(saleOrderLine.getPeriodicity() * (iterator + 1)).minusDays(1));
    }
    subscription.setFromPeriodDate(saleOrderLine.getFromSubDate().plusMonths(saleOrderLine.getPeriodicity() * iterator));
    subscription.setToPeriodDate(saleOrderLine.getFromSubDate().plusMonths(saleOrderLine.getPeriodicity() * (iterator + 1)).minusDays(1));
    subscription.setQuantity(saleOrderLine.getQty());
    if (saleOrderLine.getPeriodicity() == saleOrderLine.getProduct().getPeriodicitySelect()) {
      subscription.setUnitPrice(saleOrderLine.getPrice().multiply(new BigDecimal(saleOrderLine.getPeriodicity())));
    }
 else {
      subscription.setUnitPrice(saleOrderLine.getPrice().multiply(new BigDecimal(saleOrderLine.getPeriodicity()).divide(new BigDecimal(saleOrderLine.getProduct().getPeriodicitySelect()))));
    }
    subscription.setInvoiced(false);
    saleOrderLineIt.addSubscriptionListItem(subscription);
    iterator++;
  }
  Beans.get(SaleOrderLineRepository.class).save(saleOrderLineIt);
  return saleOrderLine;
}

Fixed version (ground truth):
@Override @Transactional public SaleOrderLine generateSubscriptions(SaleOrderLine saleOrderLineIt,SaleOrderLine saleOrderLine) throws AxelorException {
  int iterator=0;
  if (saleOrderLine.getToSubDate() == null) {
    throw new AxelorException(I18n.get("String_Node_Str"),1);
  }
  for (  Subscription subscription : saleOrderLineIt.getSubscriptionList()) {
    if (!subscription.getInvoiced()) {
      subscription.setSaleOrderLine(null);
    }
  }
  while (iterator != saleOrderLine.getPeriodNumber()) {
    Subscription subscription=new Subscription();
    if (saleOrderLine.getInvoicingTypeSelect() == 1) {
      subscription.setInvoicingDate(saleOrderLine.getFromSubDate().plusMonths(saleOrderLine.getPeriodicity() * iterator));
    }
 else {
      subscription.setInvoicingDate(saleOrderLine.getFromSubDate().plusMonths(saleOrderLine.getPeriodicity() * (iterator + 1)).minusDays(1));
    }
    subscription.setFromPeriodDate(saleOrderLine.getFromSubDate().plusMonths(saleOrderLine.getPeriodicity() * iterator));
    subscription.setToPeriodDate(saleOrderLine.getFromSubDate().plusMonths(saleOrderLine.getPeriodicity() * (iterator + 1)).minusDays(1));
    subscription.setQuantity(saleOrderLine.getQty());
    if (saleOrderLine.getPeriodicity() == saleOrderLine.getProduct().getPeriodicitySelect()) {
      subscription.setUnitPrice(saleOrderLine.getPrice().multiply(new BigDecimal(saleOrderLine.getPeriodicity())));
    }
 else {
      subscription.setUnitPrice(saleOrderLine.getPrice().multiply(new BigDecimal(saleOrderLine.getPeriodicity()).divide(new BigDecimal(saleOrderLine.getProduct().getPeriodicitySelect()))));
    }
    subscription.setInvoiced(false);
    saleOrderLineIt.addSubscriptionListItem(subscription);
    iterator++;
  }
  Beans.get(SaleOrderLineRepository.class).save(saleOrderLineIt);
  return saleOrderLine;
}