Ejemplo n.º 1
0
        public virtual void CopySOLine()
        {
            SOLineSplitFilter current1 = this.LineSplitFilter.Current;
            SOLine            current2 = this.Base.Transactions.Current;
            SOLine            copy     = this.Base.Transactions.Cache.CreateCopy((object)current2) as SOLine;

            copy.LineNbr = copy.SortOrder = (int?)PXLineNbrAttribute.NewLineNbr <SOLine.lineNbr>(this.Base.Transactions.Cache, (object)this.Base.Document.Current);
            SOLine   soLine1   = copy;
            DateTime?shipDate  = current1.ShipDate;
            DateTime?nullable1 = shipDate.HasValue ? shipDate : current2.ShipDate;

            soLine1.ShipDate = nullable1;
            SOLine soLine2   = copy;
            bool?  poCreate  = current2.POCreate;
            bool   flag      = true;
            bool?  nullable2 = poCreate.GetValueOrDefault() == flag & poCreate.HasValue ? new bool?(!this.SOSplitHasPONbr(current2)) : current2.POCreate;

            soLine2.POCreate = nullable2;
            copy.NoteID      = new Guid?(Guid.NewGuid());
            copy.GetExtension <SOLineExt>().UsrOrigQty = current1.SplitQty;
            this.Base.Transactions.Insert(copy);
            copy.OrderQty = current1.SplitQty;
            this.Base.Transactions.Update(copy);
            if (!current2.GetExtension <SOLineExt>().UsrOrigQty.HasValue)
            {
                current2.GetExtension <SOLineExt>().UsrOrigQty = current2.OrderQty;
            }
            SOLine  soLine3  = current2;
            Decimal?orderQty = soLine3.OrderQty;
            Decimal?qty      = copy.Qty;

            soLine3.OrderQty = orderQty.HasValue & qty.HasValue ? new Decimal?(orderQty.GetValueOrDefault() - qty.GetValueOrDefault()) : new Decimal?();
            this.Base.Transactions.Update(current2);
        }
        public async Task <IActionResult> Edit(int id, [Bind("SOLineID,SOHeaderID,ProdukID,Quantity")] SOLine sOLine)
        {
            if (id != sOLine.SOLineID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sOLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SOLineExists(sOLine.SOLineID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProdukID"]   = new SelectList(_context.Set <Produk>(), "ProdukID", "NamaProduk", sOLine.ProdukID);
            ViewData["SOHeaderID"] = new SelectList(_context.SOHeader, "SOHeaderID", "SOHeaderID", sOLine.SOHeaderID);
            return(View(sOLine));
        }
        public virtual IAddressBase GetFromAddress(SOOrder order, SOLine line, GetFromAddressLineDelegate del)
        {
            int?SOID = GetSOIDRelated(line);

            if (SOID != null && line.SiteID == null)
            {
                IAddressBase returnAddress = null;

                returnAddress = PXSelectJoin <FSAddress,
                                              InnerJoin <
                                                  FSBranchLocation,
                                                  On <FSBranchLocation.branchLocationAddressID, Equal <FSAddress.addressID> >,
                                                  InnerJoin <FSServiceOrder,
                                                             On <FSServiceOrder.branchLocationID, Equal <FSBranchLocation.branchLocationID> > > >,
                                              Where <
                                                  FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> > > >
                                .Select(Base, SOID)
                                .RowCast <FSAddress>()
                                .FirstOrDefault();

                return(returnAddress);
            }

            return(del(order, line));
        }
        /// <summary>
        /// Update the parent blanket order line to reflect the child line qty changing
        /// </summary>
        /// <param name="childOrderLine">child row of blanket order to update</param>
        /// <param name="orderQtyChange">qty changing (+/-)</param>
        protected virtual void UpdateParentBlanketOrderLine(SOLine childOrderLine, decimal orderQtyChange)
        {
            if (childOrderLine == null || orderQtyChange == 0m)
            {
                return;
            }

            var rowExt            = childOrderLine.GetExtension <SOLineDAExtension>();
            var parentBlanketLine = (BlanketSOLine)PXSelect <BlanketSOLine,
                                                             Where <BlanketSOLine.orderType, Equal <Required <BlanketSOLine.orderType> >,
                                                                    And <BlanketSOLine.orderNbr, Equal <Required <BlanketSOLine.orderNbr> >,
                                                                         And <BlanketSOLine.lineNbr, Equal <Required <BlanketSOLine.lineNbr> > > > > > .Select(Base,
                                                                                                                                                               rowExt.DABlanketOrderType, rowExt.DABlanketOrderNbr, rowExt.DABlanketLineNbr);

            if (parentBlanketLine == null)
            {
                return;
            }

            parentBlanketLine.DABlanketOrderQty += orderQtyChange;
            if (parentBlanketLine.DABlanketOrderQty.GetValueOrDefault() < 0m)
            {
                parentBlanketLine.DABlanketOrderQty = 0m;
            }
            parentBlanketLine.OpenQty = Math.Max(parentBlanketLine.OrderQty.GetValueOrDefault() - parentBlanketLine.DABlanketOrderQty.GetValueOrDefault(), 0m);
            blanketLinesSelected.Update(parentBlanketLine);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 反写销售订单行上的项目字段
        /// 入口参数:销售订单行ID集合,项目档案KEY
        /// </summary>
        /// <param name="bpObj"></param>
        public void ModitySoLineProject(ModitySoLineProjectCode bpObj)
        {
            List <long> l = bpObj.SoLineListID;
            Project     p = Project.Finder.Find("ID=@ID", new OqlParam(bpObj.ProjectID));

            if (l != null && l.Count > 0)
            {
                using (ISession session = Session.Open())
                {
                    if (p != null)
                    {
                        for (int i = 0; i < l.Count; i++)
                        {
                            SOLine s = SOLine.Finder.FindByID(l[i]);
                            if (s != null)
                            {
                                s.ProjectKey   = p.Key;
                                s.Project.Code = p.Code;
                                s.Project.Name = p.Name;
                            }
                        }
                    }
                    session.Commit();
                }
            }
        }
Ejemplo n.º 6
0
        public ODataShipment GetAPIShipment(SOShipment shipment, SOPackageDetail package, PXResultset <SOLine> lines)
        {
            var wrapper     = new ODataShipment();
            var apiShipment = new KCAPIShipment()
            {
                ShippedDateUtc  = shipment.ShipDate,
                TrackingNumber  = package?.TrackNumber,
                ShippingCarrier = shipment.ShipVia,
                ShippingClass   = shipment.ShipVia,
                DeliveryStatus  = "Complete"
            };
            var apiItems = new List <KCAPIShipmentItem>();

            foreach (PXResult <SOLine> line in lines)
            {
                SOLine     soLine   = line.GetItem <SOLine>();
                SOShipLine shipLine = line.GetItem <SOShipLine>();
                DAC.KNSIKCInventoryItem kcInventoryItem    = line.GetItem <DAC.KNSIKCInventoryItem>();
                InventoryItem           inventoryItem      = line.GetItem <InventoryItem>();
                InventoryItemPCExt      inventoryItemPcExt = inventoryItem.GetExtension <InventoryItemPCExt>();
                SOLinePCExt             soLinePcExt        = soLine.GetExtension <SOLinePCExt>();

                int quantity = Convert.ToInt32(shipLine.ShippedQty.GetValueOrDefault());

                if ((soLine.LineNbr != soLinePcExt?.UsrKNMasterLineNbr && ParentIsGrouped(lines, soLinePcExt)) ||
                    (inventoryItemPcExt?.UsrKNCompositeType == KCConstants.ConfigurableProduct && soLine.LineNbr == soLinePcExt?.UsrKNMasterLineNbr))
                {
                    continue;
                }

                if (inventoryItemPcExt?.UsrKNCompositeType == KCConstants.GroupedProduct && quantity == 0)
                {
                    SOShipLine childItem = lines.Where(x => x.GetItem <SOLine>().GetExtension <SOLinePCExt>().UsrKNMasterLineNbr == soLine.LineNbr &&
                                                       x.GetItem <SOLine>().LineNbr != soLine.LineNbr).RowCast <SOShipLine>().FirstOrDefault();

                    if (childItem != null)
                    {
                        KCDataExchangeMaint     graph          = PXGraph.CreateInstance <KCDataExchangeMaint>();
                        List <KNSIGroupedItems> origChildItems = graph.GroupedChildItems.Select(inventoryItem.InventoryID).RowCast <KNSIGroupedItems>().ToList();
                        quantity = Convert.ToInt32(childItem.ShippedQty / origChildItems.Where(x => x.MappedInventoryID == childItem.InventoryID).FirstOrDefault().Quantity);
                    }
                    else
                    {
                        throw new KCCorruptedShipmentException();
                    }
                }

                apiItems.Add(new KCAPIShipmentItem
                {
                    ProductID   = kcInventoryItem?.UsrKCCAID.ToString(),
                    OrderItemID = soLine?.GetExtension <KCSOLineExt>()?.UsrKCOrderItemID.ToString(),
                    Quantity    = shipLine == null ? 0 : Convert.ToInt32(quantity)
                });
            }

            apiShipment.Items = apiItems;
            wrapper.Value     = apiShipment;

            return(wrapper);
        }
Ejemplo n.º 7
0
        public static void GetSOLine(KCAPIOrderItem orderItem, InventoryItem item, SOLine soLine, int?branchID, int?defaultWarehouse)
        {
            soLine.BranchID      = branchID;
            soLine.Qty           = orderItem.Quantity;
            soLine.OpenQty       = orderItem.Quantity;
            soLine.CuryUnitPrice = orderItem.UnitPrice;
            soLine.UOM           = item.SalesUnit;
            soLine.SalesAcctID   = item.SalesAcctID;
            soLine.SalesSubID    = item.SalesSubID ?? KCGeneralDataHelper.GetDefaultSalesSubID();
            soLine.InventoryID   = item.InventoryID;
            soLine.SiteID        = defaultWarehouse;
            soLine.TaxCategoryID = "TAXABLE";
            soLine.CuryLineAmt   = soLine.CuryUnitPrice * soLine.Qty;
            soLine.ShipComplete  = "B";
            KCSOLineExt soLineExt = soLine.GetExtension <KCSOLineExt>();

            soLineExt.UsrKCOrderItemID = orderItem.ID;
            soLineExt.UsrKCCAOrderID   = orderItem.OrderID;

            SOLinePCExt        soLinePCExt = soLine.GetExtension <SOLinePCExt>();
            InventoryItemPCExt itemPCExt   = item.GetExtension <InventoryItemPCExt>();

            if (itemPCExt.UsrKNCompositeType != null)
            {
                soLinePCExt.UsrKNIsMasterLine = true;
            }
        }
Ejemplo n.º 8
0
        protected virtual void SOLine_InventoryID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            if (!e.ExternalCall)
            {
                e.Cancel = true;
            }
            SOLine tran = (SOLine)e.Row;

            if (tran == null)
            {
                return;
            }
            if (Base.Document.Current == null)
            {
                return;
            }
            if (e.NewValue == null)
            {
                return;
            }

            string              value  = Rutrots.Current?.RUTROTType;
            InventoryItem       item   = (InventoryItem)InventoryItem.Select((int)e.NewValue);
            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(item);

            if (!RUTROTHelper.IsItemMatchRUTROTType(value, item, itemRR, itemRR?.IsRUTROTDeductible == true))
            {
                sender.RaiseExceptionHandling <SOLine.inventoryID>(tran, item.InventoryCD, new PXSetPropertyException <SOLine.inventoryID>(RUTROTMessages.LineDoesNotMatchDoc));
                e.NewValue = item.InventoryCD;
                throw new PXSetPropertyException <SOLine.inventoryID>(RUTROTMessages.LineDoesNotMatchDoc);
            }
        }
Ejemplo n.º 9
0
        public virtual void SOLine_IsRUTROTDeductible_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            SOLine tran = (SOLine)e.Row;

            if (tran == null)
            {
                return;
            }
            if (Base.Document.Current == null)
            {
                return;
            }
            if (e.NewValue == null || (bool)e.NewValue == false)
            {
                return;
            }

            string              value  = Rutrots.Current?.RUTROTType;
            InventoryItem       item   = (InventoryItem)InventoryItem.Select(tran.InventoryID);
            InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(item);

            if (!RUTROTHelper.IsItemMatchRUTROTType(value, item, itemRR, (bool)e.NewValue))
            {
                sender.RaiseExceptionHandling <SOLineRUTROT.isRUTROTDeductible>(tran, false, new PXSetPropertyException <SOLineRUTROT.isRUTROTDeductible>(RUTROTMessages.LineDoesNotMatchDoc));
                e.NewValue = false;
                throw new PXSetPropertyException <SOLineRUTROT.isRUTROTDeductible>(RUTROTMessages.LineDoesNotMatchDoc);
            }
        }
Ejemplo n.º 10
0
        public virtual void FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            if (e.Cancel || e.Row == null || this._inventoryType == (Type)null)
            {
                return;
            }

            object obj = sender.GetValue(e.Row, this._inventoryType.Name);

            if (obj == null)
            {
                return;
            }

            string attributeID = "BUSINESSUN";
            string attrValue   = "Distribution";

            InventoryItem inventoryItem = InventoryItem.PK.Find(sender.Graph, new int?((int)obj));
            CSAnswers     csAnswers     = CSAnswers.PK.Find(sender.Graph, inventoryItem.NoteID, attributeID);

            if (csAnswers != null)
            {
                SOLine row = e.Row as SOLine;

                if (SelectFrom <CSAttributeDetail> .Where <CSAttributeDetail.attributeID.IsEqual <P.AsString>
                                                           .And <CSAttributeDetail.valueID.IsEqual <P.AsString> > > .View.SelectSingleBound(sender.Graph, null, csAnswers.AttributeID, csAnswers.Value).TopFirst.Description == attrValue &&
                    row != null)
                {
                    e.NewValue = row.CustomerID;
                }
            }
        }
Ejemplo n.º 11
0
        public override object Do(object obj)
        {
            ModifySoLinePrice bpObj = (ModifySoLinePrice)obj;
            if (bpObj == null) throw new Exception("修改销售订单行销售价格和最终价失败!");
             //审核: 销售订单行.外销价(弹性域字段)=申请价格、最终价=外销价*折扣
             //弃审:销售订单行.外销价=销售订单特价申请单行.定价、最终价=外销价*折扣
            List<SOLine.EntityKey> SoLineListKey = bpObj.SoLineKey;//销售订单行 key集合
            using (ISession session = Session.Open())
            {
                foreach (SOLine.EntityKey item in SoLineListKey)
                {
                    SOLine SolineEntity = item.GetEntity();//获取销售订单行实体
                    SoOrderSaleLine SoOrderSaleLineEntity=SoOrderSaleLine.Finder.Find(string.Format("SourceLineID",item));//获取特价申请单行实体
                    if (SolineEntity != null)
                    {

                        SolineEntity.DescFlexField.PrivateDescSeg10 = SoOrderSaleLineEntity.AfterPrices+"";
                        if(string.IsNullOrEmpty(SolineEntity.DescFlexField.PrivateDescSeg10))
                      //  SolineEntity.FinallyPriceTC =SoOrderSaleLineEntity

                    }

                }

                session.Commit();
            }

            return true;
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> PutSOLine([FromRoute] int id, [FromBody] SOLine sOLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sOLine.SOLineID)
            {
                return(BadRequest());
            }

            _context.Entry(sOLine).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SOLineExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 13
0
        protected virtual void ARTaxTran_RowInserting(PXCache sender, PXRowInsertingEventArgs e, PXRowInserting baseHandler)
        {
            if (!(e.Row is ARTaxTran row))
            {
                return;
            }
            baseHandler?.Invoke(sender, e);

            row.CuryTaxableAmt = 0;

            foreach (ARTran tran in Base.Transactions.Select())
            {
                SOLine line = PXSelect <
                    SOLine,
                    Where <SOLine.orderNbr, Equal <Required <SOLine.orderNbr> > > >
                              .Select(Base, tran.SOOrderNbr);

                SOLinePCExt   linePCExt = line.GetExtension <SOLinePCExt>();
                InventoryItem product   = KCInventoryItem.SelectSingle(tran.InventoryID);
                if (product != null)
                {
                    InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>();
                    if (productPCExt != null)
                    {
                        if (productPCExt.UsrKNCompositeType == null)
                        {
                            row.CuryTaxableAmt += tran.CuryTranAmt;
                        }
                    }
                }
            }
            baseHandler.Invoke(sender, e);
        }
    protected virtual IEnumerable transactions()
    {
        PXSelectBase <SOLine> query =
            new PXSelectJoin <SOLine,
                              LeftJoin <INItemCost, On <INItemCost.inventoryID, Equal <SOLine.inventoryID> >,
                                        InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <SOLine.inventoryID> > > >,
                              Where <SOLine.orderType, Equal <Current <SOOrder.orderType> >,
                                     And <SOLine.orderNbr, Equal <Current <SOOrder.orderNbr> > > >,
                              OrderBy <Asc <SOLine.orderType, Asc <SOLine.orderNbr, Asc <SOLine.lineNbr> > > > >(Base);
        var ret       = new List <PXResult <SOLine, INItemCost, InventoryItem> >();
        int startRow  = PXView.StartRow;
        int totalRows = 0;

        foreach (PXResult <SOLine, INItemCost, InventoryItem> record in query.View.Select(
                     PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns,
                     PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows))
        {
            SOLine     line     = (SOLine)record;
            INItemCost itemCost = (INItemCost)record;
            Base.initemcost.StoreCached(new PXCommandKey(new object[] { line.InventoryID }), new List <object> {
                itemCost
            });
            ret.Add(record);
        }
        PXView.StartRow = 0;
        return(ret);
    }
        protected virtual void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseHandler)
        {
            baseHandler?.Invoke(sender, e);
            if (!(e.Row is SOLine row))
            {
                return;
            }
            SOOrderEntryPCExt graphExt = Base.GetExtension <SOOrderEntryPCExt>();
            var extrows = Base.Transactions.Cache.GetExtension <SOLinePCExt>(row);

            if (extrows.UsrKNMasterLineNbr != null && string.IsNullOrEmpty(extrows.UsrKNCompositeInventory))
            {
                using (new PXConnectionScope())
                {
                    if (extrows.UsrKNMasterLineNbr != row.LineNbr)
                    {
                        SOLine parentRow = PXSelect <SOLine, Where <SOLine.orderNbr, Equal <Required <SOLine.orderNbr> >, And <SOLine.lineNbr, Equal <Required <SOLine.lineNbr> > > > > .Select(Base, row.OrderNbr, extrows.UsrKNMasterLineNbr).RowCast <SOLine>().First();

                        extrows.UsrKNCompositeInventory = graphExt.InventoryItems.SelectSingle(parentRow.InventoryID)?.InventoryCD;
                    }
                    if (extrows.UsrKNMasterLineNbr == row.LineNbr)
                    {
                        extrows.UsrKNCompositeInventory = KCMessages.CompositeItemLinePlaceholder;
                        extrows.UsrKNInventoryCD        = graphExt.InventoryItems.SelectSingle(row.InventoryID)?.InventoryCD;
                    }
                }
            }
        }
Ejemplo n.º 16
0
        //public PXAction<SalesFcstInquiry> generateRecords;
        //[PXUIField(DisplayName = "Generate Records")]
        //[PXButton(CommitChanges = true)]
        //public virtual IEnumerable GenerateRecords(PXAdapter adapter)
        //{
        //    PXLongOperation.StartOperation(this, delegate
        //    {
        //        InsertRecords();
        //    });

        //    return adapter.Get();
        //}
        #endregion

        #region Function
        private void InsertRecords()
        {
            int count = 1;

            SalesFcstInquiry fcstInquiry = SOFcstInq.Cache.CreateInstance() as SalesFcstInquiry;

            foreach (PXResult <SalesForecast> result in SOForecast.Select())
            {
                SalesForecast salesForecast = result.GetItem <SalesForecast>();

                fcstInquiry.Numbering     = count;
                fcstInquiry.SalesPersonID = salesForecast.SalesPersonID;
                fcstInquiry.CustomerID    = salesForecast.CustomerID;
                fcstInquiry.EndCustomer   = salesForecast.EndCustomer;
                fcstInquiry.InventoryID   = salesForecast.InventoryID;
                fcstInquiry.FinPeriodID   = salesForecast.FinPeriodID;
                fcstInquiry.CountryID     = salesForecast.CountryID;
                fcstInquiry.IsTotal       = salesForecast.IsTotal;
                fcstInquiry.IsSplit       = salesForecast.IsSplit;
                fcstInquiry.PercentSplit  = salesForecast.PercentSplit;
                fcstInquiry.Date          = salesForecast.Date;
                fcstInquiry.Qty           = salesForecast.Qty;
                fcstInquiry.UnitPrice     = salesForecast.UnitPrice;
                fcstInquiry.ItemClassID   = salesForecast.ItemClassID;

                count++;
                SOFcstInq.Cache.Insert(fcstInquiry);
            }

            foreach (PXResult <SOLine, SOOrder, Customer, InventoryItem> result2 in Backlog.Select())
            {
                SOOrder order = result2.GetItem <SOOrder>();
                SOLine  line  = result2.GetItem <SOLine>();

                fcstInquiry.Numbering     = count;
                fcstInquiry.OrderNbr      = order.OrderNbr;
                fcstInquiry.OrderDate     = line.OrderDate;
                fcstInquiry.RequestDate   = line.RequestDate;
                fcstInquiry.ShipDate      = line.ShipDate;
                fcstInquiry.InventoryID   = line.InventoryID;
                fcstInquiry.SiteID        = line.SiteID;
                fcstInquiry.OrderQty      = line.OrderQty;
                fcstInquiry.OpenQty       = line.OpenQty;
                fcstInquiry.CustomerID    = line.CustomerID;
                fcstInquiry.LineNbr       = line.LineNbr;
                fcstInquiry.UnitPrice     = line.UnitPrice;
                fcstInquiry.Amount        = line.OpenAmt;
                fcstInquiry.SalesPersonID = line.SalesPersonID;
                fcstInquiry.FinPeriodID   = String.Format("{0}{1}", line.ShipDate.Value.Year, line.ShipDate.Value.Month.ToString("00"));
                fcstInquiry.EndCustomer   = PXCache <SOLine> .GetExtension <SOLineExt>(line).UsrEndCustomer;

                fcstInquiry.ItemClassID      = result2.GetItem <InventoryItem>().ItemClassID;
                fcstInquiry.CustomerOrderNbr = order.CustomerOrderNbr;
                fcstInquiry.Status           = order.Status;
                fcstInquiry.TermsID          = result2.GetItem <Customer>().TermsID;

                count++;
                SOFcstInq.Cache.Insert(fcstInquiry);
            }
        }
Ejemplo n.º 17
0
        protected override void DeductAllocated(SiteStatus allocated, IMatrixItemLine line)
        {
            SOLine soLine = (SOLine)line;

            allocated.QtyAvail     += soLine.LineQtyAvail;
            allocated.QtyHardAvail += soLine.LineQtyHardAvail;
        }
Ejemplo n.º 18
0
        public virtual IEnumerable AddInvSelBySiteItemPicker(PXAdapter adapter)
        {
            foreach (ItemPickerSelected line in itempickerstatus.Cache.Cached)
            {
                if (line.Selected == true && line.QtySelected > 0)
                {
                    SOLine newline = PXCache <SOLine> .CreateCopy(Base.Transactions.Insert(new SOLine()));

                    newline.SiteID      = line.SiteID;
                    newline.InventoryID = line.InventoryID;
                    newline.SubItemID   = line.SubItemID;
                    newline.UOM         = line.SalesUnit;
                    newline.AlternateID = line.AlternateID;
                    newline             = PXCache <SOLine> .CreateCopy(Base.Transactions.Update(newline));

                    if (newline.RequireLocation != true)
                    {
                        newline.LocationID = null;
                    }
                    newline = PXCache <SOLine> .CreateCopy(Base.Transactions.Update(newline));

                    newline.Qty = line.QtySelected;
                    // cnt = 0;
                    Base.Transactions.Update(newline);
                }
            }
            itempickerstatus.Cache.Clear();
            return(adapter.Get());
        }
Ejemplo n.º 19
0
        private void UpdateOrderBalances(SOOrder order)
        {
            if (order == null)
            {
                return;
            }
            bool?     isFromCA = order.GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("FBA");
            ARPayment payment  = KCOrderPayment.Select(order.CustomerOrderNbr);

            if (isFromCA == true && payment != null)
            {
                order.PaymentTotal = order.CuryPaymentTotal = payment.CuryOrigDocAmt;
            }

            order.DocBal        = order.CuryDocBal = order.CuryOrderTotal;
            order.UnpaidBalance = order.CuryUnpaidBalance = 0;

            foreach (ARTran line in Base.Transactions.Select())
            {
                SOLine      sOLine      = KCSOLineByOrderNbrAndLineNbr.SelectSingle(line.SOOrderNbr, line.SOOrderLineNbr);
                SOLinePCExt SOLinePCExt = sOLine.GetExtension <SOLinePCExt>();
                if (SOLinePCExt.UsrKNMasterLineNbr == sOLine.LineNbr)
                {
                    line.CuryExtPrice = sOLine.CuryExtPrice;
                    line.CuryTranAmt  = sOLine.CuryLineAmt;
                }
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// 删除订单折扣
 /// </summary>
 /// <param name="soLine"></param>
 public static void DeleteSODiscount(SOLine soLine)
 {
     UFIDA.U9.Cust.GS.FT.SODiscountBE.SODiscount entity = UFIDA.U9.Cust.GS.FT.SODiscountBE.SODiscount.Finder.Find("SOLine=@SOLine", new OqlParam("SOLine", soLine.ID));
     if (entity != null)
     {
         entity.Remove();
     }
 }
Ejemplo n.º 21
0
 public Record(ARTran artran, SOLine soline, InventoryItem item, SOSalesPerTran salesPerTran)
 {
     this.ARTran       = artran;
     this.SOLine       = soline;
     this.Item         = item;
     this.SalesPerTran = salesPerTran;
     this.Transactions = new Dictionary <int, INTransaction>();
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 创建出运明细行佣金
 /// </summary>
 /// <param name="DtoList"></param>
 public void CreateShipBrokerage(List <ReturnBrokerageDto> DtoList)
 {
     //删除出运明细行对应的佣金
     using (ISession removeSession = Session.Open())
     {
         for (int i = 0; i < DtoList.Count; i++)
         {
             OrderLineBrokerage.EntityList BrokerageList = OrderLineBrokerage.Finder.FindAll("ShipPlanLine=@OrderLineID", new OqlParam(DtoList[i].ShipPlanLineID));
             if (BrokerageList != null && BrokerageList.Count > 0)
             {
                 //删除出运明细行佣金
                 for (int j = 0; j < BrokerageList.Count; j++)
                 {
                     BrokerageList[j].Remove();
                 }
             }
         }
         removeSession.Commit();
     }
     using (ISession session = Session.Open())
     {
         for (int i = 0; i < DtoList.Count; i++)
         {
             ShipPlanDetailLine shipLine = ShipPlanDetailLine.Finder.FindByID(DtoList[i].ShipPlanLineID.ID);
             if (shipLine == null)
             {
                 continue;
             }
             SOLine soLine = SOLine.Finder.FindByID(shipLine.SrcLineID);
             OrderLineBrokerage.EntityList brokerage = OrderLineBrokerage.Finder.FindAll("OrderLineID='" + shipLine.SrcLineID + "'");
             if (brokerage != null && brokerage.Count > 0)
             {
                 OrderLineBrokerage shipLineBroke = null;
                 foreach (OrderLineBrokerage orderBrokerage in brokerage)
                 {
                     shipLineBroke                = OrderLineBrokerage.Create();
                     shipLineBroke.SourceType     = AllEnumBE.SourceTypeEnum.ShipPlanDoc;
                     shipLineBroke.ShipPlanLine   = shipLine;
                     shipLineBroke.ShipPlanRowNo  = shipLine.RowNo;
                     shipLineBroke.Client         = orderBrokerage.Client;
                     shipLineBroke.Product        = orderBrokerage.Product;
                     shipLineBroke.BrokerageRatio = orderBrokerage.BrokerageRatio;
                     shipLineBroke.Payee          = orderBrokerage.Payee;
                     //shipLineBroke.PayAmount = orderBrokerage.PayAmount;
                     shipLineBroke.BrokerageType = orderBrokerage.BrokerageType;
                     shipLineBroke.Prices        = orderBrokerage.Prices;
                     shipLineBroke.PayAmount     = orderBrokerage.PayAmount / soLine.OrderByQtyTU * shipLine.Qty;
                     shipLineBroke.PayCurrency   = orderBrokerage.PayCurrency;
                     //shipLineBroke.OutPayment = orderBrokerage.OutPayment;
                     shipLineBroke.OrderCurrency    = orderBrokerage.OrderCurrency;
                     shipLineBroke.Rate             = orderBrokerage.Rate;
                     shipLineBroke.SrcBrokerageLine = orderBrokerage.SrcBrokerageLine;
                 }
             }
         }
         session.Commit();
     }
 }
 public SOLineEquipmentComponent(ContractInvoiceLine docLine, SOLine sOLineRow, FSxSOLine fSxSOLineRow)
 {
     this.componentID     = docLine.ComponentID;
     this.currentLineRef  = sOLineRow.LineNbr;
     this.equipmentAction = docLine.EquipmentAction;
     this.sourceLineRef   = docLine.LineRef;
     this.sourceNewTargetEquipmentLineNbr = docLine.NewTargetEquipmentLineNbr;
     this.fsxSOLineRow = fSxSOLineRow;
 }
Ejemplo n.º 24
0
        /*
         * 该类用于对销售订单进行删除操作的逻辑校验
         */
        /// <summary>
        /// 判断有没产生销售订单特价申请单
        /// </summary>
        /// <param name="bpObj"></param>
        /// <returns></returns>
        public static void IsSoOrderSale(SOLine soLine)
        {
            bool isExists = SoOrderSaleLine.Finder.IsExists("SourceLineID=@SourceLineID", new OqlParam("SourceLineID", soLine.ID));

            if (isExists)
            {
                throw new Exception("第" + soLine.DocLineNo.ToString() + "行:已经存在销售订单特价申请单,不允许删除!");
            }
        }
Ejemplo n.º 25
0
        public virtual void FillAppointmentSOFields(PXCache cache, ARTran arTranRow)
        {
            if (arTranRow.SOOrderType != null &&
                arTranRow.SOOrderNbr != null &&
                arTranRow.SOOrderLineNbr != null)
            {
                PXResult <SOLine, SOOrder, FSServiceOrder, FSAppointment> bqlResult =
                    (PXResult <SOLine, SOOrder, FSServiceOrder, FSAppointment>)
                    PXSelectJoin <SOLine,
                                  InnerJoin <SOOrder,
                                             On <
                                                 SOOrder.orderNbr, Equal <SOLine.orderNbr>,
                                                 And <SOOrder.orderType, Equal <SOLine.orderType> > >,
                                             LeftJoin <FSServiceOrder,
                                                       On <
                                                           Where2 <
                                                               Where <
                                                                   FSServiceOrder.refNbr, Equal <FSxSOOrder.soRefNbr>,
                                                                   And <FSServiceOrder.srvOrdType, Equal <FSxSOOrder.srvOrdType> > >,
                                                               Or <FSServiceOrder.sOID, Equal <FSxSOLine.sOID> > > >,
                                                       LeftJoin <FSAppointment,
                                                                 On <
                                                                     FSAppointment.appointmentID, Equal <FSxSOLine.appointmentID> > > > >,
                                  Where <
                                      SOLine.orderType, Equal <Required <SOLine.orderType> >,
                                      And <SOLine.orderNbr, Equal <Required <SOLine.orderNbr> >,
                                           And <SOLine.lineNbr, Equal <Required <SOLine.lineNbr> > > > > >
                    .Select(cache.Graph, arTranRow.SOOrderType, arTranRow.SOOrderNbr, arTranRow.SOOrderLineNbr);

                SOLine         soLineRow         = (SOLine)bqlResult;
                FSServiceOrder fsServiceOrderRow = (FSServiceOrder)bqlResult;
                FSAppointment  fsAppointmentRow  = (FSAppointment)bqlResult;

                if (soLineRow != null)
                {
                    FSxARTran fsxARTranRow = cache.GetExtension <FSxARTran>(arTranRow);

                    if (fsServiceOrderRow != null &&
                        fsServiceOrderRow.SOID != null)
                    {
                        fsxARTranRow.SOID = fsServiceOrderRow.SOID;

                        fsxARTranRow.BillCustomerID     = fsServiceOrderRow.CustomerID;
                        fsxARTranRow.CustomerLocationID = fsServiceOrderRow.LocationID;

                        fsxARTranRow.ServiceOrderDate = fsServiceOrderRow.OrderDate;
                    }

                    if (fsAppointmentRow != null &&
                        fsAppointmentRow.AppointmentID != null)
                    {
                        fsxARTranRow.AppointmentID   = fsAppointmentRow.AppointmentID;
                        fsxARTranRow.AppointmentDate = fsAppointmentRow.ScheduledDateTimeBegin;
                    }
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 订单佣金 上一行/下一行
        /// </summary>
        /// <param name="bpObj"></param>
        /// <returns></returns>
        public ReturnUpDownBrokerageDTO GetBrokerageInfo(UpDownLineBrokerage bpObj)
        {
            ReturnUpDownBrokerageDTO dto = new ReturnUpDownBrokerageDTO();

            if (bpObj.SoID != null)//销售订单ID不为空
            {
                if (bpObj.SoLineRow != 0)
                {
                    int    Row = bpObj.SoLineRow;//当前行号
                    string sql = string.Empty;
                    if (bpObj.Type == 1)
                    {
                        sql = "select MAX( DocLineNo) as DocLineNo ,SO from SM_SOLine where DocLineNo<" + bpObj.SoLineRow + " and SO='" + bpObj.SoID.ID + "' group by so";
                    }
                    else
                    {
                        sql = "select Min( DocLineNo) as DocLineNo ,SO from SM_SOLine where DocLineNo>" + bpObj.SoLineRow + " and SO='" + bpObj.SoID.ID + "' group by so";
                    }
                    DataSet ds = null;
                    UFSoft.UBF.Util.DataAccess.DataAccessor.RunSQL(UFSoft.UBF.Util.DataAccess.DataAccessor.GetConn(), sql.ToString(), null, out ds);
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            if (!string.IsNullOrEmpty(ds.Tables[0].Rows[i]["DocLineNo"] + ""))
                            {
                                Row = Convert.ToInt32(ds.Tables[0].Rows[i]["DocLineNo"]);
                            }
                        }
                    }
                    SOLine line = SOLine.Finder.Find(string.Format("SO.ID={0} and DocLineNo={1}", bpObj.SoID.ID, Row));
                    if (line != null)
                    {
                        dto.SoID              = line.SO.Key;                                           //销售单ID
                        dto.RowNo             = line.DocLineNo;                                        //行号
                        dto.SoLineID          = line.Key;                                              //销售单行ID
                        dto.ItemInfo_Item     = line.ItemInfo.ItemIDKey;                               //料号
                        dto.ItemInfo_ItemName = line.ItemInfo.ItemID.Name;                             //品名
                        dto.Qty           = decimal.Round(line.OrderByQtyTU, line.TU.Round.Precision); //数量
                        dto.ItemInfo_Code = line.ItemInfo.ItemCode;                                    //料品code
                        if (!string.IsNullOrEmpty(line.DescFlexField.PrivateDescSeg5))
                        {
                            dto.FinallyPriceTC = decimal.Parse(decimal.Parse(line.DescFlexField.PrivateDescSeg5).ToString("F" + line.SO.TC.PriceRound.Precision.ToString()));
                        }
                        dto.TotalMoney = decimal.Round(line.TotalMoneyTC, line.SO.TC.MoneyRound.Precision);
                        dto.Currecy    = line.SO.TC.Name;
                        if (line.TU != null)
                        {
                            dto.Uom           = line.TU.Name;                                        //单位
                            dto.Precision_Qty = line.TU.Round == null ? 2 : line.TU.Round.Precision; //精度
                        }
                    }
                }
            }

            return(dto);
        }
Ejemplo n.º 27
0
 public SOPrepaymentBySO(SOLine soLineRow, FSxSOLine fsxSOLineRow, decimal soTaxLine)
 {
     SOID           = fsxSOLineRow.SOID;
     unpaidAmount   = 0;
     unpaidAmount  += (soLineRow.CuryLineAmt ?? 0m) + soTaxLine;
     originalAmount = unpaidAmount;
     fsxSOLineList  = new List <FSxSOLine>();
     fsxSOLineList.Add(fsxSOLineRow);
 }
Ejemplo n.º 28
0
 public SOARLineEquipmentComponent(IDocLine docLine, SOLine sOLineRow, FSxSOLine fSxSOLineRow)
 {
     this.componentID     = docLine.ComponentID;
     this.currentLineRef  = sOLineRow.LineNbr;
     this.equipmentAction = docLine.EquipmentAction;
     this.sourceLineRef   = docLine.LineRef;
     this.sourceNewTargetEquipmentLineNbr = docLine.NewTargetEquipmentLineNbr;
     this.fsxSOLineRow = fSxSOLineRow;
     this.fsxARTranRow = null;
 }
Ejemplo n.º 29
0
        /// <summary>
        /// 创建评估类型单
        /// </summary>
        /// <param name="ListKey"></param>
        public string CreateAeesess(CreateAssessType bpObj)
        {
            string StrMeg = string.Empty;
            List <SOLine.EntityKey> ListKey = bpObj.SoLineID;

            using (ISession session = Session.Open())
            {
                for (int i = 0; i < ListKey.Count; i++)
                {
                    SOLine line = ListKey[i].GetEntity();//获取销售订单行信息

                    if (line != null)
                    {
                        ItemMaster item = ItemMaster.Finder.Find("code=@code", new OqlParam(line.ItemInfo.ItemCode));//通过当前料品code查询=》金额(美元),扩展字段
                        //将“价税合计”转换成 美元 ,和料品档案上的扩展字段进行比较
                        //调用原币种转会为目标币的汇率的BP
                        if (item != null)
                        {
                            if (!string.IsNullOrEmpty(item.DescFlexField.PrivateDescSeg29))
                            {
                                decimal TotalMoney = 0;
                                if (bpObj.Rate != 0)
                                {
                                    TotalMoney = line.TotalMoneyTC * bpObj.Rate;
                                }
                                else
                                {
                                    TotalMoney = line.TotalMoneyTC;
                                }
                                if (TotalMoney > Convert.ToDecimal(item.DescFlexField.PrivateDescSeg29))
                                {
                                    //自动创建一行评估类型为大货评估的质检评估子表,并且不允许删除
                                    AssessType assess = AssessType.Create();
                                    assess.AssessTypes = AllEnumBE.AssessTypeEnum.LargeCargo; //大货评估
                                    assess.SoIDKey     = line.SO.Key;                         //销售订单ID
                                    assess.SoLineIDKey = line.Key;                            //销售订单行ID
                                    //  TestDate检验日期
                                    //TestResult检验结果
                                }
                            }
                            else
                            {
                                StrMeg += line.ItemInfo.ItemName + "在料品档案中的金额值为空,生成评估类型单失败!";
                            }
                        }
                        else
                        {
                            StrMeg += "料品档案中不存在" + line.ItemInfo.ItemCode + "该编码的料品,生成评估类型单失败!";
                        }
                    }
                }
                session.Commit();
            }
            return(StrMeg);
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> PostSOLine([FromBody] SOLine sOLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SOLine.Add(sOLine);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSOLine", new { id = sOLine.SOLineID }, sOLine));
        }
        private void SetSOLine_IsPriceCalDoingForPO(SOLine line, bool value)
        {
            //line.IsPriceCalDoingForPO = true;

            Type tp = typeof(SOLine);


            foreach (PropertyInfo rInfo in tp.GetProperties())
            {
                if (rInfo.Name == "IsPriceCalDoingForPO")
                {
                    if (rInfo.CanWrite)
                    {
                        rInfo.SetValue(line, value, null);
                    }
                }
            }

        }
Ejemplo n.º 32
0
        // 是否爆款
        /// <summary>
        /// 是否爆款
        /// </summary>
        /// <param name="soline"></param>
        /// <returns></returns>
        private bool IsVogue(SOLine soline)
        {
            long itemID = soline.ItemInfo.ItemIDKey.ID;

            if (VogueAndParts.ContainsKey(itemID)
                )
            {
                ItemTypeWithVouchers itemType = VogueAndParts[itemID];

                if (itemType == ItemTypeWithVouchers.Vogue
                    || itemType == ItemTypeWithVouchers.VogueAndPart
                    )
                {
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 33
0
        private bool IsInVoucherCalc(SOLine soline)
        {
            long itemID = soline.ItemInfo.ItemIDKey.ID;

            if (VogueAndParts.ContainsKey(itemID)
                && VogueAndParts[itemID] != ItemTypeWithVouchers.Empty
                )
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 34
0
        private static void SetSOLineMoney(SOLine soline, decimal lineTotalMoney, decimal vouchersMoney, ref decimal remainMoney)
        {
            decimal finallyMoney = lineTotalMoney - vouchersMoney;
            decimal curLineVouMoney = vouchersMoney;

            if (finallyMoney > 0)
            {
                //if (soline.TotalMoneyTC != finallyMoney)
                {
                    SetLineFinallyMoney(soline, finallyMoney);
                }
            }
            else
            {
                remainMoney += finallyMoney * -1;

                soline.FreeType = UFIDA.U9.CBO.SCM.Enums.FreeTypeEnum.Present;

                // OBA,修改金额  =0,这时候价格计算可能有问题,会报错;
                // OBA, 修改最终价=0,这时候价格计算可能有问题,税额不对,税子表没有重算;
                // 金额改为0,好合算是否分摊正确
                SetLineFinallyMoney(soline, lineTotalMoney);
                //SetLineFinallyMoney(soline, 0);

                curLineVouMoney = lineTotalMoney;
            }

            // 本行分摊金额
            string strVouMoney = curLineVouMoney.ToString("G0");
            if (soline.DescFlexField.PrivateDescSeg2 != strVouMoney)
            {
                soline.DescFlexField.PrivateDescSeg2 = strVouMoney;
            }
        }
Ejemplo n.º 35
0
        private static void SetLineFinallyMoney(SOLine soline, decimal finallyMoney)
        {
            if (soline.TotalMoneyTC != finallyMoney)
            {
                soline.TotalMoneyTC = finallyMoney;
                soline.TotalMoneyFC = soline.TotalMoneyTC;
                soline.TotalMoneyCC = soline.TotalMoneyTC;
                soline.TotalMoneyAC = soline.TotalMoneyTC;

                //soline.FinallyPriceTC = 0;
                //soline.PriceCalField = "TotalMoneyTC";

                // OBA,修改金额  =0,这时候价格计算可能有问题,会报错;
                // OBA, 修改最终价=0,这时候价格计算可能有问题,税额不对,税子表没有重算;
                //if (finallyMoney == 0)
                //{
                //    soline.FinallyPriceTC = 0;
                //}

                //soline.NetMoneyTC = 0;
                //soline.NetMoneyFC = 0;
                //soline.NetMontyAC = 0;
                //soline.TaxMoneyTC = 0;
                //soline.TaxMoneyFC = 0;
                //soline.TaxMoneyAC = 0;
            }
        }
Ejemplo n.º 36
0
        private decimal GetSOLineMoney(SOLine soline)
        {
            decimal money = 0;

            if (soline != null)
            { 
                // 券分摊金额 = 私有段2
                money = soline.TotalMoneyTC + soline.DescFlexField.PrivateDescSeg2.GetDecimal();
            }

            return money;
        }
Ejemplo n.º 37
0
        private static void CalcVouchersSOLine(decimal vouchersMoney, ref decimal remainMoney, ref SOLine maxMoneyLine, SOLine soline)
        {

            // 券分摊金额 Pri 2 
            // 原含税金额 Pri 3 

            decimal lineTotalMoney = 0;
            if (!soline.DescFlexField.PrivateDescSeg3.IsNull())
            {
                lineTotalMoney = PubClass.GetDecimal(soline.DescFlexField.PrivateDescSeg3);
            }
            else
            {
                lineTotalMoney = soline.TotalMoneyTC;
                soline.DescFlexField.PrivateDescSeg3 = lineTotalMoney.ToString("G0");
            }

            // 把赠品打开
            if (lineTotalMoney > 0)
            {
                if (soline.FreeType == UFIDA.U9.CBO.SCM.Enums.FreeTypeEnum.Present)
                {
                    soline.FreeType = UFIDA.U9.CBO.SCM.Enums.FreeTypeEnum.Empty;
                }
            }

            if (maxMoneyLine == null
                || soline.TotalMoneyTC > maxMoneyLine.TotalMoneyTC
                )
            {
                maxMoneyLine = soline;
            }

            //decimal line

            SetSOLineMoney(soline, lineTotalMoney, vouchersMoney, ref remainMoney);
        }