Exemplo n.º 1
0
        decimal maxPossibleLiabilityToDeliverParcel(BuySellDoc bsd, FreightOfferTrx frtTrx)
        {
            bsd.IsNullThrowException();
            decimal ttlLiability = frtTrx.OfferAmount + bsd.InsuranceRequired;

            return(ttlLiability);
        }
Exemplo n.º 2
0
        private FreightOfferTrx getFreightOffer(string frtOfferId)
        {
            frtOfferId.IsNullOrWhiteSpaceThrowArgumentException();
            FreightOfferTrx freightOfferAcceptedTrx = FreightOfferTrxBiz.Find(frtOfferId);

            return(freightOfferAcceptedTrx);
        }
Exemplo n.º 3
0
        private BuySellDoc getBuySellDoc(FreightOfferTrx freightOfferAcceptedTrx)
        {
            freightOfferAcceptedTrx.BuySellDocId.IsNullOrWhiteSpaceThrowException();
            BuySellDoc buyselldoc = Find(freightOfferAcceptedTrx.BuySellDocId);

            return(buyselldoc);
        }
Exemplo n.º 4
0
        private void reset_DeliverymansCommissionAndFields(BuySellDoc bsd)
        {
            if (!bsd.FreightOfferTrxAcceptedId.IsNullOrWhiteSpace())
            {
                FreightOfferTrx freightOfferTrx = FreightOfferTrxBiz.Find(bsd.FreightOfferTrxAcceptedId);
                freightOfferTrx.IsNullThrowException();
                //freightOfferTrx.OfferAcceptedByDeliveryman = new BoolDateAndByComplex();
                freightOfferTrx.OfferAcceptedByOwner = new BoolDateAndByComplex();
                FreightOfferTrxBiz.Update(freightOfferTrx);

                bsd.FreightOfferTrxAcceptedId = null;
                bsd.FreightOfferTrxAccepted   = null;
            }

            bsd.DeliverymanSalesman           = null;
            bsd.DeliverymanSalesmanId         = null;
            bsd.DeliverymanSalesmanCommission = new PaymentsComplex();

            bsd.SuperDeliverymanSalesmanId         = null;
            bsd.SuperDeliverymanSalesman           = null;
            bsd.SuperDeliverymanSalesmanCommission = new PaymentsComplex();

            bsd.SuperSuperDeliverymanSalesmanId         = null;
            bsd.SuperSuperDeliverymanSalesman           = null;
            bsd.SuperSuperDeliverymanSalesmanCommission = new PaymentsComplex();

            //bsd.Total_Charged_To_Deliveryman = new PaymentsComplex();
            bsd.Total_Delivery_Payment_For_Invoice = new PaymentsComplex();

            bsd.CourierAcceptedByBuyerAndSeller = new BoolDateAndByComplex();
            bsd.CourierComingToPickUp           = new BoolDateAndByComplex();
        }
Exemplo n.º 5
0
        public void Load_Current_User_As_Delyman_Id_Into_BuySellDoc_And_UpdateVarsWithEarlierOffer(BuySellDoc buySellDoc)
        {
            //check to see if the user has bid on this before. If yes, then find it and add the values.
            Deliveryman deliveryman = loadCurrentUsersDeliverymanIdIntoBuySellDoc(buySellDoc);

            FreightOfferTrx earlierOfferByUser = FreightOfferTrxBiz.FindAll().FirstOrDefault(x => x.BuySellDocId == buySellDoc.Id && x.DeliverymanId == deliveryman.Id);

            if (earlierOfferByUser.IsNull())
            {
            }
            else
            {
                //an earlier bid has been found
                buySellDoc.UpdateFreightBidVars(earlierOfferByUser);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// This throws an exception if the deliveryman and the vendor are the same.
        /// </summary>
        /// <param name="freightOfferAcceptedTrx"></param>
        /// <param name="buyselldoc"></param>
        private void exceptionSellerAndDeliveryManIsTheSame(FreightOfferTrx freightOfferAcceptedTrx, BuySellDoc buyselldoc)
        {
            //do not allow if the DeliveryPerson and the VendorPerson and currentUser are the same
            UserId.IsNullOrWhiteSpaceThrowException();

            Person deliveryPerson = DeliverymanBiz.GetPersonForPlayer(freightOfferAcceptedTrx.DeliverymanId);
            Person sellerPerson   = OwnerBiz.GetPersonForPlayer(buyselldoc.OwnerId);
            Person userPerson     = UserBiz.GetPersonFor(UserId);

            deliveryPerson.IsNullThrowException();
            sellerPerson.IsNullThrowException();
            deliveryPerson.Id.IsNullOrWhiteSpaceThrowException();
            sellerPerson.Id.IsNullOrWhiteSpaceThrowException();
            userPerson.IsNullThrowException();

            if (deliveryPerson.Id == sellerPerson.Id && userPerson.Id == sellerPerson.Id && buyselldoc.BuySellDocStateEnum == BuySellDocStateENUM.ReadyForPickup)
            {
                throw new Exception("You are the seller. You cannot bid for this. If you want to deliver the item, ask the customer to accept you.");
            }
        }
Exemplo n.º 7
0
        public void AcceptCourier(FreightOfferTrx frtTrx, BuySellDocumentTypeENUM buySellDocumentTypeEnum, decimal currBalance, decimal insuranceRequired)
        {
            if (insuranceRequired < 0)
            {
                throw new Exception("Insurance cannot be less than zero!");
            }

            BuySellDoc bsd = getBuySellDoc(frtTrx);

            bsd.IsNullThrowException();
            exceptionSellerAndDeliveryManIsTheSame(frtTrx, bsd);

            bsd.BuySellDocumentTypeEnum = buySellDocumentTypeEnum;

            //this should all happen when courier accepts.
            //bsd.DeliveryCode_Customer = GetRandomCode();
            //bsd.PickupCode_Deliveryman = GetRandomCode();
            //bsd.FreightOfferTrxAcceptedId = frtTrx.Id;

            bsd.BuySellDocStateModifierEnum = BuySellDocStateModifierENUM.Accept;
            bsd.InsuranceRequired           = insuranceRequired;
            decimal maxDeliverymanLiability = maxPossibleLiabilityToDeliverParcel(bsd, frtTrx);

            if (frtTrx.MaxPossibleLiabilityToDeliverParcel() > currBalance)
            {
                frtTrx.IsNullThrowException();
                decimal insuranceAmountRqrdToPass = currBalance - frtTrx.OfferAmount;
                string  err = string.Format("The deliveryman '{0}' is unable to satisfy financial guarantee requirements by Rs{1:N0}. If you would still like to use him, you have an insurance amount of {2:N0} which can be reduced to {4:N0} which will allow you to proceed and accept the deliveryman. This is risky. If something goes wrong during delivery, then the maximum amount you will be able to recover from the deliveryman will be {3:N0}. Alternatively, you can request '{0}' to increase his guarantee amount with the Company. Proceed cautiously.",
                                            frtTrx.Deliveryman.FullName(),
                                            maxDeliverymanLiability - currBalance,
                                            bsd.InsuranceRequired,
                                            currBalance,
                                            insuranceAmountRqrdToPass);
                throw new Exception(err);
            }
            frtTrx.OfferAcceptedByOwner.SetToTodaysDate(UserName, UserId);
            FreightOfferTrxBiz.Update(frtTrx);
            Update(bsd);
        }
Exemplo n.º 8
0
        private void updateTheAcceptedFreightOffer(FreightOfferTrx freightOfferAcceptedTrx)
        {
            //freightOfferAcceptedTrx.IsOfferAccepted = true;

            FreightOfferTrxBiz.Update(freightOfferAcceptedTrx);
        }
Exemplo n.º 9
0
 private void acceptDeliveryMan(FreightOfferTrx freightOfferAcceptedTrx, BuySellDoc buyselldoc)
 {
 }
Exemplo n.º 10
0
        private void deliveryman_Makes_Bid_To_Pickup(BuySellDoc buySellDoc)
        {
            if (UserId.IsNullOrWhiteSpace())
            {
                return;
            }


            if (buySellDoc.FreightOfferDecimal > 0)
            {
                //we have an offer
                DateParameter dp = new DateParameter();
                dp.BeginDate = buySellDoc.PleasePickupOnDate_Start;
                dp.EndDate   = buySellDoc.PleasePickupOnDate_End;

                if (dp.IsDateWithinBeginAndEndDatesInclusive(buySellDoc.OfferedPickupOnDate))
                {
                    string buySellDocId = buySellDoc.Id;
                    buySellDoc = Find(buySellDocId);
                    buySellDoc.IsNullThrowException();

                    //the pick up is today or later.
                    //the user is the deliveryman here
                    Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId);
                    deliveryman.IsNullThrowException();


                    //create an offer
                    FreightOfferTrx frtOff = new FreightOfferTrx(
                        buySellDoc.Id,
                        deliveryman.Id,
                        buySellDoc.FreightOfferDecimal,
                        buySellDoc.OfferedPickupOnDate,
                        buySellDoc.ExpectedDeliveryDate,
                        buySellDoc.CommentByDeliveryman,
                        buySellDoc.VehicalTypeOfferedId);

                    //used later
                    frtOff.Deliveryman = deliveryman;
                    frtOff.BuySellDoc  = buySellDoc;


                    //we will only create if there is not one bid from this deliveryman
                    //for this document. If there is already a bid, then all fields will be updated.
                    //the change will only be allowed if the status of the buyselldoc is

                    //check to see if a bid already exists.
                    //this locates an earlier bid and then updates it.

                    FreightOfferTrx frtOffTrxFound = FreightOfferTrxBiz.FindAll().FirstOrDefault(x => x.BuySellDocId == buySellDocId && x.DeliverymanId == deliveryman.Id);
                    if (frtOffTrxFound.IsNull())
                    {
                        //create a new bid.
                        buySellDoc.FreightOfferTrxs.Add(frtOff);
                        FreightOfferTrxBiz.Create(frtOff);
                    }
                    else
                    {
                        //update the old bid.
                        frtOffTrxFound.UpdatePropertiesDuringModify(frtOff as ICommonWithId);
                        FreightOfferTrxBiz.Update(frtOffTrxFound);
                    }
                }
            }
        }