/// <summary> /// These are the documents that will show in the cash statements /// </summary> /// <param name="cashTypeEnum"></param> /// <param name="cashStateEnum"></param> /// <param name="lstBuySellDocs"></param> /// <returns></returns> private List <BuySellDoc> get_BuySellDocs_Allocated_Payments(CashTypeENUM cashTypeEnum, CashStateENUM cashStateEnum) { List <BuySellDoc> lstBuySellDocs = new List <BuySellDoc>(); if (cashTypeEnum == CashTypeENUM.Unknown) { throw new Exception("Cash Type Unknown"); } if (cashStateEnum == CashStateENUM.Available) { return(lstBuySellDocs); } if (cashTypeEnum == CashTypeENUM.NonRefundable) { return(lstBuySellDocs); } lstBuySellDocs = BuySellDocBiz.FindAll().Where(x => x.BuySellDocStateEnum == BuySellDocStateENUM.RequestConfirmed || x.BuySellDocStateEnum == BuySellDocStateENUM.BeingPreparedForShipmentBySeller || x.BuySellDocStateEnum == BuySellDocStateENUM.ReadyForPickup || x.BuySellDocStateEnum == BuySellDocStateENUM.CourierAcceptedByBuyerAndSeller || x.BuySellDocStateEnum == BuySellDocStateENUM.CourierComingToPickUp || x.BuySellDocStateEnum == BuySellDocStateENUM.PickedUp || x.BuySellDocStateEnum == BuySellDocStateENUM.Enroute || x.BuySellDocStateEnum == BuySellDocStateENUM.Problem) .ToList(); return(lstBuySellDocs); }
private List <BuySellDoc> get_BuySellDoc_Completed_Payments(CashTypeENUM cashTypeEnum, CashStateENUM cashStateEnum) { if (cashTypeEnum == CashTypeENUM.Unknown) { throw new Exception("Cash Type Unknown"); } if (cashTypeEnum == CashTypeENUM.NonRefundable) { //the buyselldoc are all refundable return(null); } List <BuySellDoc> lstBuySellDocs = BuySellDocBiz.FindAll().Where(x => x.BuySellDocStateEnum == BuySellDocStateENUM.Delivered).ToList(); return(lstBuySellDocs); }
/// <summary> /// This is the root of the payment trx from where payments will be added. /// We have to decide if non-refundable should only be ransacted by the bank. /// </summary> /// <param name="fromPersonId"></param> /// <param name="personToId"></param> /// <param name="amount"></param> /// <param name="cashTypeEnum"></param> /// <param name="comment"></param> /// <param name="isBank"></param> /// <returns></returns> public bool AddPayment(string fromPersonId, string personToId, decimal amount, CashTypeENUM cashTypeEnum, string comment, bool isBank, decimal availableFund) { UserId.IsNullOrWhiteSpaceThrowException("You must be logged in"); fromPersonId.IsNullOrWhiteSpaceThrowArgumentException("fromId"); personToId.IsNullOrWhiteSpaceThrowArgumentException("toId"); if (cashTypeEnum == CashTypeENUM.Unknown) { throw new Exception("Cash Type is unknown"); } if (amount == 0) { throw new Exception("Amount is zero!"); } if (isBank) { if (availableFund < amount) { string adminComment = "Cash Creation!"; //create cash for that amount createCashTransaction(null, fromPersonId, amount - availableFund, cashTypeEnum, adminComment); } } else { if (availableFund < amount) { throw new Exception(string.Format("Unavailable funds. Currently, you only have {0} which is less than your payment amount of {1}", availableFund, amount)); } } createCashTransaction(fromPersonId, personToId, amount, cashTypeEnum, comment); return(true); }
private void createCashTransaction(string personFromId, string personToId, decimal amount, CashTypeENUM cashTypeEnum, string comment) { CashTrx paymentTrx = Factory() as CashTrx; paymentTrx.CashTypeEnum = cashTypeEnum; paymentTrx.PersonFromId = personFromId; paymentTrx.PersonToId = personToId; paymentTrx.Amount = amount; paymentTrx.Comment = comment; CreateAndSave(paymentTrx); }