Exemplo n.º 1
0
        public virtual IEnumerable orders()
        {
            foreach (PXResult <POReceipt> res in PXSelectJoinGroupBy <POReceipt,
                                                                      LeftJoinSingleTable <Vendor, On <Vendor.bAccountID, Equal <POReceipt.vendorID> >,
                                                                                           InnerJoin <POReceiptLine, On <POReceiptLine.receiptNbr, Equal <POReceipt.receiptNbr> >,
                                                                                                      LeftJoin <APTran, On <APTran.receiptNbr, Equal <POReceiptLine.receiptNbr>,
                                                                                                                            And <APTran.receiptLineNbr, Equal <POReceiptLine.lineNbr> > > > > >,
                                                                      Where2 <Where <Vendor.bAccountID, IsNull, Or <Match <Vendor, Current <AccessInfo.userName> > > >,
                                                                              And <POReceipt.hold, Equal <boolFalse>,
                                                                                   And <POReceipt.released, Equal <boolFalse>,
                                                                                        And <APTran.refNbr, IsNull> > > >,
                                                                      Aggregate <GroupBy <POReceipt.receiptNbr,
                                                                                          GroupBy <POReceipt.receiptType,
                                                                                                   GroupBy <POReceipt.released,
                                                                                                            GroupBy <POReceipt.hold,
                                                                                                                     GroupBy <POReceipt.autoCreateInvoice> > > > > > >
                     .Select(this))
            {
                POReceipt sel = res;
                POReceipt order;
                if ((order = (POReceipt)Orders.Cache.Locate(sel)) != null)
                {
                    sel.Selected = order.Selected;
                }

                yield return(sel);
            }
            Orders.Cache.IsDirty = false;
        }
        public static void Process(POReceipt doc)
        {
            List <POReceipt> list = new List <POReceipt>();

            list.Add(doc);
            Process(list, false);
        }
Exemplo n.º 3
0
        protected virtual void POReceipt_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
        {
            POReceipt row = (POReceipt)e.Row;
            string dateTime = DateTime.Now.ToString();
            string createddate = Convert.ToDateTime(dateTime).ToString("yyyy-MM-dd");
            DateTime dt = DateTime.ParseExact(createddate, "yyyy-MM-dd", null);

            if (row.ReceiptDate > dt)
            {
                cache.RaiseExceptionHandling<POReceipt.receiptDate>(e.Row, row.ReceiptDate, new PXSetPropertyException(CustomMessage.DateLessToday));
            }
        }
 public virtual IEnumerable viewDocument(PXAdapter adapter)
 {
     if (this.receiptsList.Current != null)
     {
         POReceiptEntry graph = PXGraph.CreateInstance <POReceiptEntry>();
         POReceipt      poDoc = graph.Document.Search <POReceipt.receiptNbr>(this.receiptsList.Current.ReceiptNbr, this.receiptsList.Current.ReceiptType);
         if (poDoc != null)
         {
             graph.Document.Current = poDoc;
             throw new PXRedirectRequiredException(graph, true, "Document")
                   {
                       Mode = PXBaseRedirectException.WindowMode.NewWindow
                   };
         }
     }
     return(adapter.Get());
 }
Exemplo n.º 5
0
        string cancelPONonGoods(POReceipt pOReceipt, POReceiptLine pOReceiptLine)
        {
            string result = "";

            PLNSC.ScreenService.OperationContext SSContextClass = new PLNSC.ScreenService.OperationContext()
            {
                district = districtCode,
                position = positionID,
                maxInstances = maxInstance
            };

            ScreenService screenService = new ScreenService()
            {
                Timeout = sessionTimeout,
                Url = $"{urlPrefix(dbName)}ScreenService"
            };

            ScreenDTO screenReply = new ScreenDTO();
            ScreenSubmitRequestDTO submitRequest = new ScreenSubmitRequestDTO();

            try
            {
                ClientConversation.authenticate(userName, password);

                screenReply = screenService.executeScreen(SSContextClass, "MSO155");
                screenName = screenReply.mapName;

                if (screenName != "MSM155A")
                {
                    throw new PXException(CustomMessage.NotMSO155);
                }

                ScreenNameValueDTO[] fields = {
                    new ScreenNameValueDTO(),
                    new ScreenNameValueDTO(),
                    new ScreenNameValueDTO(),
                    new ScreenNameValueDTO()
                };

                fields[0].fieldName = "OPTION1I";
                fields[0].value = "3";
                fields[1].fieldName = "PO_NO1I";
                fields[1].value = pOReceiptLine.PONbr;
                fields[2].fieldName = "PO_ITEM1I";
                fields[2].value = pOReceiptLine.POLineNbr.ToString();
                fields[3].fieldName = "AUTH_BY1I";
                fields[3].value = "ADMIN";

                submitRequest.screenFields = fields;

                submitRequest.screenKey = "1"; // OK
                screenReply = screenService.submit(SSContextClass, submitRequest);

                screenName = screenReply.mapName;
                errorMsg = screenReply.message;

                if (errorMsg.Trim() != "" && !screenReply.functionKeys.Contains("XMIT-Confirm"))
                {
                    throw new PXException(errorMsg.Trim());
                }

                if (screenName != "MSM156A")
                {
                    throw new PXException(CustomMessage.NotMSM156A);
                }

                ScreenNameValueDTO[] fields156 = {
                    new ScreenNameValueDTO(),
                    new ScreenNameValueDTO(),
                    new ScreenNameValueDTO(),
                    new ScreenNameValueDTO()
                };
                string receiptRef = pOReceipt.ReceiptNbr != null ? pOReceipt.ReceiptNbr.Trim() : " ";
                string cancelValue = Math.Round((pOReceiptLine.CuryExtCost * -1) ?? 0, 2).ToString().Trim();
                fields156[0].fieldName = "VALUE_RECVD1I";
                fields156[0].value = cancelValue;
                fields156[1].fieldName = "RECEIPT_REF1I";
                fields156[1].value = "S-" + receiptRef + "RT";
                fields156[2].fieldName = "RECEIPT_DATE1I";
                fields156[2].value = DateTime.Now.ToString("yyyyMMdd");
                fields156[3].fieldName = "ANSWER1I";
                fields156[3].value = "N";

                submitRequest.screenFields = fields156;

                submitRequest.screenKey = "1"; // OK
                screenReply = screenService.submit(SSContextClass, submitRequest);

                screenName = screenReply.mapName;
                errorMsg = screenReply.message;

                if (screenReply.functionKeys.Contains("XMIT-Confirm"))
                {
                    submitRequest.screenKey = "1"; // OK
                    screenReply = screenService.submit(SSContextClass, submitRequest);

                    screenName = screenReply.mapName;
                    errorMsg = screenReply.message;
                }

                screenService.positionToMenu(SSContextClass);

                result = "OK";
            }
            catch (Exception ex)
            {
                result = ex.Message;
                throw new PXException(ex.Message);
            }

            return result;
        }
Exemplo n.º 6
0
        string cancelPOGoods(POReceipt pOReceipt, string pONbr, List<POReceiptLine> receiptLines)
        {
            string result = "";
            string transID = "";

            try
            {
                foreach (POReceiptLine pOReceiptLine in receiptLines)
                {
                    ClientConversation.authenticate(userName, password);
                    TransactionService transactionService = new TransactionService()
                    {
                        Timeout = sessionTimeout,
                        Url = $"{urlPrefix(dbName)}TransactionService"
                    };

                    PLNSC.TransactionRef.OperationContext transContext = new PLNSC.TransactionRef.OperationContext()
                    {
                        district = districtCode,
                        position = positionID,
                        maxInstances = maxInstance
                    };

                    transID = transactionService.begin(transContext);

                    PurchaseOrderReceiptService purchaseOrderReceiptService = new PurchaseOrderReceiptService()
                    {
                        Timeout = sessionTimeout,
                        Url = $"{urlPrefix(dbName)}PurchaseOrderReceiptService"
                    };

                    PLNSC.POReceiptRef.OperationContext cancelPOContext = new PLNSC.POReceiptRef.OperationContext()
                    {
                        district = transContext.district,
                        position = transContext.position,
                        maxInstances = transContext.maxInstances,
                        returnWarnings = transContext.returnWarnings,
                        trace = transContext.trace,
                        transaction = transID
                    };

                    string pOLineNbr = pOReceiptLine.POLineNbr.ToString() ?? string.Empty;

                    PurchaseOrderReceiptSearchParam searchParam = new PurchaseOrderReceiptSearchParam()
                    {
                        purchaseOrderNumber = pOReceiptLine.PONbr,
                        purchaseOrderItemNumber = pOLineNbr
                    };

                    PurchaseOrderReceiptServiceResult[] searchResult = purchaseOrderReceiptService.search(cancelPOContext, searchParam, null);

                    if (searchResult.Length > 0)
                    {
                        for (int j = 0; j < searchResult.Length;j++)
                        {
                            PLNSC.POReceiptRef.Error[] cancelPOErrors = searchResult[j].errors;
                            PLNSC.POReceiptRef.Message[] cancelPOMessages = searchResult[j].informationalMessages;

                            if (cancelPOErrors.Length > 0)
                            {
                                for (int k = 0; k < cancelPOErrors.Length; k++)
                                {
                                    string errorMessage = (k + 1) + ". " + cancelPOErrors[k].messageText;
                                    result += errorMessage;
                                }
                            }
                            PurchaseOrderReceiptDTO purchaseOrderReceiptDTO = searchResult[j].purchaseOrderReceiptDTO;
                            string receiptRef = purchaseOrderReceiptDTO.receiptReference != null ? purchaseOrderReceiptDTO.receiptReference.Trim() : " ";
                            decimal cancelQty = pOReceiptLine.ReceiptQty ?? 0;
                            PurchaseOrderReceiptDTO canceReciptlDTO = new PurchaseOrderReceiptDTO()
                            {
                                purchaseOrderNumber = purchaseOrderReceiptDTO.purchaseOrderNumber,
                                purchaseOrderItemNumber = purchaseOrderReceiptDTO.purchaseOrderItemNumber,
                                receiptReferenceCancel = "G-" + pOReceipt.ReceiptNbr.Trim() + "RT",
                                districtCode = "SC01",
                                cancelledBy = "ADMIN",
                                isOrderComplete = false,
                                isOrderCompleteSpecified = true,
                                custodianId = purchaseOrderReceiptDTO.custodianId,
                                purchaseRequisitionNumber = purchaseOrderReceiptDTO.purchaseRequisitionNumber,
                                cancelQuantity = cancelQty,
                                cancelQuantitySpecified = true,
                                receiptReference = receiptRef,
                                warehouseId = purchaseOrderReceiptDTO.warehouseId != null ? purchaseOrderReceiptDTO.warehouseId.Trim() : "MAIN",
                                changeNumber = purchaseOrderReceiptDTO.changeNumber,
                                correlationId = purchaseOrderReceiptDTO.correlationId,
                                freightCode = purchaseOrderReceiptDTO.freightCode,
                                requisitionDistrict = purchaseOrderReceiptDTO.requisitionDistrict,
                                receivedBy = purchaseOrderReceiptDTO.receivedBy,
                                receiptNumber_2 = purchaseOrderReceiptDTO.receiptNumber_2,
                                quantityNotInvoiced = purchaseOrderReceiptDTO.quantityNotInvoiced,
                                quantityNotInvoicedSpecified = true,

                            };
                            PurchaseOrderReceiptServiceResult purchaseOrderReceiptServiceResult = purchaseOrderReceiptService.cancel(cancelPOContext, canceReciptlDTO);
                            PLNSC.POReceiptRef.Error[] cancelReceiptError = purchaseOrderReceiptServiceResult.errors;
                            if (cancelReceiptError.Length > 0)
                            {
                                result = cancelReceiptError[0].messageText;
                                transContext.transaction = transID;
                                transactionService.rollback(transContext);
                            }
                            else
                            {
                                result = "OK";
                                transContext.transaction = transID;
                                transactionService.commit(transContext);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return result;
        }
Exemplo n.º 7
0
        string receiptPOGoods(POReceipt pOReceipt, string pONbr, List<POReceiptLine> receiptLines)
        {
            string result = "";
            string transID = "";

            bool isOverSupply = false;

            try
            {
                ClientConversation.authenticate(userName, password);

                TransactionService transactionService = new TransactionService()
                {
                    Timeout = sessionTimeout,
                    Url = $"{urlPrefix(dbName)}TransactionService"
                };

                PLNSC.TransactionRef.OperationContext transContext = new PLNSC.TransactionRef.OperationContext()
                {
                    district = districtCode,
                    position = positionID,
                    maxInstances = maxInstance
                };

                transID = transactionService.begin(transContext);

                ReceiptDocumentService receipt = new ReceiptDocumentService()
                {
                    Timeout = sessionTimeout,
                    Url = $"{urlPrefix(dbName)}ReceiptDocumentService"
                };

                PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemService receiptPurchaseOrderItemService = new PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemService()
                {
                    Timeout = sessionTimeout,
                    Url = $"{urlPrefix(dbName)}ReceiptPurchaseOrderItemService"
                };

                PLNSC.ReceiptPurchaseOrderItemRef.OperationContext receiptPOItemContext = new PLNSC.ReceiptPurchaseOrderItemRef.OperationContext()
                {
                    district = transContext.district,
                    position = transContext.position,
                    maxInstances = transContext.maxInstances,
                    returnWarnings = transContext.returnWarnings,
                    trace = transContext.trace,
                    transaction = transID
                };

                PLNSC.ReceiptDocumentService.OperationContext receiptContext = new PLNSC.ReceiptDocumentService.OperationContext()
                {
                    district = transContext.district,
                    position = transContext.position,
                    maxInstances = transContext.maxInstances,
                    returnWarnings = transContext.returnWarnings,
                    trace = transContext.trace,
                    transaction = transID
                };

                var userID = PXAccess.GetUserID();
                EPEmployee ePEmployee = PXSelect<EPEmployee, Where<EPEmployee.userID, Equal<Required<EPEmployee.userID>>>>.Select(Base, PXAccess.GetUserID());
                string receivedByUser = ePEmployee.AcctCD.Trim() ?? "ADMIN";

                PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemSearchParam receiptPurchaseOrderItemSearchParam = new PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemSearchParam()
                {
                    documentDistrictCode = "SC01",
                    documentNumber = pONbr,
                    documentTypeDescription = "POP",
                    isReceiveAll = false
                };

                PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemDTO restartParam = new PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemDTO()
                {
                    documentNumber = "",
                    documentDistrictCode = "",
                    documentItem = "",
                    documentTypeDescription = "",
                    receiptDocumentType = ""
                };

                PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemServiceResult[] searchResult = receiptPurchaseOrderItemService.search(receiptPOItemContext, receiptPurchaseOrderItemSearchParam, restartParam);

                if (searchResult.Length > 0)
                {
                    PLNSC.ReceiptPurchaseOrderItemRef.Error[] searchErrors = searchResult[0].errors;
                    PLNSC.ReceiptPurchaseOrderItemRef.Message[] searchMsg = searchResult[0].informationalMessages;
                    if (searchErrors.Length > 0)
                    {
                        result = searchErrors[0].messageText;
                        transContext.transaction = transID;
                        transactionService.rollback(transContext);
                        return result;
                    }
                    
                    ReceiptPurchaseOrderItemDTO[] requestItem = new ReceiptPurchaseOrderItemDTO[searchResult.Length];
                    int arrIndex = 0;
                    foreach (PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemServiceResult receiptPurchaseOrderItemServiceResult in searchResult)
                    {
                        PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemDTO lineReceipt = receiptPurchaseOrderItemServiceResult.receiptPurchaseOrderItemDTO;

                        string testPOReceiptLine = Right("000" + lineReceipt.documentItem.Trim(), 3);
                        string receiptLine = lineReceipt.documentNumber != null ? testPOReceiptLine : "001";
                        decimal receiptQty = 0;
                        pONbr = lineReceipt.documentNumber != null ? lineReceipt.documentNumber.Trim() : " ";

                        foreach (POReceiptLine pOReceiptLine in receiptLines)
                        {
                            string poNbr = pOReceiptLine.PONbr.Trim();
                            string poLine = Right("000" + pOReceiptLine.POLineNbr.ToString(), 3);
                            if (poNbr == pONbr && poLine == receiptLine)
                            {
                                receiptQty = pOReceiptLine.ReceiptQty ?? 0;
                                decimal origOrderQty = pOReceiptLine.OrigOrderQty ?? 0;
                                decimal openOrderQty = pOReceiptLine.OpenOrderQty ?? 0;
                                decimal outstandingQty = openOrderQty != 0 ? openOrderQty : origOrderQty;
                                if (receiptQty > outstandingQty)
                                {
                                    isOverSupply = true;
                                }
                                else
                                {
                                    isOverSupply = false;
                                }
                            }
                        }

                        requestItem[arrIndex] = new ReceiptPurchaseOrderItemDTO()
                        {
                            documentNumber = lineReceipt.documentNumber.Trim() ?? " ",
                            custodianId = lineReceipt.custodianId.Trim() ?? " ",
                            documentItem = receiptLine,
                            receiptQuantity = receiptQty,
                            receiptQuantitySpecified = true,
                            documentTypeDescription = lineReceipt.documentTypeDescription.Trim() ?? " ",
                            documentType = lineReceipt.documentType.Trim() ?? " ",
                            deliveryLocation = lineReceipt.deliveryLocation.Trim() ?? " ",
                            isReceive = true,
                            isReceiveSpecified = true,
                            isCompleteItem = false,
                            isCompleteItemSpecified = true,
                            isOverSupplyItem = isOverSupply,
                            isOverSupplyItemSpecified = true,
                            isBinCodeDisabled = lineReceipt.isBinCodeDisabled,
                            isBinCodeDisabledSpecified = true,
                            isCategoryCodeDisabled = lineReceipt.isCategoryCodeDisabled,
                            isCategoryCodeDisabledSpecified = true,
                            receiptDocumentType = lineReceipt.receiptDocumentType.Trim() ?? " ",
                            receivingDistrictCode = lineReceipt.receivingDistrictCode.Trim() ?? " ",
                            receivingWarehouseId = lineReceipt.receivingWarehouseId.Trim() ?? " ",
                            requestedByEmployeeId = receivedByUser,
                            purchaseRequisition = lineReceipt.purchaseRequisition.Trim() ?? " ",
                            unitOfPurchase = lineReceipt.unitOfPurchase.Trim() ?? " ",
                            unitOfIssueOutstanding = lineReceipt.unitOfIssueOutstanding,
                            unitOfIssueOutstandingSpecified = true,
                            unitOfMeasure = lineReceipt.unitOfMeasure.Trim() ?? " ",
                            unitOfPurchaseOutstanding = lineReceipt.unitOfPurchaseOutstanding,
                            unitOfPurchaseOutstandingSpecified = true
                        };
                        arrIndex += 1;
                    }

                    ReceiptDocumentDTO request = new ReceiptDocumentDTO()
                    {
                        documentNumber = pONbr,
                        receiptReference = "G-" + pOReceipt.ReceiptNbr.Trim() + "RC",
                        receiptPurchaseOrderItemDTOs = requestItem,
                        receiptDate = DateTime.Now,
                        receiptDateSpecified = true,
                        isReceiveAll = false,
                        isReceiveAllSpecified = true,
                        receivedBy = receivedByUser,
                        receivedByPosition = "INTPO",
                        receivingDistrictCode = "SC01",
                        documentDistrictCode = "SC01",
                        documentTypeDescription = "POP"
                    };

                    ReceiptDocumentServiceResult receiptDocumentServiceResult = receipt.update(receiptContext, request);
                    PLNSC.ReceiptDocumentService.Error[] updErrors = receiptDocumentServiceResult.errors;
                    PLNSC.ReceiptDocumentService.Message[] updMessages = receiptDocumentServiceResult.informationalMessages;

                    if (updErrors.Length > 0)
                    {
                        result = updErrors[0].messageText;
                        transContext.transaction = transID;
                        transactionService.rollback(transContext);
                    }
                    else
                    {
                        result = "OK";
                        transContext.transaction = transID;
                        transactionService.commit(transContext);
                    }
                }
                else
                {
                    return "No Item To receive or All Item has already been received";
                }
                //ReceiptPurchaseOrderItemDTO[] requestItem = new ReceiptPurchaseOrderItemDTO[receiptLines.Count];
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return result;
        }