예제 #1
0
        public BuySellDoc GetDeliveryOrder(string buySellId)
        {
            buySellId.IsNullOrWhiteSpaceThrowArgumentException();
            BuySellDoc buySellDoc = BuySellDocBiz.FindAll().FirstOrDefault(x => x.Id == buySellId);

            return(buySellDoc);
        }
예제 #2
0
        /// <summary>
        /// These are the documents that will show in the cash statements
        /// </summary>
        /// <param name="cashTypeEnum"></param>
        /// <param name="cashStateEnum"></param>
        /// <param name="lstBuySellDocs"></param>
        /// <returns></returns>
        private List <BuySellDoc> get_BuySellDocs_Allocated_Payments(CashTypeENUM cashTypeEnum, CashStateENUM cashStateEnum)
        {
            List <BuySellDoc> lstBuySellDocs = new List <BuySellDoc>();

            if (cashTypeEnum == CashTypeENUM.Unknown)
            {
                throw new Exception("Cash Type Unknown");
            }

            if (cashStateEnum == CashStateENUM.Available)
            {
                return(lstBuySellDocs);
            }

            if (cashTypeEnum == CashTypeENUM.NonRefundable)
            {
                return(lstBuySellDocs);
            }

            lstBuySellDocs = BuySellDocBiz.FindAll().Where(x =>
                                                           x.BuySellDocStateEnum == BuySellDocStateENUM.RequestConfirmed ||
                                                           x.BuySellDocStateEnum == BuySellDocStateENUM.BeingPreparedForShipmentBySeller ||
                                                           x.BuySellDocStateEnum == BuySellDocStateENUM.ReadyForPickup ||
                                                           x.BuySellDocStateEnum == BuySellDocStateENUM.CourierAcceptedByBuyerAndSeller ||
                                                           x.BuySellDocStateEnum == BuySellDocStateENUM.CourierComingToPickUp ||
                                                           x.BuySellDocStateEnum == BuySellDocStateENUM.PickedUp ||
                                                           x.BuySellDocStateEnum == BuySellDocStateENUM.Enroute ||
                                                           x.BuySellDocStateEnum == BuySellDocStateENUM.Problem)
                             .ToList();

            return(lstBuySellDocs);
        }
예제 #3
0
        private List <BuySellDoc> get_BuySellDocs_Allocated_Receipt()
        {
            List <BuySellDoc> lstBuySellDocs = BuySellDocBiz.FindAll().Where(x =>
                                                                             x.BuySellDocStateEnum == BuySellDocStateENUM.BeingPreparedForShipmentBySeller ||
                                                                             x.BuySellDocStateEnum == BuySellDocStateENUM.ReadyForPickup ||
                                                                             x.BuySellDocStateEnum == BuySellDocStateENUM.CourierAcceptedByBuyerAndSeller ||
                                                                             x.BuySellDocStateEnum == BuySellDocStateENUM.CourierComingToPickUp ||
                                                                             x.BuySellDocStateEnum == BuySellDocStateENUM.PickedUp ||
                                                                             x.BuySellDocStateEnum == BuySellDocStateENUM.Enroute ||
                                                                             x.BuySellDocStateEnum == BuySellDocStateENUM.Problem).ToList();

            return(lstBuySellDocs);
        }
예제 #4
0
        private List <BuySellDoc> get_BuySellDoc_Completed_Payments(CashTypeENUM cashTypeEnum, CashStateENUM cashStateEnum)
        {
            if (cashTypeEnum == CashTypeENUM.Unknown)
            {
                throw new Exception("Cash Type Unknown");
            }

            if (cashTypeEnum == CashTypeENUM.NonRefundable)
            {
                //the buyselldoc are all refundable
                return(null);
            }


            List <BuySellDoc> lstBuySellDocs = BuySellDocBiz.FindAll().Where(x =>
                                                                             x.BuySellDocStateEnum == BuySellDocStateENUM.Delivered).ToList();

            return(lstBuySellDocs);
        }
예제 #5
0
        public void MakeSuperSalesmen()
        {
            List <Salesman> normalSalesmen = SalesmanBiz.FindAll().Where(x => x.IsSuperSalesman == false).ToList();

            if (normalSalesmen.IsNullOrEmpty())
            {
                return;
            }

            int     noOfBsdRequiredToBeSuperSalesman = SuperBiz.GetNumberOfBsdToBecomeSuperSalesman();
            decimal superSalesmanCommission          = Salesman.CommissionPct_Owner_Super_Salesman;
            decimal superSuperSalesmanCommission     = Salesman.CommissionPct_Owner_Super_Super_Salesman;
            string  subject = "Congratulations! You are now a Super Salesman!";

            string body = string.Format("CONGRATULATIONS!!! You have satisfied the requirement of {0} delivered orders. You are truely a SUPER SALESMAN. Now, you can hire other salespeople and make your own sales force that will work for you. You will get a commission of {1} for every sale of theirs. Later, when they become SUPER SALESMEN themselves, you will get {2}% from each of their team sales. Remember, when building a team, if you train them properly, they will be more successful, which will end up making YOU more successful. So, take the time to train them. Help them help you. Now, you have effectively multiplied yourself. The question is now... how big a team can you build? Its all upto you.",
                                        noOfBsdRequiredToBeSuperSalesman,
                                        superSalesmanCommission,
                                        superSuperSalesmanCommission);

            foreach (Salesman sm in normalSalesmen)
            {
                int ttlNoBsdForSalesman = BuySellDocBiz.FindAll().Where(x => (x.CustomerSalesmanId == sm.Id ||
                                                                              x.OwnerSalesmanId == sm.Id ||
                                                                              x.DeliverymanSalesmanId == sm.Id) &&
                                                                        x.BuySellDocStateEnum == EnumLibrary.EnumNS.BuySellDocStateENUM.Delivered)
                                          .Count();

                if (ttlNoBsdForSalesman >= noOfBsdRequiredToBeSuperSalesman)
                {
                    sm.IsSuperSalesman = true;
                    SalesmanBiz.Update(sm);

                    createMessageFor(
                        CurrentUserParameter.SystemPersonId,
                        sm.PersonId,
                        subject,
                        body);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Use this to create buy sell orders programatically
        /// </summary>
        /// <param name="productChild"></param>
        /// <param name="ownerProductChild"></param>
        /// <param name="quantity"></param>
        /// <param name="customerUser"></param>
        /// <param name="selectListOwner"></param>
        /// <param name="selectListCustomer"></param>
        /// <param name="addressBillToId"></param>
        /// <param name="addressShipToId"></param>
        /// <param name="selectListBillTo"></param>
        /// <param name="selectListShipTo"></param>
        /// <param name="buySellDocStateEnum"></param>
        /// <returns></returns>


        public BuySellDoc CreateSale(
            ProductChild productChild,
            Owner ownerProductChild,
            int quantity,
            decimal salePrice,
            Customer customerUser,
            System.Web.Mvc.SelectList selectListOwner,
            System.Web.Mvc.SelectList selectListCustomer,
            string addressBillToId,
            string addressShipToId,
            System.Web.Mvc.SelectList selectListBillTo,
            System.Web.Mvc.SelectList selectListShipTo,
            BuySellDocStateENUM buySellDocStateEnum,
            BuySellDocStateModifierENUM buySellDocStateModifierEnum,
            DateTime pleasePickupOnDate_End,
            DateTime expectedDeliveryDate,
            string shopId)
        {
            BuySellDoc sale = BuySellDocBiz.Factory() as BuySellDoc;

            sale.ShopId = shopId;

            sale.Initialize(
                ownerProductChild.Id,
                customerUser.Id,
                addressBillToId,
                addressShipToId,
                selectListOwner,
                selectListCustomer,
                selectListBillTo,
                selectListShipTo);

            if (pleasePickupOnDate_End == DateTime.MaxValue || pleasePickupOnDate_End == DateTime.MinValue)
            {
            }
            else
            {
                sale.PleasePickupOnDate_End = pleasePickupOnDate_End;
            }

            if (expectedDeliveryDate == DateTime.MaxValue || expectedDeliveryDate == DateTime.MinValue)
            {
            }
            else
            {
                sale.ExpectedDeliveryDate = expectedDeliveryDate;
            }


            //dont really need this, but it is good for consistancy.
            sale.BuySellDocumentTypeEnum     = BuySellDocumentTypeENUM.Purchase;
            sale.BuySellDocStateModifierEnum = buySellDocStateModifierEnum;
            sale.BuySellDocStateEnum         = buySellDocStateEnum;
            sale.ExpectedDeliveryDate        = expectedDeliveryDate;
            BuySellItem buySellItem = new BuySellItem(sale.Id, productChild.Id, quantity, salePrice, productChild.FullName());

            sale.Add(buySellItem);



            BuySellDocBiz.GetDefaultVehicalType(sale);
            //add the owners address
            sale.AddressShipFromId = productChild.ShipFromAddressId;

            setStatusDate(sale);
            ControllerCreateEditParameter parm = new ControllerCreateEditParameter();

            parm.Entity       = sale as ICommonWithId;
            parm.GlobalObject = GetGlobalObject();
            getCustomerSalesmanAndOwnerSalesman(sale);


            //add the payment amount.



            BuySellDocBiz.Create(parm);

            return(sale);
        }
예제 #7
0
        public string AddToSale(string userId, string productChildId, string poNumber, DateTime poDate)
        {
            userId.IsNullOrWhiteSpaceThrowException("No user");

            double totalThisItem = 0;

            //who is the owner:The product Child owner is the owner
            //get the productChild

            productChildId.IsNullOrWhiteSpaceThrowException("No Product");
            ProductChild productChild = ProductChildBiz.Find(productChildId);

            productChild.IsNullThrowException("productChild");



            //get the product child's owner
            Owner ownerProductChild = productChild.Owner;

            ownerProductChild.IsNullThrowException("productChildOwner");

            //get the owner
            //Get the select list for owner
            Person ownerPerson = ownerProductChild.Person;

            ownerPerson.IsNullThrowException("ownerPerson");
            System.Web.Mvc.SelectList ownerSelectList = OwnerBiz.SelectListOnlyWith(ownerProductChild);


            ////the user is the customer user;
            //get the customer
            Customer customerUser = CustomerBiz.GetPlayerFor(userId);

            //Get the select list for Customer
            //remove the owner from the list... owner cannot sell to self.
            System.Web.Mvc.SelectList customerSelectList = CustomerBiz.SelectListWithout(ownerPerson);
            System.Web.Mvc.SelectList selectListOwner    = OwnerBiz.SelectListOnlyWith(ownerProductChild);
            System.Web.Mvc.SelectList selectListCustomer = CustomerBiz.SelectListWithout(ownerPerson);

            //this is the address in the customer
            AddressMain    addressBillTo          = customerUser.DefaultBillAddress;
            AddressMain    addressShipTo          = customerUser.DefaultShipAddress;
            AddressComplex addressShipFromComplex = productChild.ShipFromAddressComplex;

            string addressBillToId = "";
            string addressShipToId = "";

            if (!addressBillTo.IsNull())
            {
                addressBillToId = addressBillTo.Id;
            }

            if (!addressShipTo.IsNull())
            {
                addressShipToId = addressShipTo.Id;
            }


            //Get the select list for AddressInform
            System.Web.Mvc.SelectList selectListBillTo = AddressBiz.SelectListBillAddressCurrentUser();
            //Get the select list for AddressShipTo
            System.Web.Mvc.SelectList selectListShipTo = AddressBiz.SelectListShipAddressCurrentuser();



            //check to see if there is any open sale which belongs to the same buyer and seller
            BuySellDoc sale = BuySellDocBiz.GetOpenSaleWithSameCustomerAndSeller(customerUser.Id, ownerProductChild.Id, productChild);

            //create the itemList.
            List <BuySellItem> buySellItems = new List <BuySellItem>();
            string             shopId       = "";

            if (sale.IsNull())
            {
                //otherwise add a new sale
                sale = CreateSale(
                    productChild,
                    ownerProductChild,
                    1,
                    productChild.Sell.SellPrice,
                    customerUser,
                    selectListOwner,
                    selectListCustomer,
                    addressBillToId,
                    addressShipToId,
                    selectListBillTo,
                    selectListShipTo,
                    BuySellDocStateENUM.RequestUnconfirmed,
                    BuySellDocStateModifierENUM.Unknown,
                    DateTime.Now,
                    DateTime.Now,
                    shopId);

                totalThisItem++;
            }

            else
            {
                //dont really need this, but it is good for consistancy.
                sale.BuySellDocumentTypeEnum = BuySellDocumentTypeENUM.Purchase;
                sale.BuySellDocStateEnum     = BuySellDocStateENUM.RequestUnconfirmed;

                //now check to see if it is the same item... or is it a new item
                //get list of items for the sale
                List <BuySellItem> itemList = sale.BuySellItems.Where(x => x.MetaData.IsDeleted == false).ToList();

                if (itemList.IsNullOrEmpty())
                {
                    BuySellItem buySellItem = new BuySellItem(sale.Id, productChild.Id, 1, productChild.Sell.SellPrice, productChild.FullName());
                    sale.Add(buySellItem);
                }
                else
                {
                    //there are items in the list
                    BuySellItem itemFound = itemList.FirstOrDefault(x => x.ProductChildId == productChild.Id);
                    if (itemFound.IsNull())
                    {
                        BuySellItem buySellItem = new BuySellItem(sale.Id, productChild.Id, 1, productChild.Sell.SellPrice, productChild.FullName());
                        sale.Add(buySellItem);
                    }
                    else
                    {
                        totalThisItem                     = itemFound.Quantity.Order;
                        itemFound.Quantity.Order         += 1;
                        itemFound.Quantity.Order_Original = itemFound.Quantity.Order;
                        //itemFound.Quantity.Ship += 1;
                    }
                }

                totalThisItem++;
                sale.AddressShipFromComplex = addressShipFromComplex;

                BuySellDocBiz.GetDefaultVehicalType(sale);
                sale.AddressShipFromId = productChild.ShipFromAddressId;

                sale.RequestUnconfirmed.SetToTodaysDate(UserName, UserId);

                ControllerCreateEditParameter parm = new ControllerCreateEditParameter();
                parm.Entity       = sale as ICommonWithId;
                parm.GlobalObject = GetGlobalObject();

                BuySellDocBiz.Update(parm);
            }

            BuySellDocBiz.SaveChanges();
            string message = string.Format("Success. You ordered {0:N2} for {1:N2} (X{2:N2})", productChild.FullName(), productChild.Sell.SellPrice, totalThisItem);

            return(message);
        }