예제 #1
0
        protected void _(Events.FieldUpdated <LumShipmentPlan.customer> e)
        {
            var row = e.Row as LumShipmentPlan;

            if (e.NewValue != null && row != null)
            {
                SOOrder soOrder = SOOrder.PK.Find(this, row.OrderType, row.OrderNbr);

                Order.Cache.SetValueExt(soOrder, PX.Objects.CS.Messages.Attribute + ENDC, e.NewValue);
                Order.Update(soOrder);
            }
        }
예제 #2
0
        protected virtual void complete()
        {
            // Get the current order from the cache.
            RSSVWorkOrder row = WorkOrders.Current;

            // Change the order status to Completed.
            row.Status = WorkOrderStatusConstants.Completed;
            // Assign the current date to the DateCompleted field.
            row.DateCompleted = this.Accessinfo.BusinessDate;
            // Update the data record in the cache.
            WorkOrders.Update(row);

            //Modify the number of assigned orders for the employee
            RSSVEmployeeWorkOrderQty employeeNbrOfOrders =
                new RSSVEmployeeWorkOrderQty();

            employeeNbrOfOrders.Userid = row.Assignee;
            employeeNbrOfOrders.NbrOfAssignedOrders = -1;
            Quantity.Insert(employeeNbrOfOrders);

            // Trigger the Save action to save changes in the database.
            Actions.PressSave();
        }
예제 #3
0
        protected IEnumerable updateMaterial(PXAdapter adapter)
        {
            var data = Bom.Select();

            data.Where(x => ((AMBomMatl)x).BOMID == "210293").ToList()
            .ForEach(x =>
            {
                var row = x.GetItem <AMBomMatl>();
                Bom.SetValueExt <AMBomMatl.qtyReq>(row, (decimal?)0.006666);
                Bom.Update(row);
            });
            this.Actions.PressSave();
            return(adapter.Get());
        }
예제 #4
0
        public virtual void CloseInvoiceAndClearBalances(ARRegister ardoc, int?adjNbr, CloseInvoiceAndClearBalancesDelegate baseMethod)
        {
            RSSVWorkOrder order =
                SelectFrom <RSSVWorkOrder> .Where <RSSVWorkOrder.invoiceNbr.
                                                   IsEqual <ARRegister.refNbr.FromCurrent> > .View.SelectSingleBound(Base, new[] { ardoc });

            if (order != null)
            {
                order.Status = WorkOrderStatusConstants.Paid;
                UpdWorkOrder.Update(order); // update cache
                // no need to call the Persist method
            }
            baseMethod(ardoc, adjNbr);
        }
예제 #5
0
        //Copy repair items and labor items from the Services and Prices form.
        protected virtual void _(Events.RowUpdated <RSSVWorkOrder> e)
        {
            if (WorkOrders.Cache.GetStatus(e.Row) == PXEntryStatus.Inserted &&
                !e.Cache.ObjectsEqual <RSSVWorkOrder.serviceID, RSSVWorkOrder.deviceID>(e.Row, e.OldRow))
            {
                if (e.Row.ServiceID != null && e.Row.DeviceID != null &&
                    !IsCopyPasteContext && RepairItems.Select().Count == 0 &&
                    Labor.Select().Count == 0)
                {
                    //Retrieve the default repair items
                    var repairItems = SelectFrom <RSSVRepairItem> .
                                      Where <RSSVRepairItem.serviceID.IsEqual <RSSVWorkOrder.serviceID.FromCurrent> .
                                             And <RSSVRepairItem.deviceID.IsEqual <RSSVWorkOrder.deviceID.FromCurrent> > >
                                      .View.Select(this);

                    //Insert default repair items
                    foreach (RSSVRepairItem item in repairItems)
                    {
                        RSSVWorkOrderItem orderItem = RepairItems.Insert();
                        orderItem.RepairItemType = item.RepairItemType;
                        orderItem.InventoryID    = item.InventoryID;
                        orderItem.BasePrice      = item.BasePrice;
                        RepairItems.Update(orderItem);
                    }

                    //Retrieve the default labor items
                    var laborItems = SelectFrom <RSSVLabor> .
                                     Where <RSSVLabor.serviceID.IsEqual <RSSVWorkOrder.serviceID.FromCurrent> .
                                            And <RSSVLabor.deviceID.IsEqual <RSSVWorkOrder.deviceID.FromCurrent> > >
                                     .View.Select(this);

                    //Insert the default labor items
                    foreach (RSSVLabor item in laborItems)
                    {
                        RSSVWorkOrderLabor orderItem = new RSSVWorkOrderLabor();
                        orderItem.InventoryID  = item.InventoryID;
                        orderItem              = Labor.Insert(orderItem);
                        orderItem.DefaultPrice = item.DefaultPrice;
                        orderItem.Quantity     = item.Quantity;
                        orderItem.ExtPrice     = item.ExtPrice;
                        Labor.Update(orderItem);
                    }
                }
            }
        }
예제 #6
0
        //public string GetQREncrypter(STWNGUITran sGUITran)
        //{
        //    com.tradevan.qrutil.QREncrypter qrEncrypter = new com.tradevan.qrutil.QREncrypter();

        //    string result;

        //    try
        //    {
        //        string[][] abc = new string[1][];

        //        TWNGUIPreferences gUIPreferences = PXSelect<TWNGUIPreferences>.Select(this);

        //        if (string.IsNullOrEmpty(gUIPreferences.AESKey))
        //        {
        //            throw new MissingFieldException(string.Format("{0} {1}", nameof(TWNGUIPreferences.AESKey), PX.Data.InfoMessages.IsNull));
        //        }

        //        // a) Invoice number = GUITrans.GUINbr
        //        result = qrEncrypter.QRCodeINV(sGUITran.GUINbr,
        //                                       // b) Invoice date = GUITrans.GUIDate(If it is 2019 / 12 / 01, please change to 1081201.  107 = YYYY – 1911)
        //                                       TWNGenZeroTaxRateMedFile.GetTWNDate(sGUITran.GUIDate.Value),
        //                                       // c) Invoice time = “hhmmss” of GUITrans.GUIDate
        //                                       sGUITran.GUIDate.Value.ToString("hhmmss"),
        //                                       // d) Random number = If GUITrans.BatchNbr is not null then Right(Guitrans.bachNbrr,4) else Right(Guitrans.OrderNbrr, 4)
        //                                       string.IsNullOrEmpty(sGUITran.BatchNbr) ? sGUITran.BatchNbr.Substring(sGUITran.BatchNbr.Length - 4) : sGUITran.OrderNbr.Substring(sGUITran.OrderNbr.Length - 4),
        //                                       // e) Sales amount = GUITrans.Amount (No thousands separator, no decimal places)
        //                                       (int)sGUITran.NetAmount.Value,
        //                                       // f) Tax amount = GUITrans.Taxamount  (No thousands separator, no decimal places)
        //                                       (int)sGUITran.TaxAmount.Value,
        //                                       // g) Total amount = GUITrans.Amount + GUITrans.TaxAmount(No thousands separator, no decimal places)
        //                                       (int)(sGUITran.NetAmount + sGUITran.TaxAmount).Value,
        //                                       // h) Buyer identifier = GUITrans.TaxNbr(If it's blank or null, please use “00000000”)
        //                                       string.IsNullOrEmpty(sGUITran.TaxNbr) ? "00000000" : sGUITran.TaxNbr,
        //                                       // i) Representative identifier = “00000000”
        //                                       "00000000",
        //                                       // j) Sales identifier = GUITrans.OurTaxNbr
        //                                       sGUITran.OurTaxNbr,
        //                                       // k) Business identifier = GUITrans.OurTaxNbr
        //                                       sGUITran.OurTaxNbr,
        //                                       // l) AESKEY = GUIParameters.AESKEY
        //                                       gUIPreferences.AESKey);
        //    }
        //    catch
        //    {
        //        throw;
        //    }

        //    return result;
        //}

        public void CreateGUITrans(STWNGUITran sGUITran)
        {
            TWNGUITrans row = ViewGUITrans.Cache.CreateInstance() as TWNGUITrans;

            row.GUIFormatcode = sGUITran.VATCode;
            row.GUINbr        = sGUITran.GUINbr;
            row.SequenceNo    = SequenceNo;

            row = ViewGUITrans.Insert(row);

            row.GUIStatus     = sGUITran.GUIStatus;
            row.Branch        = GetBranchCD(sGUITran.BranchID);
            row.GUIDirection  = sGUITran.GUIDirection;
            row.GUIDate       = row.GUIDecPeriod = sGUITran.GUIDate;
            row.GUITitle      = sGUITran.GUITitle;
            row.TaxZoneID     = sGUITran.TaxZoneID;
            row.TaxCategoryID = sGUITran.TaxCategoryID;
            row.TaxID         = sGUITran.TaxID;
            row.VATType       = GetVATType(row.TaxID);
            row.TaxNbr        = sGUITran.TaxNbr;
            row.OurTaxNbr     = sGUITran.OurTaxNbr;
            row.NetAmount     = row.NetAmtRemain = sGUITran.NetAmount;
            row.TaxAmount     = row.TaxAmtRemain = sGUITran.TaxAmount;
            row.CustVend      = sGUITran.AcctCD;
            row.CustVendName  = sGUITran.AcctName;
            row.DeductionCode = sGUITran.DeductionCode;
            row.TransDate     = base.Accessinfo.BusinessDate;
            row.EGUIExcluded  = sGUITran.eGUIExcluded;
            row.Remark        = sGUITran.Remark;
            row.BatchNbr      = sGUITran.BatchNbr;
            row.OrderNbr      = sGUITran.OrderNbr;
            row.CarrierType   = sGUITran.CarrierType;
            row.CarrierID     = sGUITran.CarrierID;
            row.NPONbr        = sGUITran.NPONbr;
            row.B2CPrinted    = sGUITran.B2CPrinted;
            //row.QREncrypter   = sGUITran.GUIDirection.Equals(TWNGUIDirection.Issue) && sGUITran.NetAmount > 0 && sGUITran.eGUIExcluded.Equals(false) ? GetQREncrypter(sGUITran) : null;

            ViewGUITrans.Update(row);

            this.Actions.PressSave();
        }
예제 #7
0
        public void Persist(PersistDelegate baseMethod)
        {
            baseMethod();

            APRegister    doc    = Base.APDocument.Current;
            APRegisterExt docExt = PXCache <APRegister> .GetExtension <APRegisterExt>(doc);

            // Check for document and released flag
            if (TWNGUIValidation.ActivateTWGUI(Base) == true &&
                doc != null &&
                doc.Released == true &&
                doc.DocType.IsIn(APDocType.Invoice, APDocType.DebitAdj))
            {
                //if (Base.APTaxTran_TranType_RefNbr.Current == null)
                //{
                //    throw new PXException(TWMessages.NoInvTaxDtls);
                //}

                foreach (TWNManualGUIAPBill row in SelectFrom <TWNManualGUIAPBill> .Where <TWNManualGUIAPBill.docType.IsEqual <@P.AsString>
                                                                                           .And <TWNManualGUIAPBill.refNbr.IsEqual <@P.AsString> > > .View.Select(Base, doc.DocType, doc.RefNbr))
                {
                    // Avoid standard logic calling this method twice and inserting duplicate records into TWNGUITrans.
                    if (CountExistedRec(Base, row.GUINbr, row.VATInCode, doc.RefNbr) >= 1)
                    {
                        return;
                    }

                    if (Tax.PK.Find(Base, row.TaxID).GetExtension <TaxExt>().UsrTWNGUI != true)
                    {
                        continue;
                    }

                    Vendor vendor = Vendor.PK.Find(Base, row.VendorID);

                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        TWNReleaseProcess rp = PXGraph.CreateInstance <TWNReleaseProcess>();

                        TWNGUITrans tWNGUITrans = rp.InitAndCheckOnAP(row.GUINbr, row.VATInCode);

                        rp.CreateGUITrans(new STWNGUITran()
                        {
                            VATCode       = row.VATInCode,
                            GUINbr        = row.GUINbr,
                            GUIStatus     = TWNGUIStatus.Used,
                            BranchID      = Base.APTran_TranType_RefNbr.Current.BranchID,
                            GUIDirection  = TWNGUIDirection.Receipt,
                            GUIDate       = row.GUIDate,
                            GUITitle      = vendor?.AcctName,
                            TaxZoneID     = row.TaxZoneID,
                            TaxCategoryID = row.TaxCategoryID,
                            TaxID         = row.TaxID,
                            TaxNbr        = row.TaxNbr,
                            OurTaxNbr     = row.OurTaxNbr,
                            NetAmount     = row.NetAmt,
                            TaxAmount     = row.TaxAmt,
                            AcctCD        = vendor?.AcctCD,
                            AcctName      = vendor?.AcctName,
                            DeductionCode = row.Deduction,
                            Remark        = row.Remark,
                            BatchNbr      = doc.BatchNbr,
                            OrderNbr      = doc.RefNbr
                        });

                        if (tWNGUITrans != null)
                        {
                            if (tWNGUITrans.NetAmtRemain < row.NetAmt)
                            {
                                throw new PXException(TWMessages.RemainAmt);
                            }

                            ViewGUITrans.SetValueExt <TWNGUITrans.netAmtRemain>(tWNGUITrans, (tWNGUITrans.NetAmtRemain -= row.NetAmt));
                            ViewGUITrans.SetValueExt <TWNGUITrans.taxAmtRemain>(tWNGUITrans, (tWNGUITrans.TaxAmtRemain -= row.TaxAmt));

                            tWNGUITrans = ViewGUITrans.Update(tWNGUITrans);
                        }

                        // Manually Saving as base code will not call base graph persis.
                        ViewGUITrans.Cache.Persist(PXDBOperation.Insert);
                        ViewGUITrans.Cache.Persist(PXDBOperation.Update);

                        ts.Complete(Base);
                    }
                }
            }

            // Triggering after save events.
            ViewGUITrans.Cache.Persisted(false);
        }