Package no.sws.invoice.shipment

Examples of no.sws.invoice.shipment.Shipment


    if(invoice == null) {
      throw new IllegalArgumentException("Parameter invoice can't be null");
    }

    final Shipment shipment = invoice.getShipment();

    if(shipment == null) {
      throw new IllegalStateException("The given invoice.getShipment() returned null. Here is your invoice object:\n" + invoice);
    }

    final Element result = new Element("shipment");

    result.setText(shipment.getShipmentType().toString().toUpperCase());

    // set email/copy-addresses
    if(shipment.getShipmentType() == ShipmentType.email || shipment.getShipmentType() == ShipmentType.paper_and_email) {

      // email addresses is required
      final List<String> emailAddresses = shipment.getEmailAddresses();

      if(emailAddresses == null || emailAddresses.size() == 0) {
        throw new IllegalStateException("You must specify email addresses on shipment when shipment type is "
            + shipment.getShipmentType().toString());
      }

      // create <emailaddresses> child element and add it to the shipment element
      final Element emailAddressesElement = new Element("emailaddresses");
      result.addContent(emailAddressesElement);

      // iterate all email addresses
      for(final String currentEmailAddress : emailAddresses) {

        // create email element
        final Element emailAddressElement = new Element("email");
        emailAddressElement.setText(currentEmailAddress);

        // add element to parent element (<emailaddresses>)
        emailAddressesElement.addContent(emailAddressElement);
      }

      // copy addresses is optional
      final List<String> copyAddresses = shipment.getCopyAddresses();

      if(copyAddresses != null && copyAddresses.size() > 0) {

        // create <copyaddresses> child element and add it to the shipment element
        final Element copyAddressesElement = new Element("copyaddresses");
View Full Code Here


        // add an invoice line
        demo.addInvoiceLine(new BigDecimal("1.00"), "Fakturalinje #1", new BigDecimal("100.00"));

        // send the invoice by email with a copy to my accountant
        Shipment shipment = ShipmentFactory.getInstance(ShipmentType.email);
        shipment.addEmailAddress("kari@nordmann.no");
        shipment.addCopyAddress("kopi@regnskap.no");

        demo.setShipment(shipment);

        // add the demo invoice to the list to return. You can add as many
        // invoices you like, the only limit is the file size of the generated
View Full Code Here

TOP

Related Classes of no.sws.invoice.shipment.Shipment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.