Exemplo n.º 1
0
  /**
   * Returns an <tt>OrderLineType</tt> for an <em>act.supplierOrderItem</em>.
   *
   * @param act the order item to map
   * @param supplier the supplier
   * @param currency the currency that amounts are expressed in
   * @return a new <tt>OrderLineType</tt> corresponding to the act
   */
  private OrderLineType getOrderLine(Act act, Party supplier, Currency currency) {
    ActBean bean = factory.createActBean(act);
    Product product = (Product) bean.getNodeParticipant("product");

    OrderLineType orderLine = new OrderLineType();
    LineItemType lineItem = new LineItemType();

    String packageUnits = bean.getString("packageUnits");
    String unitCode = getUnitCode(packageUnits);

    ItemType item = getItem(bean, supplier, product, unitCode);
    lineItem.setItem(item);
    orderLine.setLineItem(lineItem);

    IDType id = UBLHelper.createID(act.getId());
    QuantityType quantity =
        UBLHelper.initQuantity(new QuantityType(), bean.getBigDecimal("quantity"), unitCode);
    LineExtensionAmountType lineAmount =
        UBLHelper.initAmount(new LineExtensionAmountType(), bean.getBigDecimal("total"), currency);
    TotalTaxAmountType taxAmount =
        UBLHelper.initAmount(new TotalTaxAmountType(), bean.getBigDecimal("tax"), currency);
    PriceType price = getPrice(bean.getBigDecimal("unitPrice"), unitCode, currency);

    lineItem.setID(id);
    lineItem.setQuantity(quantity);
    lineItem.setLineExtensionAmount(lineAmount);
    lineItem.setTotalTaxAmount(taxAmount);
    lineItem.setPrice(price);

    return orderLine;
  }
Exemplo n.º 2
0
  /**
   * Returns a <tt>MonetaryTotalType</tt> for an order.
   *
   * @param order the order
   * @param currency the currency
   * @return the corresponding <tt>MonetaryTotalType</tt>
   */
  private MonetaryTotalType getMonetaryTotal(FinancialAct order, Currency currency) {
    BigDecimal payableAmount = order.getTotal();
    BigDecimal lineExtensionAmount = payableAmount.subtract(order.getTaxAmount());

    MonetaryTotalType result = new MonetaryTotalType();
    result.setLineExtensionAmount(
        UBLHelper.initAmount(new LineExtensionAmountType(), lineExtensionAmount, currency));
    result.setPayableAmount(UBLHelper.initAmount(new PayableAmountType(), payableAmount, currency));
    return result;
  }
Exemplo n.º 3
0
 /**
  * Returns a <tt>PriceType</tt> for the specified price and unit code.
  *
  * @param price the price
  * @param unitCode the quantity unit code (UN/CEFACT). May be <tt>null</tt>
  * @param currency the currency
  * @return the corresponding <tt>PriceType</tt> for price and unitCode
  */
 private PriceType getPrice(BigDecimal price, String unitCode, Currency currency) {
   PriceType result = new PriceType();
   PriceAmountType priceAmount = UBLHelper.initAmount(new PriceAmountType(), price, currency);
   result.setPriceAmount(priceAmount);
   result.setBaseQuantity(
       UBLHelper.initQuantity(new BaseQuantityType(), BigDecimal.ONE, unitCode));
   return result;
 }
Exemplo n.º 4
0
 /**
  * Returns a <tt>TaxTotalType</tt> for an order.
  *
  * @param order the order
  * @param currency the currency
  * @return the corresponding <tt>TaxTotalType</tt>
  */
 private TaxTotalType getTaxTotal(FinancialAct order, Currency currency) {
   TaxTotalType result = new TaxTotalType();
   result.setTaxAmount(UBLHelper.initAmount(new TaxAmountType(), order.getTaxAmount(), currency));
   return result;
 }