Exemplo n.º 1
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.º 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);
        }