Пример #1
0
 private void calculate_Owner_Payment(BuySellDoc bsd, PersonPayingPenalty ppp, decimal totalPaymentAmount)
 {
     ppp.From.Person = OwnerBiz.GetPersonForPlayer(bsd.OwnerId);
     ppp.From.Person.IsNullThrowException();
     ppp.From.Amount  = totalPaymentAmount;
     ppp.From.Comment = "Owner";
 }
Пример #2
0
        private void calculate_Owner_Amount_When_Receiving_Penalty(BuySellDoc bsd, Person systemPerson, PersonPayingPenalty ppp, decimal totalPaymentAmount)
        {
            ppp.Owner.Clear();
            //get the maximum commission payable on the freight and sale
            decimal maxPayableAccordingToMaxCommission_Amount = getFreightAndProductCommissionAdded(bsd) * totalPaymentAmount;


            ppp.Owner.Person = OwnerBiz.GetPersonForPlayer(bsd.OwnerId);
            ppp.Owner.Person.IsNullThrowException();
            ppp.Owner.Comment = "Owner";
            ppp.Owner.Amount  = totalPaymentAmount - maxPayableAccordingToMaxCommission_Amount;

            if (ppp.Owner.Amount != 0)
            {
                ppp.Owner.Percent = ppp.Owner.Amount / totalPaymentAmount;
            }
        }
Пример #3
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.");
            }
        }
Пример #4
0
        private void createMessageFor(RejectCancelDeleteInbetweenClass rcdbc, BuySellDoc buySellDoc)
        {
            string        fromPersonId   = "";
            string        toPersonId     = "";
            Person        fromPerson     = null;
            List <string> listOfToPeople = new List <string>();

            string buySellDocId   = buySellDoc.Id;
            Person ownerPerson    = OwnerBiz.GetPersonForPlayer(buySellDoc.OwnerId);
            Person customerPerson = CustomerBiz.GetPersonForPlayer(buySellDoc.CustomerId);

            ownerPerson.IsNullThrowException();
            customerPerson.IsNullThrowException();
            switch (buySellDoc.BuySellDocumentTypeEnum)
            {
            case BuySellDocumentTypeENUM.Sale:
                fromPersonId = ownerPerson.Id;
                fromPerson   = ownerPerson;
                toPersonId   = customerPerson.Id;
                listOfToPeople.Add(toPersonId);
                break;

            case BuySellDocumentTypeENUM.Purchase:
                toPersonId   = ownerPerson.Id;
                fromPersonId = customerPerson.Id;
                fromPerson   = customerPerson;
                listOfToPeople.Add(toPersonId);

                break;

            case BuySellDocumentTypeENUM.Delivery:
                Person deliveryPerson = DeliverymanBiz.GetPersonForPlayer(buySellDoc.DeliverymanId);
                deliveryPerson.IsNullThrowException();

                fromPersonId = deliveryPerson.Id;
                fromPerson   = deliveryPerson;
                listOfToPeople.Add(ownerPerson.Id);
                listOfToPeople.Add(customerPerson.Id);
                break;

            case BuySellDocumentTypeENUM.Unknown:
            default:
                throw new Exception("Unknown document type");
            }

            Message message = new Message(
                fromPersonId,
                fromPerson,
                listOfToPeople,
                rcdbc.Subject,
                rcdbc.Comment,
                MessageENUM.Free,
                null);

            if (buySellDoc.Messages.IsNull())
            {
                buySellDoc.Messages = new List <Message>();
            }

            buySellDoc.Messages.Add(message);
            message.BuySellDocId = buySellDoc.Id;

            message.ListOfToPeopleId.IsNullOrEmptyThrowException();
            foreach (var pplId in message.ListOfToPeopleId)
            {
                Person person = PersonBiz.Find(pplId);
                person.IsNullThrowException();

                PeopleMessage pplMsg = new PeopleMessage();
                pplMsg.IsNullThrowException();
                pplMsg.PersonId  = pplId;
                pplMsg.Person    = person;
                pplMsg.MessageId = message.Id;
                PeopleMessageBiz.Create(pplMsg);
            }
            MessageBiz.Create(message);
        }