Package org.openbravo.model.dataimport

Examples of org.openbravo.model.dataimport.Order


    }

    protected void doChangeAction(String path, HttpServletRequest request,
            HttpServletResponse response, OBQuery<BaseOBObject> obq) {
        try {
            final Order iOrder = createImportOrder(request, obq);
            OBDal.getInstance().save(iOrder);
        } catch (final Exception e) {
            throw new OBException("Error saving Entity into database");
        }
    }
View Full Code Here


        final String line_price = request.getParameter("line_price");
        final String tax_id = request.getParameter("tax_id");
        final String payment_total = request.getParameter("payment_total");
        final String erp_org = request.getParameter("erp.org");

        final Order iOrder = new Order();

        final ExternalPOS extPos = (ExternalPOS) obq.list().get(0);

        // Client
        iOrder.setClient(extPos.getClient());

        // Organization
        final Organization syncOrgSel = (Organization) OBDal.getInstance().get(
                "Organization", erp_org);
        iOrder.setOrganization(syncOrgSel);

        // Sales representative
        iOrder.setSalesRepresentative(extPos.getSalesRepresentative());

        // Warehouse
        iOrder.setWarehouse(extPos.getWarehouse());

        // Price list
        iOrder.setPriceList(extPos.getPriceList());

        // Currency
        iOrder.setCurrency(extPos.getPriceList().getCurrency());

        // Shipping company
        iOrder.setShippingCompany(extPos.getShippingCompany());

        // Business Partner
        if (bp_id == null) {
            final BusinessPartner syncBp = extPos.getBusinessPartner();
            iOrder.setBusinessPartner(syncBp);
            final Location syncBpLoc = (syncBp.getBusinessPartnerLocationList()
                    .isEmpty()) ? null : syncBp
                    .getBusinessPartnerLocationList().get(0);

            iOrder.setPartnerAddress(syncBpLoc);
            // Payment Term
            iOrder.setPaymentTerms(syncBp.getPaymentTerms());
        } else {
            final BusinessPartner syncSelBp = (BusinessPartner) OBDal
                    .getInstance().get("BusinessPartner", bp_id);
            iOrder.setBusinessPartner(syncSelBp);
            final Location syncBpLoc = (syncSelBp
                    .getBusinessPartnerLocationList().isEmpty()) ? null
                    : syncSelBp.getBusinessPartnerLocationList().get(0);
            iOrder.setPartnerAddress(syncBpLoc);
        }

        // Document type
        iOrder.setDocumentType(extPos.getDocumentType());

        // Document number
        iOrder.setDocumentNo(ti_id + "." + ti_type);

        // Document name
        iOrder.setDocumentTypeName(extPos.getDocumentType().getName());

        // Product
        final Product pro = (Product) OBDal.getInstance().get("Product",
                line_product);
        iOrder.setProduct(pro);

        // Taxes
        final TaxRate tax = (TaxRate) OBDal.getInstance().get(
                "FinancialMgmtTaxRate", tax_id);
        iOrder.setTax(tax);

        // Quantity ordered
        iOrder.setOrderedQuantity(BigDecimal
                .valueOf(Double.valueOf(line_units)));

        // Price of product
        iOrder.setUnitPrice(BigDecimal.valueOf(Double.valueOf(line_price)));

        // Data ordered
        final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        try {
            date = formatter.parse(ti_date);
        } catch (final ParseException e) {
            throw new OBException("Error parsing date " + ti_date);
        }

        iOrder.setOrderDate(date);

        // Payment amount1
        iOrder.setPaymentamount1(Float.valueOf(payment_total));

        // Payment rules
        iOrder.setPaymentrule1(null);
        iOrder.setPaymentrule2(null);

        return iOrder;
    }
View Full Code Here

TOP

Related Classes of org.openbravo.model.dataimport.Order

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.