private void calculate_Customer_Payment(BuySellDoc bsd, PersonPayingPenalty ppp, decimal totalPaymentAmount) { ppp.From.Person = CustomerBiz.GetPersonForPlayer(bsd.CustomerId); ppp.From.Person.IsNullThrowException(); ppp.From.Amount = totalPaymentAmount; ppp.From.Comment = "Customer"; }
/// <summary> /// this only fires once user has accepted to move on /// </summary> /// <param name="buySellDoc"></param> private void update_Customer_Person_Bill_To_Default_Address_If_empty(BuySellDoc buySellDoc) { buySellDoc.IsNullThrowException(); buySellDoc.CustomerId.IsNullOrWhiteSpaceThrowException(); buySellDoc.AddressBillToId.IsNullOrWhiteSpaceThrowException(); Person customerPerson = CustomerBiz.GetPersonForPlayer(buySellDoc.CustomerId); customerPerson.IsNullThrowException(); if (customerPerson.DefaultBillAddressId.IsNullOrEmpty()) { customerPerson.DefaultBillAddressId = buySellDoc.AddressBillToId; PersonBiz.Update(customerPerson); } //Now update the Customer Default Address if required. //get the customer. Customer customer = buySellDoc.Customer; if (customer.IsNull()) { buySellDoc.CustomerId.IsNullOrWhiteSpaceThrowException(); customer = CustomerBiz.Find(buySellDoc.CustomerId); customer.IsNullThrowException(); if (customer.DefaultBillAddressId.IsNullOrWhiteSpace()) { customer.DefaultBillAddressId = customerPerson.DefaultBillAddressId; CustomerBiz.Update(customer); } } }
private void calculate_Customer_Amount_When_Receiving_Penalty(BuySellDoc bsd, Person systemPerson, PersonPayingPenalty ppp, decimal totalPaymentAmount) { //get the maximum commission payable on the freight and sale decimal maxPayableAccordingToMaxCommission_Amount = getFreightAndProductCommissionAdded(bsd) * totalPaymentAmount; decimal totalPaidOutToCustomerDeliverymanOwner = get_TotalPaidOut_To_Deliveryman_Owner_Customer(ppp); ppp.Customer.Person = CustomerBiz.GetPersonForPlayer(bsd.CustomerId); ppp.Customer.IsNullThrowException(); ppp.Customer.Comment = "Customer"; ppp.Customer.Amount = totalPaymentAmount - maxPayableAccordingToMaxCommission_Amount; if (ppp.Customer.Amount != 0) { ppp.Customer.Percent = ppp.Customer.Amount / totalPaymentAmount; } }
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); }