Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("AddressID,Address,City,PhoneNumber,Province,Receiver,UserID,ZipCode")] ShipAddress shipAddress)
        {
            if (id != shipAddress.AddressID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _addressRepository.UpdateAsync(shipAddress);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShipAddressExists(shipAddress.AddressID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(shipAddress));
        }
        public async Task <int> AddAsync(ShipAddress address)
        {
            _dbContext.ShipAddress.Add(address);
            await _dbContext.SaveChangesAsync();

            return(address.AddressID);
        }
Пример #3
0
        /*
         * 填充报表头
         *
         * Param pageIndex 页号
         * Param orderHead 订单头对象
         * Param orderDetails 订单明细对象
         */
        private void FillHead(InProcessLocation inProcessLocation)
        {
            //首部
            //No.
            string ipNo = inProcessLocation.IpNo;

            if (inProcessLocation.PrintCount > 0)
            {
                ipNo += "      (" + inProcessLocation.PrintCount.ToString() + ")";
            }
            this.SetRowCell(3, 14, ipNo);
            //收货单位
            this.SetRowCell(5, 2, inProcessLocation.PartyTo.Name);
            if (inProcessLocation.OrderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
            {
                //移库路线上没有shipto,暂时取默认的地址
                ShipAddress shipAddress = shipAddressMgr.GetDefaultShipAddress(inProcessLocation.PartyTo);
                this.SetRowCell(5, 9, shipAddress == null ? string.Empty : shipAddress.Address);
            }
            else
            {
                //地址
                this.SetRowCell(5, 9, inProcessLocation.ShipTo == null ? string.Empty : inProcessLocation.ShipTo.Address);
            }
            //卸货地点
            //运输方法
            //车号
            //介绍信编号
            //货物出门性质
            CodeMaster codeMaster = codeMasterMgr.LoadCodeMaster(BusinessConstants.CODE_MASTER_ORDER_TYPE, inProcessLocation.OrderType);

            this.SetRowCell(6, 16, codeMaster.Description);
        }
Пример #4
0
        protected override void CreateOrUpdateObject(object obj)
        {
            IList <object> list        = (IList <object>)obj;
            Customer       customer    = (Customer)list[0];
            ShipAddress    shipAddress = (ShipAddress)list[1];
            BillAddress    billAddress = (BillAddress)list[2];

            //Party newParty = this.partyMgr.LoadParty(customer.Code);
            Customer oldCustomer = this.customerMgr.LoadCustomer(customer.Code);

            if (oldCustomer == null)
            {
                customer.IsActive = true;
                //customer.LastModifyUser = this.userMgr.GetMonitorUser();
                //customer.LastModifyDate = DateTime.Now;
                this.customerMgr.CreateCustomer(customer);
            }
            else
            {
                CloneHelper.CopyProperty(customer, oldCustomer, this.Customer2CustomerFields);
                //newCustomer.LastModifyUser = this.userMgr.GetMonitorUser();
                //newCustomer.LastModifyDate = DateTime.Now;
                this.customerMgr.UpdateCustomer(oldCustomer);
            }


            BillAddress newBillAddress = this.billAddressMgr.LoadBillAddress(billAddress.Code);

            if (newBillAddress == null)
            {
                billAddress.IsActive = true;
                //billAddress.LastModifyUser = this.userMgr.GetMonitorUser();
                // billAddress.LastModifyDate = DateTime.Now;
                this.billAddressMgr.CreateBillAddress(billAddress);
            }
            else
            {
                CloneHelper.CopyProperty(billAddress, newBillAddress, this.BillAddress2BillAddressFields);
                //newBillAddress.LastModifyUser = this.userMgr.GetMonitorUser();
                //newBillAddress.LastModifyDate = DateTime.Now;
                this.billAddressMgr.UpdateBillAddress(newBillAddress);
            }

            ShipAddress newShipAddress = this.shipAddressMgr.LoadShipAddress(shipAddress.Code);

            if (newShipAddress == null)
            {
                shipAddress.IsActive = true;
                //shipAddress.LastModifyUser = this.userMgr.GetMonitorUser();
                //shipAddress.LastModifyDate = DateTime.Now;
                this.shipAddressMgr.CreateShipAddress(shipAddress);
            }
            else
            {
                CloneHelper.CopyProperty(shipAddress, newShipAddress, this.ShipAddress2ShipAddressFields);
                // newShipAddress.LastModifyUser = this.userMgr.GetMonitorUser();
                // newShipAddress.LastModifyDate = DateTime.Now;
                this.shipAddressMgr.UpdateShipAddress(newShipAddress);
            }
        }
        private object Deserialize(DssImportHistory dssImportHistory)
        {

            Supplier supplier = new Supplier();
            supplier.Code = dssImportHistory[1].ToUpper();
            supplier.Name = dssImportHistory[3];

            ShipAddress shipAddress = new ShipAddress();
            shipAddress.Code = supplier.Code.ToUpper() + "_S";
            shipAddress.Address = dssImportHistory[4];
            shipAddress.ContactPersonName = dssImportHistory[13];
            shipAddress.TelephoneNumber = dssImportHistory[14] + dssImportHistory[15];
            shipAddress.Fax = dssImportHistory[16];
            shipAddress.MobilePhone = dssImportHistory[18] + dssImportHistory[19];
            shipAddress.PostalCode = dssImportHistory[9];
            shipAddress.Party = supplier;

            BillAddress billAddress = new BillAddress();
            billAddress.Code = supplier.Code.ToUpper() + "_B";
            billAddress.Address = dssImportHistory[4];
            billAddress.ContactPersonName = dssImportHistory[13];
            billAddress.TelephoneNumber = dssImportHistory[14] + dssImportHistory[15];
            billAddress.Fax = dssImportHistory[16];
            billAddress.MobilePhone = dssImportHistory[18] + dssImportHistory[19];
            billAddress.PostalCode = dssImportHistory[9];
            billAddress.Party = supplier;

            IList<object> list = new List<object>();
            list.Add(supplier);
            list.Add(shipAddress);
            list.Add(billAddress);
            return list;
        }
Пример #6
0
        public async Task <IActionResult> Post([FromBody] ShipAddress value)
        {
            string userID = HttpContext.User.Identity.Name;
            int    count  = await _shipAddressRepository.AddAsync(value);

            return(Ok(value.AddressID));
        }
Пример #7
0
            public override XElement GenerateAddRq()
            {
                XElement Add = new XElement("CustomerAdd");

                Add.Add(Name?.ToQBXML(nameof(Name)));
                Add.Add(IsActive.ToQBXML(nameof(IsActive)));
                Add.Add(ClassRef?.ToQBXML(nameof(ClassRef)));
                Add.Add(ParentRef?.ToQBXML(nameof(ParentRef)));
                Add.Add(CompanyName?.ToQBXML(nameof(CompanyName)));
                Add.Add(Salutation?.ToQBXML(nameof(Salutation)));
                Add.Add(FirstName?.ToQBXML(nameof(FirstName)));
                Add.Add(MiddleName?.ToQBXML(nameof(MiddleName)));
                Add.Add(LastName?.ToQBXML(nameof(LastName)));
                Add.Add(JobTitle?.ToQBXML(nameof(JobTitle)));
                Add.Add(BillAddress?.ToQBXML(nameof(BillAddress)));
                Add.Add(ShipAddress?.ToQBXML(nameof(ShipAddress)));
                Add.Add(ShipToAddress?.ToQBXML(nameof(ShipToAddress)));
                Add.Add(Phone?.ToQBXML(nameof(Phone)));
                Add.Add(AltPhone?.ToQBXML(nameof(AltPhone)));
                Add.Add(Fax?.ToQBXML(nameof(Fax)));
                Add.Add(Email?.ToQBXML(nameof(Email)));
                Add.Add(Cc?.ToQBXML(nameof(Cc)));
                Add.Add(Contact?.ToQBXML(nameof(Contact)));
                Add.Add(AltContact?.ToQBXML(nameof(AltContact)));
                Add.Add(AdditionalContactRef?.ToQBXML(nameof(AdditionalContactRef)));
                Add.Add(Contacts?.ToQBXML <Contacts>(nameof(Contacts)));
                Add.Add(CustomerTypeRef?.ToQBXML(nameof(CustomerTypeRef)));
                Add.Add(TermsRef?.ToQBXML(nameof(TermsRef)));
                Add.Add(SalesRepRef?.ToQBXML(nameof(SalesRepRef)));
                Add.Add(OpenBalance?.ToQBXML(nameof(OpenBalance)));
                Add.Add(OpenBalanceDate?.ToQBXML(nameof(OpenBalanceDate)));
                Add.Add(SalesTaxCodeRef?.ToQBXML(nameof(SalesTaxCodeRef)));
                Add.Add(ItemSalesTaxRef?.ToQBXML(nameof(ItemSalesTaxRef)));
                Add.Add(ResaleNumber?.ToQBXML(nameof(ResaleNumber)));
                Add.Add(AccountNumber?.ToQBXML(nameof(AccountNumber)));
                Add.Add(CreditLimit?.ToQBXML(nameof(CreditLimit)));
                Add.Add(PreferredPaymentMethodRef?.ToQBXML(nameof(PreferredPaymentMethodRef)));
                Add.Add(CreditCardInfo?.ToQBXML(nameof(CreditCardInfo)));
                Add.Add(JobStatus.ToQBXML(nameof(JobStatus)));
                Add.Add(JobStartDate?.ToQBXML(nameof(JobStartDate)));
                Add.Add(JobProjectedEndDate?.ToQBXML(nameof(JobProjectedEndDate)));
                Add.Add(JobEndDate?.ToQBXML(nameof(JobEndDate)));
                Add.Add(JobDesc?.ToQBXML(nameof(JobDesc)));
                Add.Add(JobTypeRef?.ToQBXML(nameof(JobTypeRef)));
                Add.Add(Notes?.ToQBXML(nameof(Notes)));
                Add.Add(AdditionalNotes?.ToQBXML(nameof(AdditionalNotes)));
                Add.Add(PreferredDeliveryMethod.ToQBXML(nameof(PreferredDeliveryMethod)));
                Add.Add(PriceLevelRef?.ToQBXML(nameof(PriceLevelRef)));
                Add.Add(ExternalGUID?.ToQBXML(nameof(ExternalGUID)));
                Add.Add(CurrencyRef?.ToQBXML(nameof(CurrencyRef)));

                XElement AddRq = new XElement("CustomerAddRq");

                AddRq.Add(Add);
                AddRq.Add(IncludeRetElement?.ToQBXML(nameof(IncludeRetElement)));

                return(AddRq);
            }
Пример #8
0
        public async Task <IActionResult> Get(int id)
        {
            string      userID  = HttpContext.User.Identity.Name;
            ShipAddress address = await _shipAddressRepository.GetAsync(id);

            JsonResult result = new JsonResult(address);

            return(result);
        }
 public async Task <int> UpdateAsync(ShipAddress address)
 {
     if (null == address)
     {
         return(-1);
     }
     _dbContext.ShipAddress.Update(address);
     return(await _dbContext.SaveChangesAsync());
 }
Пример #10
0
        protected override void CreateOrUpdateObject(object obj)
        {
            IList <object> list        = (IList <object>)obj;
            Supplier       supplier    = (Supplier)list[0];
            ShipAddress    shipAddress = (ShipAddress)list[1];
            BillAddress    billAddress = (BillAddress)list[2];

            Supplier oldSupplier = supplierMgr.LoadSupplier(supplier.Code);

            if (oldSupplier == null)
            {
                supplier.IsActive = true;
                this.supplierMgr.CreateSupplier(supplier);
            }
            else
            {
                CloneHelper.CopyProperty(supplier, oldSupplier, this.Supplier2SupplierFields);
                this.supplierMgr.UpdateSupplier(oldSupplier);
            }


            BillAddress newBillAddress = this.billAddressMgr.LoadBillAddress(billAddress.Code);

            if (newBillAddress == null)
            {
                billAddress.IsActive = true;
                this.billAddressMgr.CreateBillAddress(billAddress);
            }
            else
            {
                CloneHelper.CopyProperty(billAddress, newBillAddress, this.BillAddress2BillAddressFields);
                this.billAddressMgr.UpdateBillAddress(newBillAddress);
            }

            ShipAddress newShipAddress = this.shipAddressMgr.LoadShipAddress(shipAddress.Code);

            if (newShipAddress == null)
            {
                shipAddress.IsActive = true;
                this.shipAddressMgr.CreateShipAddress(shipAddress);
            }
            else
            {
                CloneHelper.CopyProperty(shipAddress, newShipAddress, this.ShipAddress2ShipAddressFields);
                this.shipAddressMgr.UpdateShipAddress(newShipAddress);
            }
        }
Пример #11
0
        protected override void DeleteObject(object obj)
        {
            IList <object> list        = (IList <object>)obj;
            Supplier       supplier    = this.supplierMgr.LoadSupplier(((Supplier)list[0]).Code);
            ShipAddress    shipAddress = (ShipAddress)list[1];
            BillAddress    billAddress = (BillAddress)list[2];

            if (supplier != null)
            {
                supplier.IsActive = false;
                this.supplierMgr.UpdateSupplier(supplier);

                shipAddress.IsActive = false;
                this.shipAddressMgr.UpdateShipAddress(shipAddress);

                billAddress.IsActive = false;
                this.billAddressMgr.UpdateBillAddress(billAddress);
            }
        }
Пример #12
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id;
         hashCode = (hashCode * 397) ^ (CustomerId != null ? CustomerId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ EmployeeId;
         hashCode = (hashCode * 397) ^ OrderDate.GetHashCode();
         hashCode = (hashCode * 397) ^ RequiredDate.GetHashCode();
         hashCode = (hashCode * 397) ^ ShippedDate.GetHashCode();
         hashCode = (hashCode * 397) ^ ShipVia.GetHashCode();
         hashCode = (hashCode * 397) ^ Freight.GetHashCode();
         hashCode = (hashCode * 397) ^ (ShipName != null ? ShipName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipAddress != null ? ShipAddress.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipCity != null ? ShipCity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipRegion != null ? ShipRegion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipPostalCode != null ? ShipPostalCode.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipCountry != null ? ShipCountry.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #13
0
        public async Task <IActionResult> Create([Bind("AddressID,Address,City,PhoneNumber,Province,Receiver,UserID,ZipCode")] ShipAddress shipAddress)
        {
            if (ModelState.IsValid)
            {
                string temp = string.Empty;
                temp = Request.Form["dpProvince"].ToString();
                int provinceID = 0;
                int cityID     = 0;

                int.TryParse(temp, out provinceID);
                shipAddress.Province = await _addressRepository.GetProvinceNameAsync(provinceID);

                temp = Request.Form["dpProvince"].ToString();
                int.TryParse(temp, out cityID);
                shipAddress.City = await _addressRepository.GetCityNameAsync(cityID);

                shipAddress.UserID = HttpContext.User.Identity.Name;
                int count = await _addressRepository.AddAsync(shipAddress);

                return(RedirectToAction("Index"));
            }
            return(View(shipAddress));
        }
Пример #14
0
        private object Deserialize(DssImportHistory dssImportHistory)
        {
            Customer customer = new Customer();

            customer.Code = dssImportHistory[1].ToUpper();
            customer.Name = dssImportHistory[2];

            ShipAddress shipAddress = new ShipAddress();

            shipAddress.Code              = "S_" + customer.Code.ToUpper();
            shipAddress.Address           = dssImportHistory[3];
            shipAddress.ContactPersonName = dssImportHistory[12];
            shipAddress.TelephoneNumber   = dssImportHistory[13] + dssImportHistory[14];
            shipAddress.Fax         = dssImportHistory[15];
            shipAddress.MobilePhone = dssImportHistory[17] + dssImportHistory[18];
            shipAddress.PostalCode  = dssImportHistory[8];
            shipAddress.Party       = customer;

            BillAddress billAddress = new BillAddress();

            billAddress.Code              = "B_" + customer.Code.ToUpper();
            billAddress.Address           = dssImportHistory[3];
            billAddress.ContactPersonName = dssImportHistory[12];
            billAddress.TelephoneNumber   = dssImportHistory[13] + dssImportHistory[14];
            billAddress.Fax         = dssImportHistory[15];
            billAddress.MobilePhone = dssImportHistory[17] + dssImportHistory[18];
            billAddress.PostalCode  = dssImportHistory[8];
            billAddress.Party       = customer;

            IList <object> list = new List <object>();

            list.Add(customer);
            list.Add(shipAddress);
            list.Add(billAddress);
            return(list);
        }
Пример #15
0
        private object Deserialize(DssImportHistory dssImportHistory)
        {
            Supplier supplier = new Supplier();

            supplier.Code = dssImportHistory[1].ToUpper();
            supplier.Name = dssImportHistory[3];

            ShipAddress shipAddress = new ShipAddress();

            shipAddress.Code              = "S_" + supplier.Code.ToUpper();
            shipAddress.Address           = dssImportHistory[4];
            shipAddress.ContactPersonName = dssImportHistory[13];
            shipAddress.TelephoneNumber   = dssImportHistory[14] + dssImportHistory[15];
            shipAddress.Fax         = dssImportHistory[16];
            shipAddress.MobilePhone = dssImportHistory[18] + dssImportHistory[19];
            shipAddress.PostalCode  = dssImportHistory[9];
            shipAddress.Party       = supplier;

            BillAddress billAddress = new BillAddress();

            billAddress.Code              = "B_" + supplier.Code.ToUpper();
            billAddress.Address           = dssImportHistory[4];
            billAddress.ContactPersonName = dssImportHistory[13];
            billAddress.TelephoneNumber   = dssImportHistory[14] + dssImportHistory[15];
            billAddress.Fax         = dssImportHistory[16];
            billAddress.MobilePhone = dssImportHistory[18] + dssImportHistory[19];
            billAddress.PostalCode  = dssImportHistory[9];
            billAddress.Party       = supplier;

            IList <object> list = new List <object>();

            list.Add(supplier);
            list.Add(shipAddress);
            list.Add(billAddress);
            return(list);
        }
Пример #16
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id;
         hashCode = (hashCode * 397) ^ (Customer != null ? Customer.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Employee != null ? Employee.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ OrderDate.GetHashCode();
         hashCode = (hashCode * 397) ^ RequiredDate.GetHashCode();
         hashCode = (hashCode * 397) ^ ShippedDate.GetHashCode();
         hashCode = (hashCode * 397) ^ ShipVia.GetHashCode();
         hashCode = (hashCode * 397) ^ Freight.GetHashCode();
         hashCode = (hashCode * 397) ^ (ShipName != null ? ShipName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipAddress != null ? ShipAddress.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipCity != null ? ShipCity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipRegion != null ? ShipRegion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipPostalCode != null ? ShipPostalCode.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShipCountry != null ? ShipCountry.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OrderDetails != null ? OrderDetails.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntIds != null ? IntIds.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CharMap != null ? CharMap.GetHashCode() : 0);
         return(hashCode);
     }
 }
 public virtual void CreateShipAddress(ShipAddress entity)
 {
     entityDao.CreateShipAddress(entity);
 }
Пример #18
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (OrderID != 0)
            {
                hash ^= OrderID.GetHashCode();
            }
            if (CustomerID.Length != 0)
            {
                hash ^= CustomerID.GetHashCode();
            }
            if (EmployeeID != 0)
            {
                hash ^= EmployeeID.GetHashCode();
            }
            if (orderDate_ != null)
            {
                hash ^= OrderDate.GetHashCode();
            }
            if (requiredDate_ != null)
            {
                hash ^= RequiredDate.GetHashCode();
            }
            if (shippedDate_ != null)
            {
                hash ^= ShippedDate.GetHashCode();
            }
            if (ShipVia != 0)
            {
                hash ^= ShipVia.GetHashCode();
            }
            if (Freight != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Freight);
            }
            if (ShipName.Length != 0)
            {
                hash ^= ShipName.GetHashCode();
            }
            if (ShipAddress.Length != 0)
            {
                hash ^= ShipAddress.GetHashCode();
            }
            if (ShipCity.Length != 0)
            {
                hash ^= ShipCity.GetHashCode();
            }
            if (ShipRegion.Length != 0)
            {
                hash ^= ShipRegion.GetHashCode();
            }
            if (ShipPostalCode.Length != 0)
            {
                hash ^= ShipPostalCode.GetHashCode();
            }
            if (ShipCountry.Length != 0)
            {
                hash ^= ShipCountry.GetHashCode();
            }
            hash ^= lines_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #19
0
 public void DeleteShipAddress(ShipAddress address)
 {
     ShipAddressMgr.DeleteShipAddress(address);
 }
        private void Assert_that_SubmitDropship_returned_the_expected_values_for_a_dropship_order_submitted_via_SendReturnMailers(string actualExceptionMessage, ActionResult resultSubmitDropship, string wtnValue, string commentsValue, string customerNameValue, string emailValue, string equipmentCatalogValue, OrderModel myOrderModel, ShipAddress expectedShipAddress, string expectedProduct01SKU, string expectedProduct01Qty, string expectedProduct02SKU, string expectedProduct02Qty)
        {
            //1st Assert
            Assert.IsNotNull(resultSubmitDropship, "SubmitDropship method returned null");
            if (resultSubmitDropship is ContentResult)
            {
                var content = ((ContentResult)resultSubmitDropship).Content;
                Assert.Fail("The return was expected to be a PartialViewResult; instead it was a ContentResult. This normally means there was an exception. Here is the content {0}", content);
            }
            Assert.IsTrue(resultSubmitDropship is PartialViewResult, "The return from the SubmitDropship action method was not a PartialViewResult");

            //2nd Act
            var resultSubmitDropshipAsViewResult = resultSubmitDropship as PartialViewResult;

            //2nd Assert
            Assert.IsTrue(resultSubmitDropshipAsViewResult.Model is OrderModel, "The model from the SubmitDropship action method was not a OrderModel");

            //3rd Act
            var resultOrderModel = resultSubmitDropshipAsViewResult.Model as OrderModel;
            var resultLineItems = resultOrderModel.LineItems;

            //3rd Assert
            Assert.IsNotNull(resultLineItems, "The LineItems list from the OrderModel is null");

            Assert.AreEqual(myOrderModel.LineItems.Count, resultLineItems.Count, "The LineItems count is not the expected value");

            var index = 0;
            foreach (var individualLineItem in resultLineItems)
            {
                //4th Assert
                Assert.AreEqual(myOrderModel.LineItems[index].Category.Trim().ToUpper(), individualLineItem.Category.Trim().ToUpper(), "The LineItem Category for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].Description.Trim().ToUpper(), individualLineItem.Description.Trim().ToUpper(), "The LineItem Description for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].EquipTypeId, individualLineItem.EquipTypeId, "The LineItem EquipTypeId for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].Fulfilled, individualLineItem.Fulfilled, "The LineItem Fulfilled for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].ItemNumber, individualLineItem.ItemNumber, "The LineItem ItemNumber for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].Model.Trim().ToUpper(), individualLineItem.Model.Trim().ToUpper(), "The LineItem Model for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].Quantity, individualLineItem.Quantity, "The LineItem Quantity for index of {0} is not the expected value", index);
                index++;
            }

            //5th Act
            var resultOrder = resultOrderModel.Order;

            //5th Assert
            Assert.IsNotNull(resultOrder, "The Order object is null");
            Assert.AreNotEqual(0, resultOrder.OrderId, "The OrderId value is 0");
            Assert.AreNotEqual(0, resultOrder.MasterOrderId, "The MasterOrderId value is 0");
            Assert.IsNotNull(resultOrder.ShipAddress, "The ShipAddress is null (this is really the Id, not the object)");
            Assert.IsNotNull(resultOrder.ShipAddress1, "The Ship1Address1 is null (this is the object");

            //6th Act
            var resultShipAddress1 = resultOrder.ShipAddress1;

            //6th Assert
            // Here I can actually test the address information as this isn't a live subscriber and the address information here should match the inputs
            Assert.AreEqual(expectedShipAddress.Address1.Trim().ToUpper(), resultShipAddress1.Address1.Trim().ToUpper(), "Address1 is not the expected value");
            Assert.AreEqual(expectedShipAddress.Address2.Trim().ToUpper(), resultShipAddress1.Address2.Trim().ToUpper(), "Address2 is not the expected value");
            Assert.AreEqual(expectedShipAddress.Cbr, resultShipAddress1.Cbr, "CBR is not the expected value");
            Assert.AreEqual(expectedShipAddress.City.Trim().ToUpper(), resultShipAddress1.City.Trim().ToUpper(), "City is not the expected value");
            Assert.AreEqual(expectedShipAddress.Email.Trim().ToUpper(), resultShipAddress1.Email.Trim().ToUpper(), "Email is not the expected value");
            Assert.AreEqual(expectedShipAddress.State.Trim().ToUpper(), resultShipAddress1.State.Trim().ToUpper(), "State is not the expected value");
            Assert.IsNotNull(resultShipAddress1.UserEntered, "UserEntered is null");
            Assert.AreEqual(expectedShipAddress.UserEntered, resultShipAddress1.UserEntered, "UserEntered is not the expected value");
            Assert.AreEqual(expectedShipAddress.Zip.Trim().ToUpper(), resultShipAddress1.Zip.Trim().ToUpper(), "Zip is not the expected value");

            using (var db = DBContextFactory.CreateContext())
            {
                //7th Act
                var comments = db.Comments.FirstOrDefault(x => x.CommentText == commentsValue);

                //7th Assert
                Assert.IsNotNull(comments, "Comments is null");
                Assert.AreNotEqual(0, comments.CommentId, "CommentId is not valid value");
                Assert.AreEqual(resultOrder.MasterOrderId, comments.CommentOrderId, "CommentOrdeId is not the expected value");

                //8th Act
                var itxOrders = db.ItxOrders.FirstOrDefault(x => x.OrderId == resultOrder.OrderId);

                //8th Assert
                Assert.IsNotNull(itxOrders, "ItxOrders is null");
                Assert.AreNotEqual(0, itxOrders.ItxOrderId, "ItxOrderId is not valid value");

                // OrderId was already checked with the FirstOrDefault
                Assert.IsNull(itxOrders.SentToItx, "SentToItx is not null. itxOrders.SentToItx: " + itxOrders.SentToItx);
                Assert.IsNull(itxOrders.SentDateTime, "SentDateTime is not null. itxOrders.SentDateTime: " + itxOrders.SentDateTime);
                Assert.IsNotNull(itxOrders.GenerationDateTime, "GenerationDateTime is null");
                Assert.AreEqual(1, itxOrders.ProductCatalogTypeId, "ProductCatalogTypeId is not the expected value");

                // For orders placed in our test system for AT&T / CT, they are converted from a equipment catalog value of 69 to 60 (ItxOrderHelper.cs, SubmitOrder method)
                var environment = ConfigurationManager.AppSettings["Environment"];
                Assert.IsNotNull(environment, "Environment appSetting key is missing");
                var localEquipmentCatalogValue = Convert.ToInt32(equipmentCatalogValue);
                var convertedEquipmentCatalogValue = (environment.ToUpper() != "PROD" && localEquipmentCatalogValue == Int32.Parse(UVerseCatalogId)) ? 60 : localEquipmentCatalogValue;

                Assert.AreEqual(convertedEquipmentCatalogValue, itxOrders.ProductCatalogID, "ProductCatalogID is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.OrderNumber, "OrderNumber is not the expected value");
                Assert.AreEqual(1, itxOrders.OrderStatusID, "OrderStatusID is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.ReturnInfo, "ReturnInfo is not the expected value");
                Assert.AreEqual(wtnValue, itxOrders.CustomerPhoneNumber.Trim(), "CustomerPhoneNumber is not the expected value");

                // Here I can actually test the actual FirstName, LastName, and email address values as this isn't a live subscriber and the information here should match the inputs
                // Note: since customerNameValue only has one word in it, all the data will be in the first name
                Assert.AreEqual(customerNameValue, itxOrders.CustomerFirstName, "CustomerFirstName is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.CustomerLastName, "CustomerLastName is not the expected value");
                Assert.AreEqual(emailValue, itxOrders.CustomerEmail, "CustomerEmail is not the expected value");

                // Note: since customerNameValue only has one word in it, all the data will be in the first name
                Assert.AreEqual(customerNameValue, itxOrders.ShipName1, "ShipName1 is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.ShipName2, "ShipName2 is not the expected value");
                Assert.AreEqual(expectedShipAddress.Address1, itxOrders.ShipAddress1, "ShipAddress1 is not the expected value");
                Assert.AreEqual(expectedShipAddress.Address2, itxOrders.ShipAddress2, "ShipAddress2 is not the expected value");
                Assert.AreEqual(expectedShipAddress.City, itxOrders.ShipCity, "ShipCity is not the expected value");
                Assert.AreEqual(expectedShipAddress.State, itxOrders.ShipState, "ShipState is not the expected value");
                Assert.AreEqual(expectedShipAddress.Zip, itxOrders.ShipZip, "ShipZip is not the expected value");

                // Ship instructions for orders placed in test will have specific text in it
                Assert.AreEqual("TEST: DO NOT SHIP", itxOrders.ShipInstructions.Trim().ToUpper(), "ShipInstructions is not the expected value");

                // Billing information should all be empty
                Assert.AreEqual(string.Empty, itxOrders.BillName, "BillName is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillAddress1, "BillAddress1 is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillAddress2, "BillAddress2 is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillCity, "BillCity is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillState, "BillState is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillZip, "BillZip is not the expected value");

                // Only the first and second Product SKU columns should be filled in with a quantity of 1
                // all of the other fields will be empty strings
                Assert.AreEqual(expectedProduct01SKU, itxOrders.Product01SKU.Trim().ToUpper(), "Product01SKU is not the expected value");
                Assert.AreEqual(expectedProduct01Qty, itxOrders.Product01Qty, "Product01Qty is not the expected value");
                Assert.AreEqual(expectedProduct02SKU, itxOrders.Product02SKU.Trim().ToUpper(), "Product02SKU is not the expected value");
                Assert.AreEqual(expectedProduct02Qty, itxOrders.Product02Qty, "Product02Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product03SKU, "Product03SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product03Qty, "Product03Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product04SKU, "Product04SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product04Qty, "Product04Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product05SKU, "Product05SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product05Qty, "Product05Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product06SKU, "Product06SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product06Qty, "Product06Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product07SKU, "Product07SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product07Qty, "Product07Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product08SKU, "Product08SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product08Qty, "Product08Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product09SKU, "Product09SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product09Qty, "Product09Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product10SKU, "Product10SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product10Qty, "Product10Qty is not the expected value");
            }
        }
        public void A_user_can_submit_the_Dropship_Order_modal_window_when_the_UVerse_subscriber_has_a_correctly_formed_WTN()
        {
            // will run as uitestuser (via code in TestInitialize method)

            // Given a known user
            // and a known UVerse (Connecticut) subscriber with a correctly formed WTN
            const string subscriberIdValue = "490003615254"; // Using well-known Middletown, CT "test" subscriber (from list attached to email by Andrew T. on 11/12/2014)
            const string wtnValue = "8608523792";

            // and the rest of the "Dropship Order" Modal window has been filled out correctly
            const string orderTypeValue = "dropship";        // this is set in the OrderEquipmentDropship_Partial and is "dropship" for dropship orders
            var equipmentCatalogValue = UVerseCatalogId;
            const string qty_83Value = "1";                  // means EquipmentTypeId of 83, and a quantity of 1 (that EquipmentTypeId must exist in the EquipmentTypes table in SIMPL database)
            var commentsValue = string.Format("Integration Test, Dropship Equipment Order, UVerse Subscriber, generated on {0} at {1}", DateTime.Now.ToLongDateString(), DateTime.Now.ToLongTimeString());

            var fields = new FormCollection
            {
                new NameValueCollection
                {
                    {
                        "SubscriberId", subscriberIdValue
                    },
                    {
                        "OrderType", orderTypeValue
                    },
                    {
                        "EquipmentCatalog", equipmentCatalogValue
                    },
                    {
                        "qty_83", qty_83Value
                    },
                    {
                        "comments", commentsValue
                    },
                    {
                        "WTN", wtnValue
                    }

                }
            };

            var myOrderModel = new OrderModel();

            // Right now this is hardcoded, this might fail if the text is changed in the database
            var myFirstExpectedLineItem = new LineItem
            {
                Category = "Modem",
                Description = "RG - VAP2500 Wireless Access Point",
                EquipTypeId = 83,
                Fulfilled = false,
                ItemNumber = 2500,
                Model = "VAP2500",
                Quantity = 1
            };

            var mySecondExpectedLineItem = new LineItem
            {
                Category = "Misc",
                Description = "Frontier TV Combo Letter",
                EquipTypeId = 91,
                Fulfilled = false,
                ItemNumber = 1004,
                Model = "FTR TV COMBO LETTER",
                Quantity = 1
            };

            myOrderModel.LineItems.Add(myFirstExpectedLineItem);
            myOrderModel.LineItems.Add(mySecondExpectedLineItem);

            const string expectedProduct01SKU = "VAP2500KIT";
            const string expectedProduct01Qty = "1";
            const string expectedProduct02SKU = "FTRTVCOMBOLTR";
            const string expectedProduct02Qty = "1";

            var actualExceptionMessage = string.Empty;

            var subscriber = CurrentSubscriber.GetInstance();
            CurrentSubscriber.SetInstance(subscriberIdValue);

            var expectedShipAddress = new ShipAddress
            {
                Address1 = CleanOrderField(subscriber.Address),
                Address2 = CleanOrderField(subscriber.Address2),
                Name = CleanOrderField(subscriber.Name),
                City = CleanOrderField(subscriber.City),
                Zip = CleanOrderField(subscriber.Zip),
                Email = CleanOrderField(subscriber.Email),
                State = CleanOrderField(subscriber.State),
                UserEntered = false,
                WTN = wtnValue,
                Cbr = null
            };

            ActionResult resultSubmitDropship = null;
            try
            {
                //1st Act
                // when submitting the data
                resultSubmitDropship = EquipmentOrderControllerForTests.SubmitDropship(fields);
            }
            catch (Exception ex)
            {
                actualExceptionMessage = ex.Message;
            }

            // Note: for UVerse orders, the development database has the value as 60 instead of 69, so passing "60" instead of the equipmentCatalogValue
            Assert_that_SubmitDropship_returned_the_expected_values_for_a_regular_dropship_order(actualExceptionMessage, resultSubmitDropship, wtnValue, commentsValue, "60", myOrderModel, expectedShipAddress, expectedProduct01SKU, expectedProduct01Qty, expectedProduct02SKU, expectedProduct02Qty);
        }
 public virtual void DeleteShipAddress(ShipAddress entity)
 {
     Delete(entity);
 }
Пример #23
0
 public virtual void CreateShipAddress(ShipAddress entity)
 {
     Create(entity);
 }
 public virtual void UpdateShipAddress(ShipAddress entity)
 {
     Update(entity);
 }
        public void A_dropship_return_mailer_order_for_three_TiVo_Mini_devices_will_have_1_line_item_which_has_quantity_3_for_the_return_mailer()
        {
            // will run as uitestuser (via code in TestInitialize method)

            // Given a known subscriber with TiVo service
            const string subscriberIdValue = "130000259078"; // Alice Buffkin, North Myrtle Beach SC - FiOS data and TiVo service
            const string wtnValue = "8641330868";

            // and the rest of the "Dropship Order" Modal window has been filled out correctly
            const string orderTypeValue = "dropship";        // this is set in the OrderEquipmentDropship_Partial and is "dropship" for dropship orders
            var equipmentCatalogValue = TiVoReturnMailerCatalogId;
            const string qty_104Value = "3";                 // means EquipmentTypeId of 104, and a quantity of 3 (that EquipmentTypeId must exist in the EquipmentTypes table in SIMPL database)
            var commentsValue = string.Format("Integration Test, Dropship Return Mailer Order, TiVo return mailer for 3 TiVo Minis, generated on {0} at {1}", DateTime.Now.ToLongDateString(), DateTime.Now.ToLongTimeString());

            var fields = new FormCollection
            {
                new NameValueCollection
                {
                    {
                        "SubscriberId", subscriberIdValue
                    },
                    {
                        "OrderType", orderTypeValue
                    },
                    {
                        "EquipmentCatalog", equipmentCatalogValue
                    },
                    {
                        "qty_104", qty_104Value
                    },
                    {
                        "comments", commentsValue
                    },
                    {
                        "WTN", wtnValue
                    }

                }
            };

            var myOrderModel = new OrderModel();

            // Right now this is hardcoded, this might fail if the text is changed in the database
            // TiVo (OTA)     - right now there will not be any 4-packs
            var myFirstExpectedLineItem = new LineItem
            {
                Category = "Returnmailer",
                Description = "Return Mailer - TiVo Mini",
                EquipTypeId = 104,
                Fulfilled = false,
                ItemNumber = 5004,
                Model = "RTTVMINI1PK",
                Quantity = 3
            };

            myOrderModel.LineItems.Add(myFirstExpectedLineItem);

            const string expectedProduct01SKU = "FRDMTVMINISTRMRTNKIT";
            const string expectedProduct01Qty = "3";
            var expectedProduct02SKU = string.Empty;
            var expectedProduct02Qty = string.Empty;

            var actualExceptionMessage = string.Empty;

            var subscriber = CurrentSubscriber.GetInstance();
            CurrentSubscriber.SetInstance(subscriberIdValue);

            var expectedShipAddress = new ShipAddress
            {
                Address1 = CleanOrderField(subscriber.Address),
                Address2 = CleanOrderField(subscriber.Address2),
                Name = CleanOrderField(subscriber.Name),
                City = CleanOrderField(subscriber.City),
                Zip = CleanOrderField(subscriber.Zip),
                Email = CleanOrderField(subscriber.Email),
                State = CleanOrderField(subscriber.State),
                UserEntered = false,
                WTN = wtnValue,
                Cbr = null
            };

            ActionResult resultSubmitDropship = null;
            try
            {
                //1st Act
                // when submitting the data
                resultSubmitDropship = EquipmentOrderControllerForTests.SubmitDropship(fields);
            }
            catch (Exception ex)
            {
                actualExceptionMessage = ex.Message;
            }

            Assert_that_SubmitDropship_returned_the_expected_values_for_a_regular_dropship_order(actualExceptionMessage, resultSubmitDropship, wtnValue, commentsValue, equipmentCatalogValue, myOrderModel, expectedShipAddress, expectedProduct01SKU, expectedProduct01Qty, expectedProduct02SKU, expectedProduct02Qty);
        }
Пример #26
0
        public PickList CreatePickList(IList <OrderLocationTransaction> orderLocationTransactionList, User user)
        {
            List <OrderLocationTransaction>  targetOrderLocationTransactionList = new List <OrderLocationTransaction>();
            OrderLocationTransactionComparer orderLocationTransactionComparer   = new OrderLocationTransactionComparer();

            if (orderLocationTransactionList != null && orderLocationTransactionList.Count > 0)
            {
                foreach (OrderLocationTransaction orderLocationTransaction in orderLocationTransactionList)
                {
                    if (orderLocationTransaction.CurrentShipQty > 0)
                    {
                        targetOrderLocationTransactionList.Add(orderLocationTransaction);
                    }
                }
            }

            if (targetOrderLocationTransactionList.Count == 0)
            {
                throw new BusinessErrorException("Order.Error.PickUp.DetailEmpty");
            }
            else
            {
                //按FromLocation、零件号、单位、单包装排序
                targetOrderLocationTransactionList.Sort(orderLocationTransactionComparer);
            }

            string      orderType          = null;
            Party       partyFrom          = null;
            Party       partyTo            = null;
            ShipAddress shipFrom           = null;
            ShipAddress shipTo             = null;
            string      dockDescription    = null;
            bool?       isShipScanHu       = null;
            bool?       isReceiptScanHu    = null;
            bool?       isAutoReceive      = null;
            decimal?    completeLatency    = null;
            string      grGapTo            = null;
            string      asnTemplate        = null;
            string      receiptTemplate    = null;
            string      flow               = null;
            DateTime?   windowTime         = null;
            bool?       isAsnUniqueReceipt = null;

            #region 判断OrderHead的PartyFrom, PartyTo, ShipFrom, ShipTo, DockDescription是否一致
            foreach (OrderLocationTransaction orderLocationTransaction in targetOrderLocationTransactionList)
            {
                OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
                OrderHead   orderHead   = orderDetail.OrderHead;

                //判断OrderHead的Type是否一致
                if (orderType == null)
                {
                    orderType = orderHead.Type;
                }
                else if (orderHead.Type != orderType)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.OrderTypeNotEqual");
                }

                //判断OrderHead的PartyFrom是否一致
                if (partyFrom == null)
                {
                    partyFrom = orderHead.PartyFrom;
                }
                else if (orderHead.PartyFrom.Code != partyFrom.Code)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.PartyFromNotEqual");
                }

                //判断OrderHead的PartyFrom是否一致
                if (partyTo == null)
                {
                    partyTo = orderHead.PartyTo;
                }
                else if (orderHead.PartyTo.Code != partyTo.Code)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.PartyToNotEqual");
                }

                //判断OrderHead的ShipFrom是否一致
                if (shipFrom == null)
                {
                    shipFrom = orderHead.ShipFrom;
                }
                else if (!AddressHelper.IsAddressEqual(orderHead.ShipFrom, shipFrom))
                {
                    throw new BusinessErrorException("Order.Error.PickUp.ShipFromNotEqual");
                }

                //判断OrderHead的ShipTo是否一致
                if (shipTo == null)
                {
                    shipTo = orderHead.ShipTo;
                }
                else if (!AddressHelper.IsAddressEqual(orderHead.ShipTo, shipTo))
                {
                    throw new BusinessErrorException("Order.Error.PickUp.ShipToNotEqual");
                }

                //判断OrderHead的DockDescription是否一致
                if (dockDescription == null)
                {
                    dockDescription = orderHead.DockDescription;
                }
                else if (orderHead.DockDescription != dockDescription)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.DockDescriptionNotEqual");
                }

                //判断OrderHead的IsShipScanHu是否一致
                if (isShipScanHu == null)
                {
                    isShipScanHu = orderHead.IsShipScanHu;
                }
                else if (orderHead.IsShipScanHu != isShipScanHu)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.IsShipScanHuNotEqual");
                }

                //判断OrderHead的IsReceiptScanHu是否一致
                if (isReceiptScanHu == null)
                {
                    isReceiptScanHu = orderHead.IsReceiptScanHu;
                }
                else if (orderHead.IsReceiptScanHu != isReceiptScanHu)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.IsReceiptScanHuNotEqual");
                }

                //判断OrderHead的IsAutoReceipt是否一致
                if (isAutoReceive == null)
                {
                    isAutoReceive = orderHead.IsAutoReceive;
                }
                else if (orderHead.IsAutoReceive != isAutoReceive)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.IsAutoReceiveNotEqual");
                }

                //判断OrderHead的CompleteLatency是否一致
                if (completeLatency == null)
                {
                    completeLatency = orderHead.CompleteLatency;
                }
                else
                {
                    if (orderHead.CompleteLatency.HasValue && orderHead.CompleteLatency != completeLatency)
                    {
                        throw new BusinessErrorException("Order.Error.PickUp.CompleteLatencyNotEqual");
                    }
                }

                //判断OrderHead的GoodsReceiptGapTo是否一致
                if (grGapTo == null)
                {
                    grGapTo = orderHead.GoodsReceiptGapTo;
                }
                else
                {
                    if (orderHead.GoodsReceiptGapTo != null && orderHead.GoodsReceiptGapTo != grGapTo)
                    {
                        throw new BusinessErrorException("Order.Error.PickUp.GoodsReceiptGapToNotEqual");
                    }
                }

                //判断OrderHead的AsnTemplate是否一致
                if (asnTemplate == null)
                {
                    asnTemplate = orderHead.AsnTemplate;
                }
                else
                {
                    if (orderHead.AsnTemplate != null && orderHead.AsnTemplate != asnTemplate)
                    {
                        throw new BusinessErrorException("Order.Error.PickUp.AsnTemplateNotEqual");
                    }
                }

                //判断OrderHead的ReceiptTemplate是否一致
                if (receiptTemplate == null)
                {
                    receiptTemplate = orderHead.ReceiptTemplate;
                }
                else
                {
                    if (orderHead.ReceiptTemplate != null && orderHead.ReceiptTemplate != receiptTemplate)
                    {
                        throw new BusinessErrorException("Order.Error.PickUp.ReceiptTemplateNotEqual");
                    }
                }

                //判断OrderHead的Flow是否一致
                if (flow == null)
                {
                    flow = orderHead.Flow;
                }
                else if (orderHead.Flow != flow)
                {
                    //throw new BusinessErrorException("Order.Error.PickUp.FlowNotEqual");
                }

                //寻找最小的WindowTime
                if (!windowTime.HasValue)
                {
                    windowTime = orderHead.WindowTime;
                }
                else if (windowTime.Value > orderHead.WindowTime)
                {
                    windowTime = orderHead.WindowTime;
                }

                //判断OrderHead的IsAsnUniqueReceipt是否一致
                if (isAsnUniqueReceipt == null)
                {
                    isAsnUniqueReceipt = orderHead.IsAsnUniqueReceipt;
                }
                else if (orderHead.IsAsnUniqueReceipt != isAsnUniqueReceipt)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.IsAsnUniqueReceiptNotEqual");
                }
            }
            #endregion

            #region 创建捡货单头
            DateTime dateTimeNow = DateTime.Now;

            PickList pickList = new PickList();

            pickList.PickListNo        = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_PICKLIST);
            pickList.Status            = BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT;
            pickList.PickBy            = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_PICK_BY).Value;
            pickList.OrderType         = orderType;
            pickList.PartyFrom         = partyFrom;
            pickList.PartyTo           = partyTo;
            pickList.ShipFrom          = shipFrom;
            pickList.ShipTo            = shipTo;
            pickList.DockDescription   = dockDescription;
            pickList.CreateDate        = dateTimeNow;
            pickList.CreateUser        = user;
            pickList.LastModifyDate    = dateTimeNow;
            pickList.LastModifyUser    = user;
            pickList.IsShipScanHu      = isShipScanHu.Value;
            pickList.IsReceiptScanHu   = isReceiptScanHu.Value;
            pickList.IsAutoReceive     = isAutoReceive.Value;
            pickList.CompleteLatency   = completeLatency;
            pickList.GoodsReceiptGapTo = grGapTo;
            pickList.AsnTemplate       = asnTemplate;
            pickList.ReceiptTemplate   = receiptTemplate;
            pickList.Flow               = flow;
            pickList.WindowTime         = windowTime.Value;
            pickList.IsAsnUniqueReceipt = isAsnUniqueReceipt.Value;

            this.CreatePickList(pickList);
            #endregion

            #region 创建捡货单明细
            int index = 0;
            IList <LocationLotDetail> locationLotDetailList         = null;
            IList <LocationLotDetail> occupiedLocationLotDetailList = null; //捡货占用库存
            for (int i = 0; i < targetOrderLocationTransactionList.Count; i++)
            {
                OrderLocationTransaction orderLocationTransaction     = targetOrderLocationTransactionList[i];                     //本次循环OrderLocationTransaction
                OrderLocationTransaction lastOrderLocationTransaction = i == 0 ? null : targetOrderLocationTransactionList[i - 1]; //上次OrderLocationTransaction
                List <PickListDetail>    pickListDetailList           = new List <PickListDetail>();                               //本次生成的PickListDetail列表

                OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
                OrderHead   orderHead   = orderDetail.OrderHead;
                decimal     shipQty     = orderLocationTransaction.CurrentShipQty; //库存单位

                #region 过量拣货判断
                decimal pickedQty = 0; //其它拣货单的待拣货数量,只考虑Submit和InProcess状态
                IList <PickListDetail> pickedPickListDetailList = this.pickListDetailMgr.GetPickedPickListDetail(orderLocationTransaction.Id);
                if (pickedPickListDetailList != null && pickedPickListDetailList.Count > 0)
                {
                    foreach (PickListDetail pickListDetail in pickedPickListDetailList)
                    {
                        if (pickListDetail.PickList.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT ||
                            pickListDetail.PickList.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)
                        {
                            pickedQty += pickListDetail.Qty;
                        }
                    }
                }

                //累计发货数量 + 待捡货数量 + 本次拣货数量 不能大于 订单数量
                if ((orderLocationTransaction.AccumulateQty.HasValue ? orderLocationTransaction.AccumulateQty.Value : 0) + shipQty + pickedQty > orderLocationTransaction.OrderedQty)
                {
                    throw new BusinessErrorException("MasterData.PickList.Error.PickExcceed", orderLocationTransaction.Item.Code);
                }
                #endregion

                //比较本次OrderLocationTransaction和上次OrderLocationTransaction,如果不相同需重新查找locationLotDetailList和重置index
                //为了处理订单合并捡货时,相同零件推荐的Hu/LotNo不重复问题
                if (lastOrderLocationTransaction == null ||
                    orderLocationTransactionComparer.Compare(lastOrderLocationTransaction, orderLocationTransaction) == -1)
                {
                    index = 0;

                    #region 零头发货选项查询待拣货列表
                    string oddShipOption = orderDetail.OddShipOption;

                    if (oddShipOption == null || oddShipOption.Trim() == string.Empty)
                    {
                        CodeMaster codeMaster = this.codeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION);

                        oddShipOption = codeMaster.Value;
                    }

                    if (oddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_SHIP_FIRST)
                    {
                        //零头优先发、LotnNo先进先出、货架、包装
                        if (orderHead.IsPickFromBin)
                        {
                            locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, null, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "sb.Sequence;Asc", "Qty;Asc", "Id;Asc" }, orderHead.IsPickFromBin, true, null, null, true);
                        }
                        else
                        {
                            locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, null, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "Qty;Asc", "Id;Asc" }, orderHead.IsPickFromBin, false, null, null, true);
                        }
                        #region 重新排序,把零头放在前面
                        if (locationLotDetailList != null && locationLotDetailList.Count > 0)
                        {
                            IList <LocationLotDetail> oddLocationLotDetailList   = new List <LocationLotDetail>();
                            IList <LocationLotDetail> noOddLocationLotDetailList = new List <LocationLotDetail>();
                            foreach (LocationLotDetail locationLotDetail in locationLotDetailList)
                            {
                                if (!this.locationMgr.IsHuOcuppyByPickList(locationLotDetail.Hu.HuId))
                                {
                                    if (locationLotDetail.Hu.Qty < orderDetail.UnitCount)
                                    {
                                        oddLocationLotDetailList.Add(locationLotDetail);
                                        shipQty += locationLotDetail.Qty;  //零头一定要先发走,不占用待拣货数量
                                    }
                                    else
                                    {
                                        noOddLocationLotDetailList.Add(locationLotDetail);
                                    }
                                }
                            }
                            locationLotDetailList = oddLocationLotDetailList;
                            IListHelper.AddRange <LocationLotDetail>(locationLotDetailList, noOddLocationLotDetailList);
                        }
                        #endregion
                    }
                    else if (oddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_NOT_SHIP)
                    {
                        //零头不发
                        if (orderHead.IsPickFromBin)
                        {
                            locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "sb.Sequence;Asc", "Id;Asc" }, orderHead.IsPickFromBin, true);
                        }
                        else
                        {
                            locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "Id;Asc" }, orderHead.IsPickFromBin, false);
                        }
                    }

                    #endregion

                    IList <PickListDetail> submitPickListDetailList = this.pickListDetailMgr.GetPickListDetail(orderLocationTransaction.Location.Code, orderDetail.Item.Code, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT, BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS });
                    //IList<PickListResult> inprocessPickListResultList = this.pickListResultMgr.GetPickListResult(orderLocationTransaction.Location.Code, orderDetail.Item.Code, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS });

                    occupiedLocationLotDetailList = this.Convert2OccupiedLocationLotDetail(submitPickListDetailList, pickList.PickBy);
                }

                if (locationLotDetailList != null && locationLotDetailList.Count > 0)
                {
                    PickListDetail lastestPickListDetail = null;
                    for (; index < locationLotDetailList.Count; index++)
                    {
                        LocationLotDetail locationLotDetail = locationLotDetailList[index];
                        decimal           locQty            = locationLotDetail.Qty;

                        if (pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_HU)
                        {
                            #region  Hu捡货

                            #region 过滤掉已经被推荐的库存
                            if (occupiedLocationLotDetailList != null && occupiedLocationLotDetailList.Count > 0)
                            {
                                bool findMatch = false;
                                foreach (LocationLotDetail occupiedLocationLotDetail in occupiedLocationLotDetailList)
                                {
                                    if (occupiedLocationLotDetail.Hu.HuId == locationLotDetail.Hu.HuId)
                                    {
                                        findMatch = true;
                                        continue;
                                    }
                                }

                                if (findMatch)
                                {
                                    continue;
                                }
                            }
                            #endregion

                            shipQty -= locQty;

                            PickListDetail pickListDetail = new PickListDetail();

                            pickListDetail.PickList = pickList;
                            pickListDetail.OrderLocationTransaction = orderLocationTransaction;
                            pickListDetail.Item      = orderLocationTransaction.Item;
                            pickListDetail.UnitCount = orderDetail.UnitCount;
                            pickListDetail.Uom       = orderDetail.Uom;
                            pickListDetail.HuId      = locationLotDetail.Hu.HuId;
                            pickListDetail.LotNo     = locationLotDetail.LotNo;
                            pickListDetail.Location  = locationLotDetail.Location;
                            if (locationLotDetail.StorageBin != null)
                            {
                                pickListDetail.StorageArea = locationLotDetail.StorageBin.Area;
                                pickListDetail.StorageBin  = locationLotDetail.StorageBin;
                            }
                            pickListDetail.Qty = locQty / orderLocationTransaction.UnitQty; //订单单位
                            this.pickListDetailMgr.CreatePickListDetail(pickListDetail);
                            pickList.AddPickListDetail(pickListDetail);
                            pickListDetailList.Add(pickListDetail);

                            if (shipQty <= 0)
                            {
                                index++;
                                break;
                            }
                            #endregion
                        }
                        else if (pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO)
                        {
                            #region  LotNo捡货

                            #region 过滤掉已经被推荐的库存
                            if (occupiedLocationLotDetailList != null && occupiedLocationLotDetailList.Count > 0)
                            {
                                foreach (LocationLotDetail occupiedLocationLotDetail in occupiedLocationLotDetailList)
                                {
                                    if (occupiedLocationLotDetail.Item.Code == locationLotDetail.Item.Code &&
                                        occupiedLocationLotDetail.LotNo == locationLotDetail.LotNo &&
                                        occupiedLocationLotDetail.Location.Code == locationLotDetail.Location.Code &&
                                        StorageBinHelper.IsStorageBinEqual(occupiedLocationLotDetail.StorageBin, locationLotDetail.StorageBin))
                                    {
                                        if (locationLotDetail.Hu.Qty < orderDetail.UnitCount)
                                        {
                                            shipQty -= locationLotDetail.Qty;  //如果零头被占用,需要扣减发货数量
                                        }

                                        if (occupiedLocationLotDetail.Qty == 0)
                                        {
                                            continue;
                                        }

                                        if (occupiedLocationLotDetail.Qty - locQty >= 0)
                                        {
                                            occupiedLocationLotDetail.Qty -= locQty;
                                            locQty = 0;
                                            continue;
                                        }
                                        else
                                        {
                                            occupiedLocationLotDetail.Qty = 0;
                                            locQty -= occupiedLocationLotDetail.Qty;
                                            break;
                                        }
                                    }
                                }

                                if (locQty == 0)
                                {
                                    continue;
                                }
                            }
                            #endregion

                            shipQty -= locQty;

                            if (shipQty < 0)
                            {
                                locQty += shipQty;
                                shipQty = 0;
                            }

                            if (lastestPickListDetail != null &&
                                lastestPickListDetail.LotNo == locationLotDetail.LotNo &&
                                StorageBinHelper.IsStorageBinEqual(lastestPickListDetail.StorageBin, locationLotDetail.StorageBin))
                            {
                                #region 合并捡货数量
                                lastestPickListDetail.Qty += locQty / orderLocationTransaction.UnitQty; //订单单位
                                this.pickListDetailMgr.UpdatePickListDetail(lastestPickListDetail);
                                #endregion
                            }
                            else
                            {
                                #region 新增捡货明细
                                lastestPickListDetail = new PickListDetail();

                                lastestPickListDetail.PickList = pickList;
                                lastestPickListDetail.OrderLocationTransaction = orderLocationTransaction;
                                lastestPickListDetail.Item      = orderLocationTransaction.Item;
                                lastestPickListDetail.UnitCount = locationLotDetail.Hu.UnitCount;  //可能拣货的包装和订单明细包装不一致,所以使用Hu上的单包装
                                lastestPickListDetail.Uom       = orderDetail.Uom;
                                lastestPickListDetail.LotNo     = locationLotDetail.Hu.LotNo;
                                lastestPickListDetail.Location  = locationLotDetail.Location;
                                if (locationLotDetail.StorageBin != null)
                                {
                                    lastestPickListDetail.StorageArea = locationLotDetail.StorageBin.Area;
                                    lastestPickListDetail.StorageBin  = locationLotDetail.StorageBin;
                                }
                                lastestPickListDetail.Qty = locQty / orderLocationTransaction.UnitQty; //订单单位

                                this.pickListDetailMgr.CreatePickListDetail(lastestPickListDetail);
                                pickList.AddPickListDetail(lastestPickListDetail);
                                pickListDetailList.Add(lastestPickListDetail);
                                #endregion
                            }

                            if (shipQty <= 0)
                            {
                                index++;
                                break;
                            }
                            #endregion
                        }
                        else
                        {
                            throw new TechnicalException("Invalied PickBy value:" + pickList.PickBy);
                        }
                    }
                }

                //if (pickListDetailList.Count == 0)
                //{
                //    throw new BusinessErrorException("MasterData.PickList.Error.NotEnoughInventory");
                //}

                if (shipQty > 0)
                {
                    PickListDetail pickListDetail = new PickListDetail();

                    pickListDetail.PickList = pickList;
                    pickListDetail.OrderLocationTransaction = orderLocationTransaction;
                    pickListDetail.Item      = orderLocationTransaction.Item;
                    pickListDetail.UnitCount = orderDetail.UnitCount;
                    pickListDetail.Uom       = orderDetail.Uom;
                    pickListDetail.Location  = orderLocationTransaction.Location;
                    pickListDetail.Qty       = shipQty / orderLocationTransaction.UnitQty;                                        //订单单位
                    pickListDetail.Memo      = this.languageMgr.TranslateMessage("MasterData.PickList.NotEnoughInventory", user); //设置Memo为库存不足

                    pickList.AddPickListDetail(pickListDetail);

                    this.pickListDetailMgr.CreatePickListDetail(pickListDetail);
                }

                if (pickListDetailList.Count > 0 && pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO)
                {
                    string lotNo         = string.Empty;
                    bool   hasMultiLotNo = false;
                    foreach (PickListDetail pickListDetail in pickListDetailList)
                    {
                        if (lotNo == string.Empty)
                        {
                            lotNo = pickListDetail.LotNo;
                        }
                        else if (lotNo != pickListDetail.LotNo)
                        {
                            hasMultiLotNo = true;
                            break;
                        }
                    }

                    //设置Memo为多批号
                    if (hasMultiLotNo)
                    {
                        foreach (PickListDetail pickListDetail in pickListDetailList)
                        {
                            if (pickListDetail.Memo == null || pickListDetail.Memo.Trim() == string.Empty)
                            {
                                pickListDetail.Memo = this.languageMgr.TranslateMessage("MasterData.PickList.MultiLotNo", user);
                            }
                            else
                            {
                                pickListDetail.Memo += "; " + this.languageMgr.TranslateMessage("MasterData.PickList.MultiLotNo", user);
                            }
                            this.pickListDetailMgr.UpdatePickListDetail(pickListDetail);
                        }
                    }
                }
            }
            #endregion

            //if (pickList.PickListDetails == null || pickList.PickListDetails.Count == 0)
            //{
            //    throw new BusinessErrorException("MasterData.PickList.Error.NotEnoughInventory");
            //}

            return(pickList);
        }
Пример #27
0
 public void UpdateShipAddress(ShipAddress address)
 {
     ShipAddressMgr.UpdateShipAddress(address);
 }
 public virtual void UpdateShipAddress(ShipAddress entity)
 {
     entityDao.UpdateShipAddress(entity);
 }
Пример #29
0
 public virtual void UpdateShipAddress(ShipAddress entity)
 {
     Update(entity);
 }
 public virtual void DeleteShipAddress(ShipAddress entity)
 {
     entityDao.DeleteShipAddress(entity);
 }
Пример #31
0
 public virtual void DeleteShipAddress(ShipAddress entity)
 {
     Delete(entity);
 }
Пример #32
0
        private object Deserialize(DssImportHistory dssImportHistory)
        {
            Customer customer = new Customer();
            customer.Code = dssImportHistory[1].ToUpper();
            customer.Name = dssImportHistory[2];

            ShipAddress shipAddress = new ShipAddress();
            shipAddress.Code = "S_" + customer.Code.ToUpper();
            shipAddress.Address = dssImportHistory[3];
            shipAddress.ContactPersonName = dssImportHistory[12];
            shipAddress.TelephoneNumber = dssImportHistory[13] + dssImportHistory[14];
            shipAddress.Fax = dssImportHistory[15];
            shipAddress.MobilePhone = dssImportHistory[17] + dssImportHistory[18];
            shipAddress.PostalCode = dssImportHistory[8];
            shipAddress.Party = customer;

            BillAddress billAddress = new BillAddress();
            billAddress.Code = "B_"+customer.Code.ToUpper() ;
            billAddress.Address = dssImportHistory[3];
            billAddress.ContactPersonName = dssImportHistory[12];
            billAddress.TelephoneNumber = dssImportHistory[13] + dssImportHistory[14];
            billAddress.Fax = dssImportHistory[15];
            billAddress.MobilePhone = dssImportHistory[17] + dssImportHistory[18];
            billAddress.PostalCode = dssImportHistory[8];
            billAddress.Party = customer;

            IList<object> list = new List<object>();
            list.Add(customer);
            list.Add(shipAddress);
            list.Add(billAddress);
            return list;
        }
Пример #33
0
 public virtual void CreateShipAddress(ShipAddress entity)
 {
     entityDao.CreateShipAddress(entity);
 }
        public void A_user_can_submit_the_Dropship_Order_modal_window_when_the_FiOS_subscriber_has_a_correctly_formed_WTN()
        {
            // will run as uitestuser (via code in TestInitialize method)

            // Given a known user
            // and a known FiOS subscriber with a correctly formed WTN
            const string subscriberIdValue = "370100037230"; // Field IT
            const string wtnValue = "4252525179";

            // and the rest of the "Dropship Order" Modal window has been filled out correctly
            const string orderTypeValue = "dropship";        // this is set in the OrderEquipmentDropship_Partial and is "dropship" for dropship orders
            var equipmentCatalogValue = FiOSCatalogId;
            const string qty_14Value = "1";                  // means EquipmentTypeId of 14, and a quantity of 1 (that EquipmentTypeId must exist in the EquipmentTypes table in SIMPL database)
            var commentsValue = string.Format("Integration Test, Dropship Equipment Order, FiOS subscriber, generated on {0} at {1}", DateTime.Now.ToLongDateString(), DateTime.Now.ToLongTimeString());

            var fields = new FormCollection
            {
                new NameValueCollection
                {
                    {
                        "SubscriberId", subscriberIdValue
                    },
                    {
                        "OrderType", orderTypeValue
                    },
                    {
                        "EquipmentCatalog", equipmentCatalogValue
                    },
                    {
                        "qty_14", qty_14Value
                    },
                    {
                        "comments", commentsValue
                    },
                    {
                        "WTN", wtnValue
                    }

                }
            };

            var myOrderModel = new OrderModel();

            // Right now this is hardcoded, this might fail if the text is changed in the database
            var myFirstExpectedLineItem = new LineItem
            {
                Category = "Misc",
                Description = "Zyxel Wireless USB Adapter",
                EquipTypeId = 14,
                Fulfilled = false,
                ItemNumber = 11059789,
                Model = "ZYXEL USB",
                Quantity = 1
            };

            myOrderModel.LineItems.Add(myFirstExpectedLineItem);

            var actualExceptionMessage = string.Empty;

            var subscriber = CurrentSubscriber.GetInstance();
            CurrentSubscriber.SetInstance(subscriberIdValue);

            var expectedShipAddress = new ShipAddress
            {
                Address1 = CleanOrderField(subscriber.Address),
                Address2 = CleanOrderField(subscriber.Address2),
                Name = CleanOrderField(subscriber.Name),
                City = CleanOrderField(subscriber.City),
                Zip = CleanOrderField(subscriber.Zip),
                Email = CleanOrderField(subscriber.Email),
                State = CleanOrderField(subscriber.State),
                UserEntered = false,
                WTN = wtnValue,
                Cbr = null
            };

            const string expectedProduct01SKU = "G-220V3";
            const string expectedProduct01Qty = "1";
            var expectedProduct02SKU = string.Empty;
            var expectedProduct02Qty = string.Empty;

            ActionResult resultSubmitDropship = null;
            try
            {
                //1st Act
                // when submitting the data
                resultSubmitDropship = EquipmentOrderControllerForTests.SubmitDropship(fields);
            }
            catch(Exception ex)
            {
                actualExceptionMessage = ex.Message;
            }

            Assert_that_SubmitDropship_returned_the_expected_values_for_a_regular_dropship_order(actualExceptionMessage, resultSubmitDropship, wtnValue, commentsValue, equipmentCatalogValue, myOrderModel, expectedShipAddress, expectedProduct01SKU, expectedProduct01Qty, expectedProduct02SKU, expectedProduct02Qty);
        }
Пример #35
0
 public virtual void UpdateShipAddress(ShipAddress entity)
 {
     entityDao.UpdateShipAddress(entity);
 }
        public void A_user_can_submit_the_Return_Mailer_Dropship_Order_page_when_the_user_has_entered_a_correctly_formed_WTN()
        {
            // will run as uitestuser (via code in TestInitialize method)

            // The InventoryMenuSendReturnMailerItemEnabled key needs to be set to true for the user to
            // see the ReturnMailer_Partial / ReturnMailerDropship_Partial views (as those views
            // are returned by the ReturnMailerDropship action method only when that key is true)

            // The phone number for a former subscriber from the previous
            // company (e.g. AT&T or Verizon) that needs a return
            // mailer sent to them
            const string wtnValue = "1234567890";
            const string altAddressValue = "true";           // Indicates that an alternate address was provided
            const string address1Value = "Any Street";
            const string address2Value = "Any Apartment";
            const string customerNameValue = "testName";
            const string cityValue = "Any City";
            const string zipCodeValue = "12345";
            const string emailValue = "*****@*****.**";
            const string stateValue = "WA";
            const string cbrValue = "2345623456";

            const string orderTypeValue = "dropship";        // this is set in the ReturnMailerDropship_Partial
            var equipmentCatalogValue = UVerseCatalogId;
            // should be 60 in our development environment
            const string qty_88Value = "1";                  // means EquipmentTypeId of 88, and a quantity of 1 (that EquipmentTypeId must exist in the EquipmentTypes table in SIMPL database)
            var commentsValue = string.Format("Integration Test, Dropship via SendReturnMailer menu item, generated on {0} at {1}", DateTime.Now.ToLongDateString(), DateTime.Now.ToLongTimeString());

            var fields = new FormCollection
            {
                new NameValueCollection
                {
                    {
                        "WTN", wtnValue
                    },
                    {
                        "altAddress", altAddressValue
                    },
                    {
                        "address1", address1Value
                    },
                    {
                        "address2", address2Value
                    },
                    {
                        "customer_name", customerNameValue
                    },
                    {
                        "city", cityValue
                    },
                    {
                        "zipCode", zipCodeValue
                    },
                    {
                        "email", emailValue
                    },
                    {
                        "state", stateValue
                    },
                    {
                        "cbr", cbrValue
                    },
                    {
                        "OrderType", orderTypeValue
                    },
                    {
                        "EquipmentCatalog", equipmentCatalogValue
                    },
                    {
                        "qty_88", qty_88Value
                    },
                    {
                        "comments", commentsValue
                    }
                }
            };

            var myOrderModel = new OrderModel();

            // Right now this is hardcoded, this might fail if the text is changed in the database
            var myFirstExpectedLineItem = new LineItem
            {
                Category = "Returnmailer",
                Description = "Return Mailer - UCON Modem/RG",
                EquipTypeId = 88,
                Fulfilled = false,
                ItemNumber = 1001,
                Model = "FTRTVBHRDISC",
                Quantity = 1
            };

            var mySecondExpectedLineItem = new LineItem
            {
                Category = "Misc",
                Description = "Frontier TV Combo Letter",
                EquipTypeId = 91,
                Fulfilled = false,
                ItemNumber = 1004,
                Model = "FTR TV COMBO LETTER",
                Quantity = 1
            };

            myOrderModel.LineItems.Add(myFirstExpectedLineItem);
            myOrderModel.LineItems.Add(mySecondExpectedLineItem);

            const string expectedProduct01SKU = "FTRTVBHRDISC";
            const string expectedProduct01Qty = "1";
            const string expectedProduct02SKU = "FTRTVCOMBOLTR";
            const string expectedProduct02Qty = "1";

            var expectedShipAddress = new ShipAddress
            {
                Address1 = address1Value,
                Address2 = address2Value,
                Name = customerNameValue,
                City = cityValue,
                Zip = zipCodeValue,
                Email = emailValue,
                State = stateValue,
                UserEntered = true,
                WTN = wtnValue,
                Cbr = cbrValue
            };

            var actualExceptionMessage = string.Empty;

            ActionResult resultSubmitDropship = null;
            try
            {
                //1st Act
                // when submitting the data
                resultSubmitDropship = EquipmentOrderControllerForTests.SubmitDropship(fields);
            }
            catch (Exception ex)
            {
                actualExceptionMessage = ex.Message;
            }

            Assert_that_SubmitDropship_returned_the_expected_values_for_a_dropship_order_submitted_via_SendReturnMailers(actualExceptionMessage, resultSubmitDropship, wtnValue, commentsValue, customerNameValue, emailValue, equipmentCatalogValue, myOrderModel, expectedShipAddress, expectedProduct01SKU, expectedProduct01Qty, expectedProduct02SKU, expectedProduct02Qty);
        }
Пример #37
0
 public virtual void DeleteShipAddress(ShipAddress entity)
 {
     entityDao.DeleteShipAddress(entity);
 }
        private void Assert_that_SubmitDropship_returned_the_expected_values_for_a_regular_dropship_order(string actualExceptionMessage, ActionResult resultSubmitDropship, string wtnValue, string commentsValue, string equipmentCatalogValue, OrderModel myOrderModel, ShipAddress expectedShipAddress, string expectedProduct01SKU, string expectedProduct01Qty, string expectedProduct02SKU, string expectedProduct02Qty)
        {
            //1st Assert
            //The result is a partialViewResult
            // then the "Order Successfully Created" modal window is shown

            if (resultSubmitDropship is ContentResult)
            {
                var content = ((ContentResult)resultSubmitDropship).Content;
                Assert.Fail("The return was expected to be a PartialViewResult; instead it was a ContentResult. This normally means there was an exception. Here is the content {0}", content);
            }
            Assert.IsTrue(resultSubmitDropship is PartialViewResult, "The return from the SubmitDropship action method was not a PartialViewResult");

            //2nd Act
            //Start drilling down the result record from SubmitDropship
            //Cast the result to be a PartialViewResult
            var resultSubmitDropshipAsViewResult = resultSubmitDropship as PartialViewResult;

            //2nd Assert
            //Verify the result Model is an OrderModel type
            // and the records in the database match the expected values
            // Note: the OrderModel has data that is retrieved from the database
            Assert.IsTrue(resultSubmitDropshipAsViewResult.Model is OrderModel, "The model from the SubmitDropship action method was not a OrderModel");

            //3rd Act
            //Get the LineItems from the SubmitDropship return .OrderModel.LineItems
            var resultOrderModel = resultSubmitDropshipAsViewResult.Model as OrderModel;
            var resultLineItems = resultOrderModel.LineItems;

            //3rd Assert
            Assert.IsNotNull(resultLineItems, "The LineItems list from the OrderModel is null");

            Assert.AreEqual(myOrderModel.LineItems.Count, resultLineItems.Count, "The LineItems count is not the expected value");

            var index = 0;
            foreach (var individualLineItem in resultLineItems)
            {
                //4th Assert
                Assert.AreEqual(myOrderModel.LineItems[index].Category.Trim().ToUpper(), individualLineItem.Category.Trim().ToUpper(), "The LineItem Category for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].Description.Trim().ToUpper(), individualLineItem.Description.Trim().ToUpper(), "The LineItem Description for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].EquipTypeId, individualLineItem.EquipTypeId, "The LineItem EquipTypeId for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].Fulfilled, individualLineItem.Fulfilled, "The LineItem Fulfilled for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].ItemNumber, individualLineItem.ItemNumber, "The LineItem ItemNumber for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].Model.Trim().ToUpper(), individualLineItem.Model.Trim().ToUpper(), "The LineItem Model for index of {0} is not the expected value", index);
                Assert.AreEqual(myOrderModel.LineItems[index].Quantity, individualLineItem.Quantity, "The LineItem Quantity for index of {0} is not the expected value", index);
                index++;
            }

            //5th Act
            var resultOrder = resultOrderModel.Order;

            //5th Assert
            Assert.IsNotNull(resultOrder, "The Order object is null");
            Assert.AreNotEqual(0, resultOrder.OrderId, "The OrderId value is 0");
            Assert.AreNotEqual(0, resultOrder.MasterOrderId, "The MasterOrderId value is 0");
            Assert.IsNotNull(resultOrder.ShipAddress, "The ShipAddress is null (this is really the Id, not the object)");
            Assert.IsNotNull(resultOrder.ShipAddress1, "The Ship1Address1 is null (this is the object");

            //6th Act
            var resultShipAddress1 = resultOrder.ShipAddress1;

            //6th Assert
            Assert.AreEqual(expectedShipAddress.Address1.Trim().ToUpper(), resultShipAddress1.Address1.Trim().ToUpper(), "Address1 is not the expected value");
            Assert.AreEqual(expectedShipAddress.Address2.Trim().ToUpper(), resultShipAddress1.Address2.Trim().ToUpper(), "Address2 is not the expected value");
            Assert.AreEqual(expectedShipAddress.Cbr, resultShipAddress1.Cbr, "CBR is not the expected value");
            Assert.AreEqual(expectedShipAddress.City.Trim().ToUpper(), resultShipAddress1.City.Trim().ToUpper(), "City is not the expected value");
            Assert.AreEqual(expectedShipAddress.Email.Trim().ToUpper(), resultShipAddress1.Email.Trim().ToUpper(), "Email is not the expected value");
            Assert.AreEqual(expectedShipAddress.State.Trim().ToUpper(), resultShipAddress1.State.Trim().ToUpper(), "State is not the expected value");
            Assert.IsNotNull(resultShipAddress1.UserEntered, "UserEntered is null");
            Assert.AreEqual(expectedShipAddress.UserEntered, resultShipAddress1.UserEntered, "UserEntered is not the expected value");
            Assert.AreEqual(expectedShipAddress.Zip.Trim().ToUpper(), resultShipAddress1.Zip.Trim().ToUpper(), "Zip is not the expected value");

            // We can test the WTN as that is being set at the beginning of the test
            Assert.AreEqual(wtnValue, resultShipAddress1.WTN, "WTN is not the expected value");

            using (var db = DBContextFactory.CreateContext())
            {
                //7th Act
                var comments = db.Comments.FirstOrDefault(x => x.CommentText == commentsValue);

                //7th Assert
                Assert.IsNotNull(comments, "Comments is null");
                Assert.AreNotEqual(0, comments.CommentId, "CommentId is not valid value");
                Assert.AreEqual(resultOrder.MasterOrderId, comments.CommentOrderId, "CommentOrdeId is not the expected value");

                //8th Act
                var itxOrders = db.ItxOrders.FirstOrDefault(x => x.OrderId == resultOrder.OrderId);

                //8th Assert
                Assert.IsNotNull(itxOrders, "ItxOrders is null");
                Assert.AreNotEqual(0, itxOrders.ItxOrderId, "ItxOrderId is not valid value");
                // OrderId was already checked with the FirstOrDefault
                Assert.IsNull(itxOrders.SentToItx, "SentToItx is not null");
                Assert.IsNull(itxOrders.SentDateTime, "SentDateTime is not null");
                Assert.IsNotNull(itxOrders.GenerationDateTime, "GenerationDateTime is null");
                Assert.AreEqual(1, itxOrders.ProductCatalogTypeId, "ProductCatalogTypeId is not the expected value");
                Assert.AreEqual(Convert.ToInt32(equipmentCatalogValue), itxOrders.ProductCatalogID, "ProductCatalogID is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.OrderNumber, "OrderNumber is not the expected value");
                Assert.AreEqual(1, itxOrders.OrderStatusID, "OrderStatusID is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.ReturnInfo, "ReturnInfo is not the expected value");
                Assert.AreEqual(wtnValue, itxOrders.CustomerPhoneNumber, "CustomerPhoneNumber is not the expected value");

                // Note: Not testing the actual FirstName, LastName, and email address values as this is a live subscriber and the data in Triad could change
                // Therefore, just testing the values to make sure that everything is not null or whitespace (except for lastname as that can be string.empty)
                Assert.IsFalse(string.IsNullOrWhiteSpace(itxOrders.CustomerFirstName.Trim()), "CustomerFirstName is null or whitespace");
                Assert.IsNotNull(itxOrders.CustomerLastName, "CustomerLastName is null");
                Assert.IsFalse(string.IsNullOrWhiteSpace(itxOrders.CustomerEmail.Trim()), "CustomerEmail is null or whitespace");

                // Therefore, just testing the address values to make sure that everything is not null or whitespace (except for shipname2 as that can be string.empty)
                Assert.IsFalse(string.IsNullOrWhiteSpace(itxOrders.ShipName1.Trim()), "ShipName1 is null or whitespace");
                Assert.IsNotNull(itxOrders.ShipName2, "ShipName2 is null");
                Assert.AreEqual(expectedShipAddress.Address1, itxOrders.ShipAddress1, "ShipAddress1 is not the expected value");
                Assert.AreEqual(expectedShipAddress.Address2, itxOrders.ShipAddress2, "ShipAddress2 is not the expected value");
                Assert.AreEqual(expectedShipAddress.City, itxOrders.ShipCity, "ShipCity is not the expected value");
                Assert.AreEqual(expectedShipAddress.State, itxOrders.ShipState, "ShipState is not the expected value");
                Assert.AreEqual(expectedShipAddress.Zip, itxOrders.ShipZip, "ShipZip is not the expected value");

                // Ship instructions for orders placed in test will have specific text in it
                Assert.AreEqual("TEST: DO NOT SHIP", itxOrders.ShipInstructions.Trim().ToUpper(), "ShipInstructions is not the expected value");

                // Billing information should all be empty
                Assert.AreEqual(string.Empty, itxOrders.BillName, "BillName is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillAddress1, "BillAddress1 is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillAddress2, "BillAddress2 is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillCity, "BillCity is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillState, "BillState is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.BillZip, "BillZip is not the expected value");

                // Only the first Product SKU column will be guaranteed to be filled in with a quantity of 1
                // one some orders, the second item may be filled
                // all of the other fields will be empty strings
                Assert.AreEqual(expectedProduct01SKU, itxOrders.Product01SKU.Trim(), "Product01SKU is not the expected value");
                Assert.AreEqual(expectedProduct01Qty, itxOrders.Product01Qty, "Product01Qty is not the expected value");
                Assert.AreEqual(expectedProduct02SKU, itxOrders.Product02SKU, "Product02SKU is not the expected value");
                Assert.AreEqual(expectedProduct02Qty, itxOrders.Product02Qty, "Product02Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product03SKU, "Product03SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product03Qty, "Product03Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product04SKU, "Product04SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product04Qty, "Product04Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product05SKU, "Product05SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product05Qty, "Product05Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product06SKU, "Product06SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product06Qty, "Product06Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product07SKU, "Product07SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product07Qty, "Product07Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product08SKU, "Product08SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product08Qty, "Product08Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product09SKU, "Product09SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product09Qty, "Product09Qty is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product10SKU, "Product10SKU is not the expected value");
                Assert.AreEqual(string.Empty, itxOrders.Product10Qty, "Product10Qty is not the expected value");
            }
        }
Пример #39
0
 public void CreateShipAddress(ShipAddress address)
 {
     ShipAddressMgr.CreateShipAddress(address);
 }
Пример #40
0
        public void CreateReceipt(Receipt receipt, User user, bool isOddCreateHu)
        {
            log.Debug("Start create receipt");
            #region 查找所有的发货项,收货单打印模板,收货差异处理选项
            string      orderType       = null;
            Party       partyFrom       = null;
            Party       partyTo         = null;
            ShipAddress shipFrom        = null;
            ShipAddress shipTo          = null;
            string      dockDescription = null;
            string      receiptTemplate = null;
            string      huTemplate      = null;
            string      grGapTo         = null;
            IList <InProcessLocationDetail> inProcessLocationDetailList = new List <InProcessLocationDetail>();
            if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0)
            {
                foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations)
                {
                    InProcessLocation currentIp = inProcessLocationMgr.LoadInProcessLocation(inProcessLocation.IpNo);
                    if (currentIp.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE)
                    {
                        throw new BusinessErrorException("InProcessLocation.Error.StatusErrorWhenReceive", currentIp.Status, currentIp.IpNo);
                    }

                    if (orderType == null)
                    {
                        orderType = inProcessLocation.OrderType;
                    }

                    //判断OrderHead的PartyFrom是否一致
                    if (partyFrom == null)
                    {
                        partyFrom = inProcessLocation.PartyFrom;
                    }
                    else if (inProcessLocation.PartyFrom.Code != partyFrom.Code)
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.PartyFromNotEqual");
                    }

                    //判断OrderHead的PartyFrom是否一致
                    if (partyTo == null)
                    {
                        partyTo = inProcessLocation.PartyTo;
                    }
                    else if (inProcessLocation.PartyTo.Code != partyTo.Code)
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.PartyToNotEqual");
                    }

                    //判断OrderHead的ShipFrom是否一致
                    if (shipFrom == null)
                    {
                        shipFrom = inProcessLocation.ShipFrom;
                    }
                    else if (!AddressHelper.IsAddressEqual(inProcessLocation.ShipFrom, shipFrom))
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.ShipFromNotEqual");
                    }

                    //判断OrderHead的ShipTo是否一致
                    if (shipTo == null)
                    {
                        shipTo = inProcessLocation.ShipTo;
                    }
                    else if (!AddressHelper.IsAddressEqual(inProcessLocation.ShipTo, shipTo))
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.ShipToNotEqual");
                    }

                    if (dockDescription == null)
                    {
                        dockDescription = inProcessLocation.DockDescription;
                    }
                    else if (inProcessLocation.DockDescription != dockDescription)
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.DockDescriptionNotEqual");
                    }

                    //判断收货单打印模板是否一致
                    if (receiptTemplate == null)
                    {
                        receiptTemplate = inProcessLocation.ReceiptTemplate;
                    }
                    else
                    {
                        if (inProcessLocation.ReceiptTemplate != null && inProcessLocation.ReceiptTemplate != receiptTemplate)
                        {
                            throw new BusinessErrorException("Order.Error.ReceiveOrder.ReceiptTemplateNotEqual");
                        }
                    }

                    //判断条码打印模板是否一致
                    if (huTemplate == null)
                    {
                        huTemplate = inProcessLocation.HuTemplate;
                    }
                    else
                    {
                        if (inProcessLocation.HuTemplate != null && inProcessLocation.HuTemplate != huTemplate)
                        {
                            throw new BusinessErrorException("Order.Error.ReceiveOrder.HuTemplateNotEqual");
                        }
                    }

                    #region 查找收货差异处理选项
                    if (grGapTo == null)
                    {
                        grGapTo = inProcessLocation.GoodsReceiptGapTo;
                    }
                    else
                    {
                        if (inProcessLocation.GoodsReceiptGapTo != null && inProcessLocation.GoodsReceiptGapTo != grGapTo)
                        {
                            throw new BusinessErrorException("Order.Error.ReceiveOrder.GoodsReceiptGapToNotEqual");
                        }
                    }
                    #endregion

                    IListHelper.AddRange <InProcessLocationDetail>(
                        inProcessLocationDetailList, this.inProcessLocationDetailMgr.GetInProcessLocationDetail(inProcessLocation));
                }
            }
            #endregion

            IList <ReceiptDetail> targetReceiptDetailList = receipt.ReceiptDetails;
            receipt.ReceiptDetails = null;   //清空Asn明细,稍后填充

            #region 创建收货单Head
            receipt.ReceiptNo       = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_RECEIPT);
            receipt.OrderType       = orderType;
            receipt.CreateDate      = DateTime.Now;
            receipt.CreateUser      = user;
            receipt.PartyFrom       = partyFrom;
            receipt.PartyTo         = partyTo;
            receipt.ShipFrom        = shipFrom;
            receipt.ShipTo          = shipTo;
            receipt.DockDescription = dockDescription;
            receipt.ReceiptTemplate = receiptTemplate;
            receipt.IsPrinted       = false;
            receipt.NeedPrint       = false;
            if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0)
            {
                foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations)
                {
                    if (inProcessLocation.NeedPrintReceipt)
                    {
                        receipt.NeedPrint = true;
                        break;
                    }
                }
            }

            this.CreateReceipt(receipt);
            log.Debug("Create receipt " + receipt.ReceiptNo + " head successful");
            #endregion

            #region HU处理/入库操作/创建收货明细
            log.Debug("Start create receipt detail");
            IList <LocationLotDetail> inspectLocationLotDetailList = new List <LocationLotDetail>();
            foreach (ReceiptDetail receiptDetail in targetReceiptDetailList)
            {
                OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction;
                OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
                OrderHead   orderHead   = orderDetail.OrderHead;

                if (orderHead.CreateHuOption == BusinessConstants.CODE_MASTER_CREATE_HU_OPTION_VALUE_GR &&
                    receiptDetail.HuId == null)         //如果订单设置为收货时创建Hu,但是收货时已经扫描过Hu了,按已扫描处理
                {
                    #region 收货时创建Hu
                    log.Debug("Create receipt detail with generate barcode.");
                    #region 生产本次收货+剩余零头生成Hu
                    decimal oddQty = 0;

                    if (!isOddCreateHu && orderDetail.HuLotSize.HasValue &&
                        orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)    //只有生产支持零头
                    {
                        #region 查找剩余零头 + 本次收货数是否能够生成Hu
                        Hu oddHu = this.CreateHuFromOdd(receiptDetail, user);
                        if (oddHu != null)
                        {
                            log.Debug("Generate barcode using odd qty.");
                            //如果零头生成了Hu,本次收货数会扣减
                            #region 创建Hu
                            IList <Hu> oddHuList = new List <Hu>();
                            oddHuList.Add(oddHu);
                            IList <ReceiptDetail> oddReceiptDetailList = this.receiptDetailMgr.CreateReceiptDetail(receipt, orderLocationTransaction, oddHuList);
                            log.Debug("Generate odd barcode successful.");
                            #endregion

                            #region 入库
                            IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(oddReceiptDetailList[0], user, receiptDetail.PutAwayBinCode);
                            log.Debug("odd Inventory in successful.");
                            #endregion

                            #region 是否检验
                            if (orderDetail.NeedInspection && orderHead.NeedInspection && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML)
                            {
                                foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList)
                                {
                                    LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId);
                                    locationLotDetail.CurrentInspectQty = locationLotDetail.Qty;
                                    inspectLocationLotDetailList.Add(locationLotDetail);
                                }
                            }
                            #endregion
                        }
                        #endregion

                        oddQty = receiptDetail.ReceivedQty.HasValue && orderDetail.HuLotSize.HasValue ?
                                 receiptDetail.ReceivedQty.Value % orderDetail.HuLotSize.Value : 0; //收货零头数
                        log.Debug("Receive odd qty is " + oddQty);

                        receiptDetail.ReceivedQty = receiptDetail.ReceivedQty.Value - oddQty; //收货数量凑整
                    }
                    #endregion

                    #region 满包装/零头创建Hu处理
                    if (receiptDetail.ReceivedQty.HasValue ||
                        receiptDetail.RejectedQty.HasValue ||
                        receiptDetail.ScrapQty.HasValue)
                    {
                        //创建Hu
                        IList <Hu> huList = this.huMgr.CreateHu(receiptDetail, user);
                        log.Debug("Create barcode successful.");

                        //创建收货项
                        IList <ReceiptDetail> receiptDetailList = this.receiptDetailMgr.CreateReceiptDetail(receipt, orderLocationTransaction, huList);
                        log.Debug("Create receipt detail successful.");

                        #region 如果还有次品或者废品收货,添加到收货列表
                        if ((receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty > 0) ||
                            (receiptDetail.ScrapQty.HasValue && receiptDetail.ScrapQty > 0))
                        {
                            ReceiptDetail rejAndScrapReceiptDetail = new ReceiptDetail();
                            CloneHelper.CopyProperty(receiptDetail, rejAndScrapReceiptDetail);
                            rejAndScrapReceiptDetail.ReceivedQty    = null;
                            rejAndScrapReceiptDetail.PutAwayBinCode = null;
                            rejAndScrapReceiptDetail.Receipt        = receipt;

                            this.receiptDetailMgr.CreateReceiptDetail(rejAndScrapReceiptDetail);

                            receiptDetailList.Add(rejAndScrapReceiptDetail);
                            receipt.AddReceiptDetail(rejAndScrapReceiptDetail);
                        }
                        #endregion

                        foreach (ReceiptDetail huReceiptDetail in receiptDetailList)
                        {
                            #region 匹配ReceiptDetail和InProcessLocationDetail,Copy相关信息
                            if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                            {
                                IList <InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList);
                                if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count > 0)
                                {
                                    if (matchInProcessLocationDetailList.Count > 1)
                                    {
                                        //只有当ASN中包含条码,按数量收货,并收货后创建条码才有可能发生这种情况。
                                        //变态才这么干。
                                        log.Error("只有当ASN中包含条码,按数量收货,并收货后创建条码才有可能发生这种情况。");
                                        throw new BusinessErrorException("你是变态才这么设置。");
                                    }

                                    //如果找到匹配项,只可能有一个
                                    huReceiptDetail.PlannedBill   = matchInProcessLocationDetailList[0].PlannedBill;
                                    huReceiptDetail.IsConsignment = matchInProcessLocationDetailList[0].IsConsignment;
                                    huReceiptDetail.ShippedQty    = matchInProcessLocationDetailList[0].Qty;

                                    this.receiptDetailMgr.UpdateReceiptDetail(huReceiptDetail);
                                }

                                //收货创建HU,分配PlannedAmount,todo:考虑余数
                                huReceiptDetail.PlannedAmount = receiptDetail.PlannedAmount / receiptDetail.ReceivedQty.Value * huReceiptDetail.ReceivedQty.Value;
                            }
                            #endregion

                            #region 入库
                            IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(huReceiptDetail, user, receiptDetail.PutAwayBinCode);
                            log.Debug("Inventory in successful.");
                            #endregion

                            #region 是否检验
                            if (orderDetail.NeedInspection &&
                                orderHead.NeedInspection &&
                                orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML &&
                                huReceiptDetail.ReceivedQty.HasValue &&
                                huReceiptDetail.ReceivedQty > 0)
                            {
                                foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList)
                                {
                                    if (inventoryTransaction.Location.Code != BusinessConstants.SYSTEM_LOCATION_REJECT)
                                    {
                                        LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId);
                                        locationLotDetail.CurrentInspectQty = inventoryTransaction.Qty;
                                        inspectLocationLotDetailList.Add(locationLotDetail);
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region 生产剩余零头处理
                    if (oddQty > 0)
                    {
                        log.Debug("Start handle odd qty.");
                        ReceiptDetail oddReceiptDetail = new ReceiptDetail();
                        CloneHelper.CopyProperty(receiptDetail, oddReceiptDetail);

                        oddReceiptDetail.ReceivedQty = oddQty;
                        oddReceiptDetail.RejectedQty = 0;
                        oddReceiptDetail.ScrapQty    = 0;

                        #region 零头入库
                        oddReceiptDetail.Receipt = receipt;
                        IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(oddReceiptDetail, user, receiptDetail.PutAwayBinCode);
                        #endregion

                        #region 零头创建收货明细
                        this.receiptDetailMgr.CreateReceiptDetail(oddReceiptDetail);
                        receipt.AddReceiptDetail(oddReceiptDetail);
                        #endregion

                        #region 创建HuOdd
                        LocationLotDetail locationLotDetail = locationLotDetailMgr.LoadLocationLotDetail(inventoryTransactionList[0].LocationLotDetailId);
                        this.huOddMgr.CreateHuOdd(oddReceiptDetail, locationLotDetail, user);
                        #endregion
                        log.Debug("End handle odd qty.");
                    }
                    #endregion

                    #endregion
                }
                else
                {
                    #region 收货时不创建Hu
                    log.Debug("Create receipt detail with no generate barcode.");

                    #region 更新Hu上的OrderNo、ReceiptNo和AntiResloveHu
                    if (receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty)
                    {
                        Hu   hu        = this.huMgr.LoadHu(receiptDetail.HuId);
                        bool isUpdated = false;

                        if (hu.OrderNo == null || hu.ReceiptNo == null)
                        {
                            if (hu.OrderNo == null)
                            {
                                log.Debug("Update hu OrderNo " + orderHead.OrderNo + ".");
                                hu.OrderNo = orderHead.OrderNo;
                            }

                            if (hu.ReceiptNo == null)
                            {
                                log.Debug("Update hu ReceiptNo " + receipt.ReceiptNo + ".");
                                hu.ReceiptNo = receipt.ReceiptNo;
                            }

                            isUpdated = true;
                        }

                        if (hu.AntiResolveHu == null &&
                            orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                        {
                            hu.AntiResolveHu = orderHead.AntiResolveHu;
                            isUpdated        = true;
                        }

                        if (isUpdated)
                        {
                            this.huMgr.UpdateHu(hu);
                        }
                    }
                    #endregion

                    IList <ReceiptDetail> noCreateHuReceiptDetailList = new List <ReceiptDetail>();

                    #region 匹配ReceiptDetail和InProcessLocationDetail,Copy相关信息
                    log.Debug("Start match ReceiptDetail and InProcessLocationDetail.");
                    if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION &&
                        orderHead.SubType != BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ)     //收货调整已经匹配过InProcessLocationDetail,不需要在匹配
                    {
                        IList <InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList);
                        log.Debug("Find matched InProcessLocationDetailList, count = " + matchInProcessLocationDetailList != null ? matchInProcessLocationDetailList.Count : 0);

                        if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count == 1)
                        {
                            //一次收货对应一次发货。
                            log.Debug("one ipdet vs one receiptdet.");
                            receiptDetail.PlannedBill   = matchInProcessLocationDetailList[0].PlannedBill;
                            receiptDetail.IsConsignment = matchInProcessLocationDetailList[0].IsConsignment;
                            if (matchInProcessLocationDetailList[0].InProcessLocation.Type == BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_GAP)
                            {
                                receiptDetail.ShippedQty = 0 - matchInProcessLocationDetailList[0].Qty;
                            }
                            else
                            {
                                receiptDetail.ShippedQty = matchInProcessLocationDetailList[0].Qty;
                            }
                            receiptDetail.ReceivedInProcessLocationDetail = matchInProcessLocationDetailList[0];
                            noCreateHuReceiptDetailList.Add(receiptDetail);
                        }
                        else if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count > 1)
                        {
                            //一次收货对应多次发货。
                            //如:发货按条码,收货按数量。
                            log.Debug("multi ipdet vs one receiptdet.");
                            decimal totalRecQty = receiptDetail.ReceivedQty.Value;
                            InProcessLocationDetail lastInProcessLocationDetail = null;
                            log.Debug("Start Fetch matched InProcessLocationDetailList.");
                            foreach (InProcessLocationDetail inProcessLocationDetail in matchInProcessLocationDetailList)
                            {
                                lastInProcessLocationDetail = inProcessLocationDetail; //记录最后一次发货项,供没有对应发货的收货项使用

                                if (inProcessLocationDetail.ReceivedQty.HasValue && Math.Abs(inProcessLocationDetail.ReceivedQty.Value) >= Math.Abs(inProcessLocationDetail.Qty))
                                {
                                    continue;
                                }

                                if (Math.Abs(totalRecQty) > 0)
                                {
                                    log.Debug("Start cloned ReceiptDetail.");
                                    ReceiptDetail clonedReceiptDetail = new ReceiptDetail();
                                    CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail);
                                    log.Debug("End cloned ReceiptDetail.");

                                    clonedReceiptDetail.PlannedBill   = inProcessLocationDetail.PlannedBill;
                                    clonedReceiptDetail.IsConsignment = inProcessLocationDetail.IsConsignment;

                                    #region
                                    if (matchInProcessLocationDetailList[0].InProcessLocation.Type == BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_GAP)
                                    {
                                        inProcessLocationDetail.Qty = 0 - inProcessLocationDetail.Qty;
                                    }
                                    #endregion

                                    if (Math.Abs(totalRecQty) > Math.Abs(inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero)))
                                    {
                                        clonedReceiptDetail.ReceivedQty = inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero);
                                        clonedReceiptDetail.ShippedQty  = inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero);
                                        totalRecQty -= inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero);
                                    }
                                    else
                                    {
                                        clonedReceiptDetail.ReceivedQty = totalRecQty;
                                        clonedReceiptDetail.ShippedQty  = totalRecQty;
                                        totalRecQty = 0;
                                    }

                                    //因为去掉了数量,记录已经匹配的发货项,避免差异处理的时候匹配多条而产生差异。
                                    clonedReceiptDetail.ReceivedInProcessLocationDetail = inProcessLocationDetail;

                                    noCreateHuReceiptDetailList.Add(clonedReceiptDetail);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            log.Debug("End Fetch matched InProcessLocationDetailList.");

                            //超收,没有找到对应的发货项,只记录收货数,发货数记0
                            if (Math.Abs(totalRecQty) > 0)
                            {
                                ReceiptDetail clonedReceiptDetail = new ReceiptDetail();
                                CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail);

                                clonedReceiptDetail.ShippedQty  = 0;
                                clonedReceiptDetail.ReceivedQty = totalRecQty;
                                clonedReceiptDetail.ReceivedInProcessLocationDetail = lastInProcessLocationDetail;

                                noCreateHuReceiptDetailList.Add(clonedReceiptDetail);
                            }
                        }
                        else
                        {
                            noCreateHuReceiptDetailList.Add(receiptDetail);
                        }
                    }
                    else
                    {
                        noCreateHuReceiptDetailList.Add(receiptDetail);
                    }
                    log.Debug("End match ReceiptDetail and InProcessLocationDetail.");
                    #endregion

                    foreach (ReceiptDetail noCreateHuReceiptDetail in noCreateHuReceiptDetailList)
                    {
                        noCreateHuReceiptDetail.Receipt = receipt;

                        if (noCreateHuReceiptDetail.ReceivedQty != 0)
                        {
                            #region 入库
                            log.Debug("Start Inventory In.");
                            IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(noCreateHuReceiptDetail, user, noCreateHuReceiptDetail.PutAwayBinCode);
                            log.Debug("End Inventory In.");
                            #endregion

                            #region 是否检验
                            if (orderDetail.NeedInspection && orderHead.NeedInspection && inventoryTransactionList != null && inventoryTransactionList.Count > 0 &&
                                orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML)
                            {
                                foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList)
                                {
                                    if (inventoryTransaction.Location.Code != BusinessConstants.SYSTEM_LOCATION_REJECT)
                                    {
                                        LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId);
                                        locationLotDetail.CurrentInspectQty = inventoryTransaction.Qty;
                                        inspectLocationLotDetailList.Add(locationLotDetail);
                                    }
                                }
                            }
                            #endregion
                        }

                        #region 创建收货明细
                        log.Debug("Start Create Receipt Detail.");
                        this.receiptDetailMgr.CreateReceiptDetail(noCreateHuReceiptDetail);
                        receipt.AddReceiptDetail(noCreateHuReceiptDetail);
                        log.Debug("End Create Receipt Detail.");
                        #endregion
                    }

                    #endregion
                }
            }
            #endregion

            #region 检验
            if (inspectLocationLotDetailList.Count > 0)
            {
                //对于没有Hu的,如果收货时已经回冲了负数库存,也就是库存数量和待检验数量不一致可能会有问题
                //增加ipno,receiptno,isseperated字段
                this.inspectOrderMgr.CreateInspectOrder(inspectLocationLotDetailList, user, receipt.InProcessLocations[0].IpNo, receipt.ReceiptNo, false);
            }
            #endregion

            //#region 匹配收货发货项,查找差异
            //IList<InProcessLocationDetail> gapInProcessLocationDetailList = new List<InProcessLocationDetail>();

            //#region 发货项不匹配
            //foreach (InProcessLocationDetail inProcessLocationDetail in inProcessLocationDetailList)
            //{
            //    if (inProcessLocationDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type
            //        != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)   //生产暂时不支持差异
            //    {
            //        decimal receivedQty = 0;  //发货项的累计收货数

            //        //一条发货项可能对应多条收货项
            //        foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails)
            //        {
            //            //匹配收货项和发货项
            //            if (receiptDetail.ReceivedInProcessLocationDetail != null)
            //            {
            //                //对于已经匹配的,直接按发货项匹配
            //                if (receiptDetail.ReceivedInProcessLocationDetail.Id == inProcessLocationDetail.Id)
            //                {
            //                    if (receiptDetail.ReceivedQty.HasValue)
            //                    {
            //                        receivedQty += receiptDetail.ReceivedQty.Value;
            //                    }
            //                }
            //            }
            //            else if (OrderHelper.IsInProcessLocationDetailMatchReceiptDetail(
            //                inProcessLocationDetail, receiptDetail))
            //            {
            //                if (receiptDetail.ReceivedQty.HasValue)
            //                {
            //                    receivedQty += receiptDetail.ReceivedQty.Value;
            //                }
            //            }
            //        }

            //        if (receivedQty != inProcessLocationDetail.Qty)
            //        {
            //            #region 收货数量和发货数量不匹配,记录差异
            //            InProcessLocationDetail gapInProcessLocationDetail = new InProcessLocationDetail();
            //            gapInProcessLocationDetail.Qty = receivedQty - inProcessLocationDetail.Qty;
            //            gapInProcessLocationDetail.OrderLocationTransaction = inProcessLocationDetail.OrderLocationTransaction;
            //            //gapInProcessLocationDetail.HuId = inProcessLocationDetail.HuId;
            //            gapInProcessLocationDetail.LotNo = inProcessLocationDetail.LotNo;
            //            gapInProcessLocationDetail.IsConsignment = inProcessLocationDetail.IsConsignment;
            //            gapInProcessLocationDetail.PlannedBill = inProcessLocationDetail.PlannedBill;

            //            gapInProcessLocationDetailList.Add(gapInProcessLocationDetail);
            //            #endregion
            //        }
            //    }
            //}
            //#endregion

            //#region 收货项不匹配
            //foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails)
            //{
            //    if (receiptDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type
            //        != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)   //生产暂时不支持差异
            //    {
            //        IList<InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList);

            //        if (matchInProcessLocationDetailList == null || matchInProcessLocationDetailList.Count == 0)
            //        {
            //            OrderLocationTransaction outOrderLocationTransaction =
            //                this.orderLocationTransactionMgr.GetOrderLocationTransaction(receiptDetail.OrderLocationTransaction.OrderDetail, BusinessConstants.IO_TYPE_OUT)[0];
            //            #region 没有找到和收货项对应的发货项
            //            InProcessLocationDetail gapInProcessLocationDetail = new InProcessLocationDetail();
            //            gapInProcessLocationDetail.Qty = receiptDetail.ReceivedQty.Value;
            //            gapInProcessLocationDetail.OrderLocationTransaction = outOrderLocationTransaction;
            //            //gapInProcessLocationDetail.HuId = receiptDetail.HuId;
            //            gapInProcessLocationDetail.LotNo = receiptDetail.LotNo;
            //            gapInProcessLocationDetail.IsConsignment = receiptDetail.IsConsignment;
            //            gapInProcessLocationDetail.PlannedBill = receiptDetail.PlannedBill;

            //            gapInProcessLocationDetailList.Add(gapInProcessLocationDetail);
            //            #endregion
            //        }
            //    }
            //}
            //#endregion
            //#endregion

            #region 关闭InProcessLocation
            if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0)
            {
                foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations)
                {
                    if (inProcessLocation.IsAsnUniqueReceipt)
                    {
                        //不支持多次收货直接关闭
                        this.inProcessLocationMgr.CloseInProcessLocation(inProcessLocation, user);
                    }
                    else
                    {
                        this.inProcessLocationMgr.TryCloseInProcessLocation(inProcessLocation, user);
                    }

                    //transportationOrderMgr.TryCompleteTransportationOrder(inProcessLocation, user);
                }
            }
            #endregion
        }
 public virtual void CreateShipAddress(ShipAddress entity)
 {
     Create(entity);
 }