Author: mor
Date: Mon Jul 20 13:07:53 2009 New Revision: 795814 URL: http://svn.apache.org/viewvc?rev=795814&view=rev Log: Improvements in the Verify Pick process as a result of last commit (rev. 795809) Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml?rev=795814&r1=795813&r2=795814&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml Mon Jul 20 13:07:53 2009 @@ -241,7 +241,7 @@ <if-compare value="0" operator="equals" field="orderItemShipGrpInvRes.quantity" type="BigDecimal"> <!-- if none left reserved, remove OIIR --> <remove-value value-field="orderItemShipGrpInvRes"/> - <if-compare field="shipment.statusId" operator="not-equals" value="SHIPMENT_PICKED"> + <if-compare field="shipment.statusId" operator="not-equals" value="SHIPMENT_SCHEDULED"> <!-- if there are no more OIIRs for the orderItem, set the orderItem.statusId to ITEM_COMPLETED --> <get-related value-field="orderItem" relation-name="OrderItemShipGrpInvRes" list="otherOiirs"/> <if-empty field="otherOiirs"> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=795814&r1=795813&r2=795814&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java Mon Jul 20 13:07:53 2009 @@ -303,12 +303,16 @@ // check reserved quantity, it should be equal to verified quantity this.checkReservedQty(orderId, locale); String shipmentId = this.createShipment((this.getPickRows(orderId)).get(0)); + this.issueItemsToShipment(shipmentId, locale); - invoiceId = this.createInvoice(orderId); - for (VerifyPickSessionRow line: this.getPickRows(orderId)) { - invoiceItemSeqId = this.createInvoiceItem(line, invoiceId, shipmentId); - line.setInvoiceItemSeqId(invoiceItemSeqId); - } + + // Update the shipment status to Picked, this will trigger createInvoicesFromShipment and finally a invoice will be created + Map updateShipmentCtx = FastMap.newInstance(); + updateShipmentCtx.put("shipmentId", shipmentId); + updateShipmentCtx.put("statusId", "SHIPMENT_PICKED"); + updateShipmentCtx.put("userLogin", this.getUserLogin()); + this.getDispatcher().runSync("updateShipment", updateShipmentCtx); + return shipmentId; } @@ -386,7 +390,7 @@ newShipment.put("primaryShipGroupSeqId", line.getShipGroupSeqId()); newShipment.put("primaryOrderId", orderId); newShipment.put("shipmentTypeId", "OUTGOING_SHIPMENT"); - newShipment.put("statusId", "SHIPMENT_PICKED"); + newShipment.put("statusId", "SHIPMENT_SCHEDULED"); newShipment.put("userLogin", this.getUserLogin()); GenericValue orderRoleShipTo = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "SHIP_TO_CUSTOMER"))); if (UtilValidate.isNotEmpty(orderRoleShipTo)) { @@ -419,45 +423,4 @@ String shipmentId = (String) newShipResp.get("shipmentId"); return shipmentId; } - - protected String createInvoice(String orderId) throws GeneralException { - GenericDelegator delegator = this.getDelegator(); - Map createInvoiceContext = FastMap.newInstance(); - GenericValue orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); - GenericValue billingAccount = orderHeader.getRelatedOne("BillingAccount"); - String billingAccountId = billingAccount != null ? billingAccount.getString("billingAccountId") : null; - createInvoiceContext.put("partyId", (EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "BILL_TO_CUSTOMER")))).getString("partyId")); - createInvoiceContext.put("partyIdFrom", (EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "BILL_FROM_VENDOR")))).getString("partyId")); - createInvoiceContext.put("billingAccountId", billingAccountId); - createInvoiceContext.put("invoiceTypeId", "SALES_INVOICE"); - createInvoiceContext.put("statusId", "INVOICE_IN_PROCESS"); - createInvoiceContext.put("currencyUomId", orderHeader.getString("currencyUom")); - createInvoiceContext.put("userLogin", this.getUserLogin()); - Map createInvoiceResult = this.getDispatcher().runSync("createInvoice", createInvoiceContext); - if (ServiceUtil.isError(createInvoiceResult)) { - throw new GeneralException(ServiceUtil.getErrorMessage(createInvoiceResult)); - } - String invoiceId = (String) createInvoiceResult.get("invoiceId"); - return invoiceId; - } - - protected String createInvoiceItem(VerifyPickSessionRow line, String invoiceId, String shipmentId) throws GeneralException { - Map createInvoiceItemContext = FastMap.newInstance(); - createInvoiceItemContext.put("invoiceId", invoiceId); - createInvoiceItemContext.put("orderId", line.getOrderId()); - createInvoiceItemContext.put("invoiceItemTypeId", "INV_FPROD_ITEM"); - createInvoiceItemContext.put("productId", line.getProductId()); - createInvoiceItemContext.put("quantity", line.getReadyToVerifyQty()); - createInvoiceItemContext.put("userLogin", this.getUserLogin()); - Map createInvoiceItemResult = this.getDispatcher().runSync("createInvoiceItem", createInvoiceItemContext); - if (ServiceUtil.isError(createInvoiceItemResult)) { - throw new GeneralException(ServiceUtil.getErrorMessage(createInvoiceItemResult)); - } - String invoiceItemSeqId = (String) createInvoiceItemResult.get("invoiceItemSeqId"); - GenericValue shipmentItemBilling = this.getDelegator().makeValue("ShipmentItemBilling", UtilMisc.toMap("invoiceId", invoiceId, "invoiceItemSeqId", invoiceItemSeqId)); - shipmentItemBilling.put("shipmentId", shipmentId); - shipmentItemBilling.put("shipmentItemSeqId", line.getShipmentItemSeqId()); - shipmentItemBilling.create(); - return invoiceItemSeqId; - } } \ No newline at end of file Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=795814&r1=795813&r2=795814&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java Mon Jul 20 13:07:53 2009 @@ -416,7 +416,13 @@ shipmentPackageMap.put("weightUomId", getWeightUomId()); shipmentPackageMap.put("userLogin", userLogin); - Map<String, Object> shipmentPackageResult = this.getDispatcher().runSync("createShipmentPackage", shipmentPackageMap); + Map<String, Object> shipmentPackageResult = FastMap.newInstance(); + GenericValue shipmentPackage = this.getDelegator().findOne("ShipmentPackage", UtilMisc.toMap("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId), false); + if (UtilValidate.isEmpty(shipmentPackage)) { + shipmentPackageResult = this.getDispatcher().runSync("createShipmentPackage", shipmentPackageMap); + } else { + shipmentPackageResult = this.getDispatcher().runSync("updateShipmentPackage", shipmentPackageMap); + } if (ServiceUtil.isError(shipmentPackageResult)) { throw new GeneralException(ServiceUtil.getErrorMessage(shipmentPackageResult)); } |
Free forum by Nabble | Edit this page |