Beispiel #1
0
        string recordProjectActuals(SOOrder sOOrder)
        {
            string result  = "";
            string transID = "";

            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);

                string raisedDate = (sOOrder.OrderDate ?? DateTime.Now).ToString("yyyyMMdd");

                PLNSC.ProjectService.OperationContext projectOperationContext = new PLNSC.ProjectService.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance,
                    transaction  = transID
                };

                ProjectService projectService = new ProjectService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}ProjectService"
                };

                ProjectServiceActualsRequestDTO projectServiceActualsRequestDTO = new ProjectServiceActualsRequestDTO()
                {
                    actualStrDate = raisedDate,
                    districtCode  = "SC01",
                    projectNo     = sOOrder.OrderNbr.Trim()
                };

                ProjectServiceActualsReplyDTO            projectServiceActualsReplyDTO = projectService.actuals(projectOperationContext, projectServiceActualsRequestDTO);
                PLNSC.ProjectService.WarningMessageDTO[] actualErrors = projectServiceActualsReplyDTO.warningsAndInformation;
                if (actualErrors.Length > 0)
                {
                    result = actualErrors[0].message;
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Beispiel #2
0
        string modifyProject(SOOrder sOOrder)
        {
            int?customerSalesAcctId;
            int?customerSalesSubId;
            int?cogsAcctId;
            int?cogsSubId;
            int?invtAcctId;
            int?invtSubId;
            int?cARAccountID;

            string cogsAcctCd      = "";
            string cogsSubCd       = "";
            string invtAcctCd      = "";
            string invtSubCd       = "";
            string custSalesAcctCD = "";
            string custSalesSubCD  = "";
            string cARAccountCD    = string.Empty;
            string custCD          = "";
            string transID         = "";

            string result = "";

            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);

                BAccount2 customer = PXSelect <BAccount2,
                                               Where <BAccount2.bAccountID, Equal <Required <BAccount2.bAccountID> >,
                                                      And <BAccount2.defLocationID, Equal <Required <BAccount2.defLocationID> >,
                                                           And <BAccount.type, Equal <Required <BAccount.type> > > > > > .Select(Base, sOOrder.CustomerID, sOOrder.CustomerLocationID, "CU");

                Location custLocation = PXSelect <Location,
                                                  Where <Location.bAccountID, Equal <Required <Location.bAccountID> >,
                                                         And <Location.locationID, Equal <Required <Location.locationID> > > > > .Select(Base, sOOrder.CustomerID, sOOrder.CustomerLocationID);

                customerSalesAcctId = custLocation.CSalesAcctID;
                customerSalesSubId  = custLocation.CSalesSubID;
                cARAccountID        = custLocation.CARAccountID;

                Account custSalesAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, customerSalesAcctId);

                Account custARAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, cARAccountID);

                Sub custSalesSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, customerSalesSubId);

                custSalesAcctCD = custSalesAccount.AccountCD;
                custSalesSubCD  = custSalesSub.SubCD;
                cARAccountCD    = custARAccount.AccountCD;
                custCD          = customer.AcctCD.Trim();

                foreach (SOLine soLine in Base.Transactions.Select(sOOrder.OrderNbr))
                {
                    InventoryItem inventoryItem = PXSelect <InventoryItem,
                                                            Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, soLine.InventoryID);

                    cogsAcctId = inventoryItem.COGSAcctID;
                    cogsSubId  = inventoryItem.COGSSubID;
                    invtAcctId = inventoryItem.InvtAcctID;
                    invtSubId  = inventoryItem.InvtSubID;

                    if (cogsAcctId == null && cogsSubId == null)
                    {
                        throw new PXException(CustomMessage.COGSAccountEmpty);
                    }

                    Account itemInvtAcct = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, invtAcctId);

                    Sub itemInvtSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, invtSubId);

                    Account invtCogsAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, cogsAcctId);

                    Sub invtCogsSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, cogsSubId);

                    cogsAcctCd = invtCogsAccount.AccountCD;
                    cogsSubCd  = invtCogsSub.SubCD;
                    invtAcctCd = itemInvtAcct.AccountCD;
                    invtSubCd  = itemInvtSub.SubCD;

                    if (cogsAcctId != null && cogsSubId != null)
                    {
                        break;
                    }
                }

                EPEmployee ePEmployee = PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > .Select(Base, sOOrder.OwnerID);

                string   originatorId         = ePEmployee != null ? ePEmployee.AcctCD : "ADMIN";
                string   stockItemAccount     = custSalesSubCD.Substring(0, 11).Trim() + cogsSubCd.Substring(11, 4).Trim(); // + cogsAcctCd.Trim();
                string   nonStockItemAccount  = cogsSubCd.Trim();                                                           // + cogsAcctCd.Trim();
                string   itemInventoryAccount = invtSubCd.Trim() + invtAcctCd.Trim();
                DateTime actStartDate         = sOOrder.OrderDate ?? DateTime.Now;
                string   raisedDate           = actStartDate.ToString("yyyyMMdd");
                string   planFinishDate       = (sOOrder.RequestDate ?? actStartDate.AddDays(60)).ToString("yyyyMMdd");

                try
                {
                    //ClientConversation.authenticate(userName, password);
                    PLNSC.ProjectService.OperationContext projectOperationContext = new PLNSC.ProjectService.OperationContext()
                    {
                        district     = districtCode,
                        position     = positionID,
                        maxInstances = maxInstance,
                        transaction  = transID
                    };

                    ProjectService projectService = new ProjectService()
                    {
                        Timeout = sessionTimeout,
                        Url     = $"{urlPrefix(dbName)}ProjectService"
                    };

                    ProjectServiceModifyRequestDTO projectRequest = new ProjectServiceModifyRequestDTO()
                    {
                        districtCode       = "SC01",
                        projectNo          = sOOrder.OrderNbr,
                        projDesc           = sOOrder.OrderDesc,
                        originatorId       = originatorId,
                        raisedDate         = raisedDate,
                        planFinDate        = planFinishDate,
                        accountCode        = cARAccountCD,
                        accountCodeEnabled = true
                    };

                    ProjectServiceModifyReplyDTO             projectReply       = projectService.modify(projectOperationContext, projectRequest);
                    PLNSC.ProjectService.WarningMessageDTO[] warningMessageDTOs = projectReply.warningsAndInformation;

                    if (warningMessageDTOs.Length > 0)
                    {
                        result = warningMessageDTOs[0].message;
                        transContext.transaction = transID;
                        transactionService.rollback(transContext);
                    }
                    else
                    {
                        result = "OK";
                        transContext.transaction = transID;
                        transactionService.commit(transContext);
                    }
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Beispiel #3
0
        string modifyProjectRefCodes(SOOrder sOOrder)
        {
            string transID = "";
            string result  = "";

            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);

                BAccount2 customer = PXSelect <BAccount2,
                                               Where <BAccount2.bAccountID, Equal <Required <BAccount2.bAccountID> >,
                                                      And <BAccount2.defLocationID, Equal <Required <BAccount2.defLocationID> >,
                                                           And <BAccount.type, Equal <Required <BAccount.type> > > > > > .Select(Base, sOOrder.CustomerID, sOOrder.CustomerLocationID, "CU");

                string custCD = customer.AcctCD.Trim();

                PLNSC.RefCodesRef.OperationContext refCodesOperation = new PLNSC.RefCodesRef.OperationContext()
                {
                    district     = transContext.district,
                    position     = transContext.position,
                    maxInstances = transContext.maxInstances
                };

                RefCodesService refCodesService = new RefCodesService()
                {
                    Timeout = transactionService.Timeout,
                    Url     = $"{urlPrefix(dbName)}RefCodesService"
                };

                RefCodesServiceModifyRequestDTO refCodesServiceModifyRequestDTO = new RefCodesServiceModifyRequestDTO()
                {
                    entityType  = "PRJ",
                    entityValue = transContext.district.Trim() + sOOrder.OrderNbr.Trim(),
                    refNo       = "001",
                    seqNum      = "001",
                    refCode     = sOOrder.CustomerOrderNbr.Trim()
                };

                RefCodesServiceModifyReplyDTO         refCodesServiceModifyReplyDTO = refCodesService.modify(refCodesOperation, refCodesServiceModifyRequestDTO);
                PLNSC.RefCodesRef.WarningMessageDTO[] refCodesErrors = refCodesServiceModifyReplyDTO.warningsAndInformation;
                if (refCodesErrors.Length > 0)
                {
                    result = refCodesErrors[0].message;
                    transactionService.rollback(transContext);
                }
                else
                {
                    if (sOOrder.CustomerID != null)
                    {
                        RefCodesServiceModifyRequestDTO refCodesServiceModifyRequestDTO2 = new RefCodesServiceModifyRequestDTO()
                        {
                            entityType  = "PRJ",
                            entityValue = transContext.district.Trim() + sOOrder.OrderNbr.Trim(),
                            refNo       = "002",
                            seqNum      = "001",
                            refCode     = custCD
                        };

                        RefCodesServiceModifyReplyDTO         refCodesServiceModifyReplyDTO2 = refCodesService.modify(refCodesOperation, refCodesServiceModifyRequestDTO2);
                        PLNSC.RefCodesRef.WarningMessageDTO[] refCodesErrors2 = refCodesServiceModifyReplyDTO2.warningsAndInformation;
                        if (refCodesErrors2.Length > 0)
                        {
                            result = refCodesErrors2[0].message;
                            transContext.transaction = transID;
                            transactionService.rollback(transContext);
                        }
                        else
                        {
                            result = "OK";
                            transContext.transaction = transID;
                            transactionService.commit(transContext);
                        }
                    }
                    else
                    {
                        result = "OK";
                        transContext.transaction = transID;
                        transactionService.commit(transContext);
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Beispiel #4
0
        string authoriseProject(SOOrder sOOrder)
        {
            string result  = "";
            string transID = "";

            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);

                PLNSC.ProjectService.OperationContext projectOperationContext = new PLNSC.ProjectService.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance,
                    transaction  = transID
                };

                ProjectService projectService = new ProjectService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}ProjectService"
                };

                ProjectServiceAuthoriseRequestDTO projectServiceAuthoriseRequestDTO = new ProjectServiceAuthoriseRequestDTO()
                {
                    authsdBy  = "ADMIN",
                    projectNo = sOOrder.OrderNbr.Trim()
                };

                ProjectServiceAuthoriseReplyDTO projectServiceAuthoriseReplyDTO = projectService.authorise(projectOperationContext, projectServiceAuthoriseRequestDTO);

                PLNSC.ProjectService.WarningMessageDTO[] authErrors = projectServiceAuthoriseReplyDTO.warningsAndInformation;

                if (authErrors.Length > 0)
                {
                    result = authErrors[0].message;
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Beispiel #5
0
        string createProjectEstimate(SOOrder sOOrder)
        {
            string transID = "";
            string result  = "";

            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);

                EPEmployee ePEmployee = PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > .Select(Base, sOOrder.OwnerID);

                string estimatorId = ePEmployee != null ? ePEmployee.AcctCD : "ADMIN";

                ProjectEstimateService projectEstimateService = new ProjectEstimateService()
                {
                    Timeout = transactionService.Timeout,
                    Url     = $"{urlPrefix(dbName)}ProjectEstimateService"
                };

                PLNSC.ProjectEstimateRef.OperationContext projectEstimateOperationContext = new PLNSC.ProjectEstimateRef.OperationContext()
                {
                    district     = transContext.district,
                    position     = transContext.position,
                    maxInstances = transContext.maxInstances
                };

                //ProjectEstimateDTO[] projectEstimateDTOs = new ProjectEstimateDTO[1];
                ProjectEstimateDTO projectEstimateDTO = new ProjectEstimateDTO()
                {
                    districtCode                       = transContext.district,
                    projectNo                          = sOOrder.OrderNbr.Trim(),
                    estimateBuildMethod                = "T",
                    estimatorId                        = estimatorId,
                    directEstimateCost                 = Math.Round(sOOrder.OrderTotal ?? 0, 2),
                    directEstimateCostSpecified        = true,
                    directUnallocFinPeriodEst          = Math.Round(sOOrder.OrderTotal ?? 0, 2),
                    directUnallocFinPeriodEstSpecified = true,
                    estimateSpreadCode                 = "A",
                    budgetCode                         = "RAB"
                };
                ProjectEstimateServiceResult projectEstimateServiceResult = projectEstimateService.update(projectEstimateOperationContext, projectEstimateDTO);
                //ProjectEstimateServiceResult[] projectEstimateServiceResults = projectEstimateService.multipleUpdate(projectEstimateOperationContext, projectEstimateDTOs);

                //ProjectEstimateServiceResult projectEstimateServiceResult = projectEstimateServiceResults[0];

                Error[] errors = projectEstimateServiceResult.errors;

                if (errors.Length > 0)
                {
                    result = errors[0].messageText.Trim();
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Beispiel #6
0
        string actualEffort(string sONbr)
        {
            string result  = string.Empty;
            string transID = "";

            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);

                ProjectService projectService = new ProjectService()
                {
                    Timeout = transactionService.Timeout,
                    Url     = $"{urlPrefix(dbName)}ProjectService"
                };

                PLNSC.ProjectService.OperationContext projectServiceContext = new PLNSC.ProjectService.OperationContext()
                {
                    district     = transContext.district,
                    position     = transContext.position,
                    maxInstances = transContext.maxInstances
                };

                ProjectServiceReadRequestDTO projectServiceReadRequestDTO = new ProjectServiceReadRequestDTO()
                {
                    districtCode = transContext.district,
                    projectNo    = sONbr.Trim()
                };

                ProjectServiceReadReplyDTO projectServiceReadReplyDTO = projectService.read(projectServiceContext, projectServiceReadRequestDTO);
                PLNSC.ProjectService.WarningMessageDTO[] errorRead    = projectServiceReadReplyDTO.warningsAndInformation;
                if (errorRead.Length > 0)
                {
                    result = errorRead[0].message.Trim();
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                    return(result);
                }

                string actStrDate = projectServiceReadReplyDTO.actualStrDate;

                ProjectServiceActualsRequestDTO projectServiceActualsRequestDTO = new ProjectServiceActualsRequestDTO()
                {
                    districtCode  = transContext.district,
                    projectNo     = sONbr.Trim(),
                    actualStrDate = actStrDate,
                    actualFinDate = DateTime.Now.ToString("yyyyMMdd")
                };
                ProjectServiceActualsReplyDTO projectServiceActualReplyDTO = projectService.actuals(projectServiceContext, projectServiceActualsRequestDTO);

                PLNSC.ProjectService.WarningMessageDTO[] errors = projectServiceActualReplyDTO.warningsAndInformation;

                if (errors.Length > 0)
                {
                    result = errors[0].message.Trim();
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                    return(result);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
Beispiel #7
0
        string finalizeEllipseProject(string sONbr)
        {
            string result  = string.Empty;
            string transID = "";

            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);

                ProjectService projectService = new ProjectService()
                {
                    Timeout = transactionService.Timeout,
                    Url     = $"{urlPrefix(dbName)}ProjectService"
                };

                PLNSC.ProjectService.OperationContext projectServiceContext = new PLNSC.ProjectService.OperationContext()
                {
                    district     = transContext.district,
                    position     = transContext.position,
                    maxInstances = transContext.maxInstances
                };

                //ProjectEstimateDTO[] projectEstimateDTOs = new ProjectEstimateDTO[1];
                ProjectServiceFinaliseRequestDTO projectServiceFinaliseRequestDTO = new ProjectServiceFinaliseRequestDTO()
                {
                    districtCode = transContext.district,
                    projectNo    = sONbr.Trim(),
                    finalCostInd = "Y"
                };
                ProjectServiceFinaliseReplyDTO projectServiceFinaliseReplyDTO = projectService.finalise(projectServiceContext, projectServiceFinaliseRequestDTO);
                //ProjectEstimateServiceResult[] projectEstimateServiceResults = projectEstimateService.multipleUpdate(projectEstimateOperationContext, projectEstimateDTOs);

                //ProjectEstimateServiceResult projectEstimateServiceResult = projectEstimateServiceResults[0];

                PLNSC.ProjectService.WarningMessageDTO[] errors = projectServiceFinaliseReplyDTO.warningsAndInformation;

                if (errors.Length > 0)
                {
                    result = errors[0].message.Trim();
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
Beispiel #8
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;
        }
Beispiel #9
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;
        }