Example #1
0
 /**
  * Creates a new return item from an order item.
  *
  * <p>The quantity on the return item will default to the order's: <em>receivedQuantity</em>
  *
  * @param orderItem the order item
  * @return a new return item
  * @throws ArchetypeServiceException for any archetype service error
  */
 public FinancialAct createReturnItem(FinancialAct orderItem) {
   List<IMObject> objects =
       copy(
           orderItem,
           ORDER_ITEM,
           new ReturnItemHandler(),
           orderItem.getActivityStartTime(),
           false);
   ActBean order = new ActBean(orderItem, service);
   BigDecimal received = order.getBigDecimal("receivedQuantity");
   FinancialAct item = (FinancialAct) objects.get(0);
   item.setQuantity(received);
   return (FinancialAct) objects.get(0);
 }
Example #2
0
 /**
  * Creates a new supplier act item.
  *
  * @param shortName the act short name
  * @param product the product
  * @param quantity the quantity
  * @param packageSize the package size
  * @param packageUnits the package units
  * @param unitPrice the unit price
  * @param listPrice the list price
  * @return a new act
  */
 protected static FinancialAct createItem(
     String shortName,
     Product product,
     BigDecimal quantity,
     int packageSize,
     String packageUnits,
     BigDecimal unitPrice,
     BigDecimal listPrice) {
   FinancialAct item = (FinancialAct) create(shortName);
   ActBean bean = new ActBean(item);
   bean.addParticipation(StockArchetypes.STOCK_PARTICIPATION, product);
   item.setQuantity(quantity);
   bean.setValue("packageSize", packageSize);
   bean.setValue("packageUnits", packageUnits);
   bean.setValue("unitPrice", unitPrice);
   bean.setValue("listPrice", listPrice);
   ArchetypeServiceHelper.getArchetypeService().deriveValues(item);
   return item;
 }
Example #3
0
 /**
  * Creates a new delivery item from an order item.
  *
  * <p>The quantity on the delivery item will default to the order's:
  *
  * <p><tt>quantity - (receivedQuantity + cancelledQuantity)</tt>
  *
  * @param orderItem the order item
  * @return a new delivery item
  * @throws ArchetypeServiceException for any archetype service error
  */
 public FinancialAct createDeliveryItem(FinancialAct orderItem) {
   List<IMObject> objects =
       copy(
           orderItem,
           ORDER_ITEM,
           new DeliveryItemHandler(),
           orderItem.getActivityStartTime(),
           false);
   ActBean order = new ActBean(orderItem, service);
   BigDecimal quantity = orderItem.getQuantity();
   BigDecimal received = order.getBigDecimal("receivedQuantity");
   BigDecimal cancelled = order.getBigDecimal("cancelledQuantity");
   BigDecimal remaining = quantity.subtract(received.add(cancelled));
   if (remaining.compareTo(BigDecimal.ZERO) < 0) {
     remaining = BigDecimal.ZERO;
   }
   FinancialAct delivery = (FinancialAct) objects.get(0);
   delivery.setQuantity(remaining);
   return delivery;
 }