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();
        }
Exemple #2
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);
        }
Exemple #3
0
        private void updateTheAcceptedFreightOffer(FreightOfferTrx freightOfferAcceptedTrx)
        {
            //freightOfferAcceptedTrx.IsOfferAccepted = true;

            FreightOfferTrxBiz.Update(freightOfferAcceptedTrx);
        }
Exemple #4
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);
                    }
                }
            }
        }