private void createPenaltyTrx(BuySellDoc bsd, Person systemPerson, string reason) { PersonPayingPenalty ppp; IPenaltyClass penalty = PenaltyController.GetPenalty(bsd, out ppp); if (penalty.IsNull()) { return; } //we want to delete the maximum commission. //payments will be made to people who exist. //balance will go to the system decimal totalPaymentAmount = penalty.PenaltyAmount(); if (totalPaymentAmount == 0) { return; } switch (bsd.BuySellDocStateModifierEnum) { case BuySellDocStateModifierENUM.Unknown: break; case BuySellDocStateModifierENUM.Reject: break; case BuySellDocStateModifierENUM.Cancel: break; case BuySellDocStateModifierENUM.Accept: break; case BuySellDocStateModifierENUM.SeeAddress: if (bsd.BuySellDocumentTypeEnum == BuySellDocumentTypeENUM.Sale) { bsd.IsShowFullAddressTo_Seller = true; } if (bsd.BuySellDocumentTypeEnum == BuySellDocumentTypeENUM.Purchase) { bsd.IsShowFullAddressTo_Customer = true; } break; case BuySellDocStateModifierENUM.OptOutOfSystem: { if (bsd.BuySellDocumentTypeEnum != BuySellDocumentTypeENUM.Purchase) { return; } if (bsd.BuySellDocStateEnum != BuySellDocStateENUM.RequestUnconfirmed) { return; } bsd.OptedOutOfSystem.SetToTodaysDate(UserName, UserId); } break; default: break; } calculateAndDistributePenaltyPayments_Controller(bsd, systemPerson, ppp, penalty, totalPaymentAmount); createAndSavePenalty(bsd, reason, ppp, totalPaymentAmount, GetGlobalObject()); //if (bsd.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.Cancel || bsd.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.SeeAddress) //{ //PersonPayingPenalty ppp; //IPenaltyClass penalty = PenaltyController.GetPenalty(bsd, out ppp); //if (penalty.IsNull()) // return; ////we want to delete the maximum commission. ////payments will be made to people who exist. ////balance will go to the system //decimal totalPaymentAmount = penalty.PenaltyAmount(); //if (totalPaymentAmount == 0) // return; //get all the persons involved //create a cash transaction //here we should know who is paying //if(bsd.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.SeeAddress) //{ // //update the bsd // ControllerCreateEditParameter parm = new ControllerCreateEditParameter(); // parm.Entity = bsd as ICommonWithId; // if (bsd.BuySellDocumentTypeEnum == BuySellDocumentTypeENUM.Sale) // { // bsd.IsShowFullAddressTo_Seller = true; // parm.GlobalObject = GetGlobalObject(); // //for some reason I am losing the value of bsd.BuySellDocumentTypeEnum... it becomes // //purchase when we do GetGlobalObject. // //so I am fixing it here. // bsd.BuySellDocumentTypeEnum = BuySellDocumentTypeENUM.Sale; // BuySellDocBiz.Update(parm); // } // if (bsd.BuySellDocumentTypeEnum == BuySellDocumentTypeENUM.Purchase) // { // parm.GlobalObject = GetGlobalObject(); // bsd.IsShowFullAddressTo_Customer = true; // //for some reason I am losing the value of bsd.BuySellDocumentTypeEnum... it becomes // //purchase when we do GetGlobalObject. // //so I am fixing it here. // bsd.BuySellDocumentTypeEnum = BuySellDocumentTypeENUM.Purchase; // BuySellDocBiz.Update(parm); // } //} //calculateAndDistributePenaltyPayments_Controller(bsd, systemPerson, ppp, penalty, totalPaymentAmount); //createAndSavePenalty(bsd, reason, ppp, totalPaymentAmount, GetGlobalObject()); //} }
/// <summary> /// This is the controller that directs how the payments are made. /// </summary> /// <param name="bsd"></param> /// <param name="systemPerson"></param> /// <param name="ppp"></param> /// <param name="penalty"></param> /// <param name="totalPaymentAmount"></param> private void calculateAndDistributePenaltyPayments_Controller(BuySellDoc bsd, Person systemPerson, PersonPayingPenalty ppp, IPenaltyClass penalty, decimal totalPaymentAmount) { if (totalPaymentAmount == 0) { return; } switch (penalty.WhoPaysWhoEnum) { case WhoPaysWhoENUM.OwnerPaysCustomer: ownerPaysCustomer_Penalty(bsd, systemPerson, ppp, totalPaymentAmount); break; case WhoPaysWhoENUM.OwnerPaysDeliveryMan: ownerPaysDeliveryMan_Penalty(bsd, systemPerson, ppp, totalPaymentAmount); break; case WhoPaysWhoENUM.OwnerPaysSystem: //used for optingOutOfSystem Owner_Pays_System(bsd, systemPerson, ppp, totalPaymentAmount); break; case WhoPaysWhoENUM.CustomerPaysOwner: customerPaysOwner_Penalty(bsd, systemPerson, ppp, totalPaymentAmount); break; case WhoPaysWhoENUM.CustomerPaysDeliveryman: customerPaysDeliveryman_Penalty(bsd, systemPerson, ppp, totalPaymentAmount); break; case WhoPaysWhoENUM.CustomerPaysSystem: customer_Pays_System(bsd, systemPerson, ppp, totalPaymentAmount); break; case WhoPaysWhoENUM.DeliverymanPaysOwner: deliverymanPaysOwner_Penalty(bsd, systemPerson, ppp, totalPaymentAmount); break; case WhoPaysWhoENUM.DeliverymanPaysCustomer: deliverymanPaysCustomer_Penalty(bsd, systemPerson, ppp, totalPaymentAmount); break; case WhoPaysWhoENUM.Unknown: default: throw new Exception("I Dont know who to pay!"); } }