Ejemplo n.º 1
0
        /// <summary>
        /// The new GUI number comes from a GUI invoice and multiple GUI credit notes, merge the same inventory, and then summarize the quantity.
        /// Insert the merged result into the new history table.
        /// </summary>
        public virtual void CreateInvTranHist()
        {
            Dictionary <string, decimal?> dic1 = new Dictionary <string, decimal?>();

            foreach (ARTran row in RetriveARTran(this, Document.Current.VATOutCode, Document.Current.GUINbr))
            {
                dic1.Add(string.Format("{0}-{1}", row.InventoryID, row.LineNbr), row.Qty);
            }

            Dictionary <string, decimal?> dic2 = new Dictionary <string, decimal?>();

            string[] cNGUINbrs = !string.IsNullOrEmpty(Document.Current.CNGUINbr) ? Document.Current.CNGUINbr.Split(';') : new string[1] {
                string.Empty
            };

            for (int i = 0; i < cNGUINbrs.Length; i++)
            {
                string cNGUINbr = cNGUINbrs[i].TrimStart();

                foreach (ARTran row in SelectFrom <ARTran> .InnerJoin <TWNGUITrans> .On <ARTran.refNbr.IsEqual <TWNGUITrans.orderNbr> >
                         .Where <TWNGUITrans.gUIFormatcode.IsEqual <@P.AsString>
                                 .And <TWNGUITrans.gUINbr.IsEqual <@P.AsString>
                                       .And <TWNGUITrans.sequenceNo.IsEqual <@P.AsInt> > > >
                         .OrderBy <Asc <ARTran.inventoryID> > .View.Select(this, Document.Current.CNVATOutCode, cNGUINbr, i))
                {
                    dic2.Add(string.Format("{0}-{1}", row.InventoryID, string.IsNullOrEmpty(row.OrigInvoiceNbr) ? row.SOOrderLineNbr : row.OrigInvoiceLineNbr), -row.Qty);
                }
            }

            var resDict = dic1.Concat(dic2).GroupBy(x => x.Key).ToDictionary(x => x.Key, x => x.Sum(y => y.Value));

            foreach (ARTran row in RetriveARTran(this, Document.Current.VATOutCode, Document.Current.GUINbr))
            {
                int?lineNbr = string.IsNullOrEmpty(row.OrigInvoiceNbr) ? row.SOOrderLineNbr : row.OrigInvoiceLineNbr;

                TWNInvTranHist tranHist = new TWNInvTranHist();

                tranHist.RequestID      = Document.Current.RequestID;
                tranHist.InvoiceType    = row.TranType;
                tranHist.InvoiceNbr     = row.RefNbr;
                tranHist.InvTranLineNbr = row.LineNbr;
                tranHist.InventoryID    = row.InventoryID;
                if (resDict.ContainsKey(string.Format("{0}-{1}", tranHist.InventoryID, row.LineNbr)))
                {
                    tranHist.Qty = resDict[string.Format("{0}-{1}", tranHist.InventoryID, row.LineNbr)];
                }
                tranHist.UnitPrice = row.CuryUnitPrice;
                tranHist.TranAmt   = tranHist.Qty * tranHist.UnitPrice;

                InvTranHist.Insert(tranHist);
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 3
0
        public virtual IEnumerable addUsers(PXAdapter adapter)
        {
            var users = UsersForAddition.Select().Where(a => a.GetItem <Contact>().Selected == true).ToList();

            foreach (var user in users)
            {
                var surveyUser = new SurveyUser();
                surveyUser.Active    = true;
                surveyUser.SurveyID  = SurveyCurrent.Current.SurveyID;
                surveyUser.ContactID = user.GetItem <Contact>().ContactID;
                surveyUser           = SurveyUsers.Insert(surveyUser);
            }

            return(adapter.Get());
        }
Ejemplo n.º 4
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);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public virtual void CreateNewGUITran(TWNGUITrans refTran)
        {
            TWNGUITrans newTran = PXCache <TWNGUITrans> .CreateCopy(refTran);

            newTran.GUIStatus            = TWNGUIStatus.Used;
            newTran.GUINbr               = Document.Current.NewGUINbr;
            newTran.GUIDate              = Document.Current.NewGUIDate;
            newTran.OrderNbr             = Document.Current.RequestID;
            newTran.NetAmount            = newTran.NetAmtRemain = Document.Current.CalcNetAmt;
            newTran.TaxAmount            = newTran.TaxAmtRemain = Document.Current.CalcTaxAmt;
            newTran.IdentityID           = null;
            newTran.BatchNbr             = null;
            newTran.EGUIExported         = null;
            newTran.EGUIExportedDateTime = null;
            newTran.NoteID               = null;

            GUIInvoice.Insert(newTran);
        }
        protected override void SyncWithDocumentCart(ScanHeader header, ScanLine line, INCartSplit cartSplit, decimal?qty)
        {
            INRegisterCart registerCart = RegisterCart.Current;

            if (registerCart == null)
            {
                registerCart = RegisterCart.Insert();
            }

            RegisterCart.Cache.SetValue <INRegisterCart.docType>(registerCart, Register.DocType);
            RegisterCart.Cache.SetValue <INRegisterCart.refNbr>(registerCart, Register.RefNbr);

            SyncWithDocumentCartLine(header, line, cartSplit, qty);

            if (IsEmptyCart)
            {
                RegisterCart.Delete(registerCart);
            }
        }
Ejemplo n.º 7
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();
        }
        protected virtual void SyncWithDocumentCartLine(ScanHeader header, ScanLine line, INCartSplit cartSplit, decimal?qty)
        {
            bool emptyLine = line.Qty.GetValueOrDefault() == 0;

            INRegisterCartLine docCartLine = RegisterCartLines.Search <INRegisterCartLine.lineNbr>(line.LineNbr);

            if (docCartLine == null)
            {
                if (qty <= 0)
                {
                    throw new PXArgumentException(nameof(qty));
                }
                docCartLine = RegisterCartLines.Insert();
                RegisterCartLines.Cache.SetValue <INRegisterCartLine.cartSplitLineNbr>(docCartLine, cartSplit.SplitLineNbr);
            }
            docCartLine      = (INRegisterCartLine)RegisterCartLines.Cache.CreateCopy(docCartLine);
            docCartLine.Qty += qty;
            RegisterCartLines.Cache.Update(docCartLine);

            if (docCartLine.Qty == 0)
            {
                RegisterCartLines.Delete(docCartLine);
            }
        }