/// <summary> /// Constructor to create "new" PaymentAdvices. /// New paymentAdvices will be created "unlocked". /// </summary> /// <param name="parentPAList">Parent PaymentAdviceList: must assign to create PaymentAdvice</param> /// <param name="StudId">Student Id: must assign a valid student id to create PaymentAdvice</param> public PaymentAdvice(PaymentAdviceList parentPAList, int StudId) { if (parentPAList == null) throw new ApasInvaidOperationException( "Invalid Operation: Unable to create a PaymentAdvice without " + "a valid parent PaymentAdviceList."); _IsLocked=false; IdStudent = StudId; IsFrozen=0; IsExcluded=0; IdLockHolder=null; LockKey = null; ClassFees = new Dictionary<int, ClassFee>(); OtherFees = new Dictionary<long, OtherFee>(); LastAction = "Create"; LastModifiedTime = DateTime.Now; LastModifiedBy = ApasAccessControlManager.GetCurrentInstance().LogonUser.Id; parentPAList.AddPaymentAdvice(this); }
public object Get(GetBankPaymentAdviceList request) { // Get the contract for the Bank by specifying the bank address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.BANK.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BankContractAdr); // Create a new return instance for Bank Metadata and set the Bank contract address uint countPaymentAdvice = contract.GetFunction("countPaymentAdviceEntries").CallAsync <uint>().Result; // Create the bond list object and initialise PaymentAdviceList list = new PaymentAdviceList() { Items = new List <PaymentAdviceDetail>() }; // Iterate through all the payment advice entries available according to count for (uint i = 0; i < countPaymentAdvice; i++) { // Call the payment advice from the specified idx PaymentAdviceDetail advice = contract.GetFunction("bankPaymentAdvice").CallDeserializingToObjectAsync <PaymentAdviceDetail>(i).Result; // Verify the payment advice returned has not already been processed (check the payment amount) if (advice.Amount > 0) { // Set the Advice index advice.Idx = i; // Convert the payment subject if applicable if (advice.PaymentSubject.StartsWith("0x000000") == true) { advice.PaymentSubject = Convert.ToUInt64(advice.PaymentSubject.RemoveHexPrefix(), 16).ToString(); } // Add advice to the list list.Items.Add(advice); } } // Return the list of all outstanding payment advice return(list); }
public virtual PaymentAdviceList GetParentPAList() { ISession db = NHibernateManager.GetCurrentSession(); PaymentAdviceList parent = db.Get<PaymentAdviceList>(IdPaymentAdviceList); if (parent == null) { parent = new PaymentAdviceList(IdPaymentAdviceList, false); } return parent; }
private void setCurrentPAList(PaymentAdviceList newPAList) { if (CurrentPAList != null) NHibernateManager.GetCurrentSession().Evict(CurrentPAList); _CurrentPAList = newPAList; }
/// <summary> /// A method to be called at the start of APAS /// </summary> public void PreparePAList(DateTime month) { //forget about the Access Control for now //bool canCreate = ApasAccessControlManager.GetCurrentInstance() // .isAccessGranted("PaymentAdviceList", "Create"); //bool canEdit = ApasAccessControlManager.GetCurrentInstance() // .isAccessGranted("PaymentAdviceList", "Edit"); //only one thread can perform this method at a time lock (criticalSection) { //check if a PAlist exists for the requreded month //Create new PAlist and generate if not exists, //Sync if exists (must hold records first) PaymentAdviceList newPA, prevPA; IList<PaymentAdviceList> pList; if ( SelectPAList(month) ) { //has PAList already created newPA = _CurrentPAList; if (newPA.IsFrozen==0) //resync only if not frozen { ResyncPAList(); } } else { //dun have PAList //create one //Get previous month PAList. must have one. Else error pList = PaymentAdviceList.FindByMonth (month.AddMonths(-1)); if (pList.Count == 0) { throw new ApasInvaidOperationException( "Invalid Operation: Missing payment advise list for " + month.AddMonths(-1).ToString("MMM yyyy") + ". In order to generate " + month.ToString("MMM yyyy") + " payment advice list, you must have generated " + month.AddMonths(-1).ToString("MMM yyyy") + " payment advice list."); } else { newPA = new PaymentAdviceList(month); newPA.LastAction="Create"; newPA.LastModifiedBy = ApasAccessControlManager.GetCurrentInstance().LogonUser.Id; newPA.LastModifiedTime = DateTime.Now; newPA.Save(); newPA.GeneratePaymentAdvices(pList[0]); //release all locks //select generated PAlist as current PAList setCurrentPAList(newPA); } } } }