private void SyncLists() { originalTransactionList = new TransactionList(); foreach (var item in App.Instance.TransDataSource.TransactionList) originalTransactionList.Add(item); }
public TransactionList SyncTransactions(TransactionList transactions) { try { var transList = new TransactionList(); var transIDs = transactions.Select(x => x.TransactionId).ToList(); using (EntityContext context = new EntityContext()) { var query = (from i in context.Transaction where transIDs.Contains(i.TransactionId) select i).ToList(); //investigate if there is a better way to convert the generic list to ObservableCollection foreach (var item in query) { var tempItem = transactions.FirstOrDefault(x => x.TransactionId == item.TransactionId); if (tempItem.ModifiedDate < item.ModifiedDate) transactions.Remove(tempItem); } } return SaveTransactions(transactions); } catch (Exception) { throw; } }
internal Portfolio(FreeQuant.Instruments.Portfolio portfolio) { this.portfolio = portfolio; this.positions = new PositionList(portfolio.Positions); this.transactions = new TransactionList(portfolio.Transactions); this.account = new PortfolioAccount(portfolio.Account); }
public void DateChangeAfter() { // Expecting a minimal change in position. // If moving the item up, it should end up BELOW items with the same date. TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-10")); tl.Add(newTx("2012-02-15")); Transaction tx = newTx("2012-02-05"); tl.Add(tx); AssertAtIndex(tl, 0, tx); // Different date, easy case tx.Date = new DateTime(2012, 02, 5); tx.Date = new DateTime(2012, 02, 12); AssertAtIndex(tl, 1, tx); // Different date, easy case tx.Date = new DateTime(2012, 02, 5); tx.Date = new DateTime(2012, 02, 20); AssertAtIndex(tl, 2, tx); // Same date, should come BEFORE the bottom one, coming from above tx.Date = new DateTime(2012, 02, 5); tx.Date = new DateTime(2012, 02, 15); AssertAtIndex(tl, 1, tx); // Same date, should come BEFORE the bottom-1 one, coming from below tx.Date = new DateTime(2012, 02, 5); tx.Date = new DateTime(2012, 02, 10); AssertAtIndex(tl, 0, tx); }
/// <summary> /// ImportSummary constructor /// </summary> public ImportSummary() { this.transactionsImported = 0; this.transactionsExpected = -1; this.transactionsMerged = 0; _ignored = new TransactionList(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["AdminSession"] == null) { Response.Redirect("/Login"); } if (!IsPostBack) { string customerIdString = (string)Page.RouteData.Values["CustomerId"]; int customerId = 0; try { customerId = Int32.Parse(customerIdString); } catch (FormatException) { } if (customerId != 0) { CustomerDataSource = CustomerManager.GetCustomer(customerId); if (CustomerDataSource.Id == 0) Response.Redirect("/Admin"); TransactionDataSource = TransactionManager.Admin_GetTransactionsByCustomer(CustomerDataSource.Id); BindPage(); } else Response.Redirect("/Admin"); } }
public ImportedTransaction() { SimilarTransactions = new TransactionList(); SuggestedTag = null; SuggestedDescription = ""; SelectedMatch = null; }
public void testTagNameChanges() { // Create a Transaction element and show its version-dependent tag name Transaction trans = new Transaction(); assertTransactionInfo(trans); TransactionList tl = new TransactionList(); tl.Add(trans); assertTransactionInfo(trans); }
public void AddTxEarlier() { TransactionList tl = new TransactionList(); tl.Add(newTx("2012-02-10")); AssertInOrder(tl); tl.Add(newTx("2012-02-01")); AssertInOrder(tl); Assert.AreEqual(2, tl.Count); }
/// <summary> /// Create a trasnaction list with random transactions /// </summary> /// <param name="r"></param> /// <param name="txCount"></param> /// <returns></returns> public static TransactionList NextTransactionList(this Random r, int txCount) { TransactionList tl = new TransactionList(); for (int i = 0; i < txCount; i++) { Transaction tx = new Transaction() { Date = r.NextDate() }; int index = r.Next(tl.Count + 1); tl.Insert(index, tx); } return tl; }
public static TransactionList GetTransactionsByCustomer(int CustomerId) { TransactionList list = new TransactionList(); SqlParamsColl paramList = new SqlParamsColl(); paramList.Add("@CustomerId", SqlDbType.Int, CustomerId); SqlTools.ExecuteReader("dbo.Admin_LoadCustomerTransactions", paramList, reader => { while (reader.Read()) { list.Add(PopulateObjectFromReader(reader)); } }); return list; }
internal static TransactionList getTransactionList(HttpResponseMessage responce) { var transactionList = new TransactionList(); var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("transactions")) { var transactionArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["transactions"].ToString()); foreach (var transactionObj in transactionArray) { var transaction = new Transaction(); transaction = JsonConvert.DeserializeObject<Transaction>(transactionObj.ToString()); transactionList.Add(transaction); } } if (jsonObj.ContainsKey("page_context")) { var pageContext = new PageContext(); pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString()); transactionList.page_context = pageContext; } return transactionList; }
public void FindSimilarTransactions(TransactionList trans) { var results = from t in trans where Similar(t) select t; foreach (var t in results) { // Add the found transaction to the list of similar transactions SimilarTransactions.Add(t); // Select the first transaction as the matching one. // TODO: This can be somehow rated so the transaction that matches the most // gets selected instead of the first one. // if (SelectedMatch == null) // SelectedMatch = SimilarTransactions[0]; // Set the suggested tag and description for this transaction // based on the found transaction... // TODO: Move this functionality to later in the process...we only really // want to do this AFTER the user has confirmed that these two transactions // do actually match. if (t.Tags.Count > 0 && t.Tags[0].Tag != Tag.Unassigned) { if (SuggestedTag == null) SuggestedTag = t.Tags[0].Tag; if (SuggestedDescription.Length == 0) SuggestedDescription = t.Description; // if (Tags.Count == 0) // Tags.Add(new TransactionTag(ID, t.Tags[0].Tag, Amount)); } } if (SimilarTransactions.Count > 0) SelectedMatch = SimilarTransactions[0]; if (SuggestedTag == null) SuggestedTag = Tag.Unassigned; }
public static TransactionList GetAccountTransactions(int AccountNumber) { TransactionList list = new TransactionList(); SqlParamsColl paramList = new SqlParamsColl(); decimal feeAmount = 0; try { feeAmount = Decimal.Parse(ConfigurationManager.AppSettings["Fee_TransactionHistory"]); } catch (FormatException) { } paramList.Add("@AccountNumber", SqlDbType.Int, AccountNumber); paramList.Add("@FeeAmount", SqlDbType.Money, feeAmount); SqlTools.ExecuteReader("Account_RetrieveTransactions", paramList, reader => { while (reader.Read()) { list.Add(PopulateObjectFromReader(reader)); } }); return list; }
public TransactionList SaveTransactions(TransactionList transactions) { try { bool updateFound = false; using (EntityContext context = new EntityContext()) { foreach (var item in transactions) { if (item.TransactionId > 0) //Update { //update database only if the transaction in DB is older var original = context.Transaction .Include(x => x.Category) .Include(x => x.TransactionType) .Include(x => x.TransactionImages) .Include(x => x.TransactionReasonType) .Where(t => t.TransactionId == item.TransactionId && t.ModifiedDate < item.ModifiedDate && !t.IsDeleted).FirstOrDefault(); if (original !=null) { item.HasChanges = false; original.Category = context.Category.Where(k => !k.IsDeleted).Single(p => p.CategoryId == item.Category.CategoryId); //original.Category.CreatedUser = null; //original.Category.ModifiedUser = null; //context.Entry(original).Collection(x => x.TransactionImages).Load(); original.TransactionType = context.TypeTransaction.Where(k => !k.IsDeleted).Single(p => p.TypeTransactionId == item.TransactionType.TypeTransactionId); original.TransactionReasonType = context.TransactionReason.Where(k => !k.IsDeleted).Single(p => p.TypeTransactionReasonId == item.TransactionReasonType.TypeTransactionReasonId); original.CreatedUser = context.User.Where(k => !k.IsDeleted).Single(p => p.UserId == item.CreatedUser.UserId); original.ModifiedUser = context.User.Where(k => !k.IsDeleted).Single(p => p.UserId == item.ModifiedUser.UserId); if (item.TransactionImages != null) { foreach (var x in item.TransactionImages) { if (x.TransactionImageId > 0) original.TransactionImages.Where(k => k.TransactionImageId == x.TransactionImageId).Select(k => { k.Name = x.Name; k.Path = x.Path; k.ModifiedDate = x.ModifiedDate; k.IsDeleted = x.IsDeleted; k.ModifiedUser = context.User.Where(p => !p.IsDeleted).Single(p => p.UserId == x.ModifiedUser.UserId); return k; }).ToList(); else { x.CreatedUser = context.User.Where(p => !p.IsDeleted).Single(p => p.UserId == x.CreatedUser.UserId); x.ModifiedUser = context.User.Where(p => !p.IsDeleted).Single(p => p.UserId == x.ModifiedUser.UserId); original.TransactionImages.Add(x); } } } context.Entry(original).CurrentValues.SetValues(item); updateFound = true; } } else //Insert { item.Category = context.Category.Where(k => !k.IsDeleted).Single(p => p.CategoryId == item.Category.CategoryId); item.TransactionType = context.TypeTransaction.Where(k => !k.IsDeleted).Single(p => p.TypeTransactionId == item.TransactionType.TypeTransactionId); if (item.TransactionReasonType != null) item.TransactionReasonType = context.TransactionReason.Where(k => !k.IsDeleted).Single(p => p.TypeTransactionReasonId == item.TransactionReasonType.TypeTransactionReasonId); item.CreatedUser = context.User.Where(k => !k.IsDeleted).Single(p => p.UserId == item.CreatedUser.UserId); item.ModifiedUser = context.User.Where(k => !k.IsDeleted).Single(p => p.UserId == item.ModifiedUser.UserId); if (item.TransactionImages != null) { foreach (var x in item.TransactionImages) { x.CreatedUser = context.User.Where(p => !p.IsDeleted).Single(p => p.UserId == x.CreatedUser.UserId); x.ModifiedUser = context.User.Where(p => !p.IsDeleted).Single(p => p.UserId == x.ModifiedUser.UserId); //item.TransactionImages.Add(x); } item.HasPhotos = item.TransactionImages.Count > 0; } context.Transaction.Add(item); updateFound = true; } } if (updateFound) context.SaveChanges(); } transactions.PrepareForServiceSerialization(); //return GetLatestTransactions(); return transactions; } catch (DbEntityValidationException e) { StringBuilder s = new StringBuilder(); foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); s.Append(string.Format("{0} - {1}", ve.PropertyName, ve.ErrorMessage)); } } throw new DbEntityValidationException(s.ToString()); } catch (Exception) { throw; } }
private void GetTransactionsForBudgets(BudgetList budgetList) { try { using (EntityContext context = new EntityContext()) { foreach (var item in budgetList) { var inQuery = from t in context.Transaction .Include(t => t.TransactionType).Where(k => !k.IsDeleted) where t.TransactionDate >= item.FromDate && t.TransactionDate <= item.ToDate && !t.IsDeleted && t.ModifiedUser.UserId == item.ModifiedUser.UserId select t; TransactionList tl = new TransactionList(); foreach (var inItem in inQuery.ToList()) tl.Add(inItem); item.Transactions = tl; ////Apply the rule to create a new budget if the expired one is set to Repeat //if (item.Repeat && item.ToDate < DateTime.Now) //{ // var dataSpanRange = item.ToDate - item.FromDate; // var dataSpanToday = DateTime.Now - item.ToDate; // var dateDif = dataSpanRange.Days; // var diff = dataSpanToday.Days % dataSpanRange.Days; // var newFromDate = DateTime.Now.AddDays(-diff + 1); // var newToDate = newFromDate.AddDays(dataSpanRange.Days); // var test = newToDate - newFromDate; // var newBudget = item.Clone(); // newBudget.FromDate = newFromDate; // newBudget.ToDate = newToDate; // item.Repeat = false; // context.Budget.Add(newBudget); // //context.SaveChanges(); //} } //return budgetList; } } catch (Exception) { throw; } }
public TransactionsReceivedEventArgs(TransactionList txList, Peer peer, AElfProtocolMsgType msgType) { Transactions = txList; Peer = peer; MsgType = msgType; }
public TransactionGroup(string name, TransactionList transactions) { Name = name; Transactions = transactions; }
public bool ValidateContextual(ParticipantHandler participantHandler, List <Chain> context) { var blockIsValid = true; //Handle initializing block if (Index == 0) { blockIsValid &= TransactionList.Count() == 2; var registration = (from t in TransactionList where t.GetType() == typeof(PublisherRegistrationTransaction) select(PublisherRegistrationTransaction) t).FirstOrDefault(); var vote = (from t in TransactionList where t.GetType() == typeof(VotingTransaction) select(VotingTransaction) t).FirstOrDefault(); blockIsValid &= registration != null && vote != null; blockIsValid &= ValidateBlockIntegrity(registration.PublicKey); blockIsValid &= participantHandler.ProcessTransaction(registration, context); blockIsValid &= participantHandler.ProcessTransaction(vote, context); } //Handle new Publisher registration else if (TransactionList.Count() == 1 && TransactionList[0].GetType() == typeof(PublisherRegistrationTransaction)) { var registration = (PublisherRegistrationTransaction)TransactionList[0]; blockIsValid &= ValidateBlockIntegrity(registration.PublicKey); blockIsValid &= participantHandler.ProcessTransaction(registration, context); } //Handle regular block else if (participantHandler.HasPublisher(Publisher)) { blockIsValid &= ValidateBlockIntegrity(participantHandler.GetPublisherKey(Publisher)); foreach (var t in TransactionList) { if (t.GetType() == typeof(PhysicianRegistrationTransaction)) { PhysicianRegistrationTransaction temp = (PhysicianRegistrationTransaction)t; blockIsValid &= temp.ValidateTransactionIntegrity(temp.PublicKey); blockIsValid &= participantHandler.ProcessTransaction(temp, context); } else if (participantHandler.HasSender(t.SenderAddress)) { blockIsValid &= t.ValidateTransactionIntegrity(participantHandler.GetSenderKey(t.SenderAddress)); blockIsValid &= participantHandler.ProcessTransaction(t, context); } else { blockIsValid = false; } } } //Fallback - Block definitely invalid else { blockIsValid = false; } return(blockIsValid); }
protected override void LoadSubClass() { if (Transactions == null) { Transactions = new TransactionList(this, "Transactions"); } //assumption we're taking with caching with Sponsor entities in particular: // the corresponding sproc returns the whole household of sponsor + dependent clients records // and also the "household" (sponsor) address/phone record // then this lookup method returns a cached model of the specific type // and the GUI can then pull what it needs off that object via basic properties //the specified GUID passed in is for the Sponsor's *Sponsor*table* RowGUID Fields = EntityLookup(GUID, "Sponsor", "Sponsor_s"); var sponsorTable = DsCache.Tables["Sponsor"]; sponsorTable.Columns["DutyPhoneDSN1"].AllowDBNull = false; //sucks to have to fix these but they're 'generated' from a real field so they lose their NOT NULL metadata sponsorTable.Columns["DutyPhoneDSN2"].AllowDBNull = false; ClientTable.ColumnChanged += ClientTableColumnChanged; ClientTable.RowChanged += ClientTableRowChanged; UTAPFields = RowLookup("Sponsor_UTAP", GUID); //create the logical lookup field for SuspensionTaxOffice via Sponsor.SuspensionTaxOfficeId to Office.TaxOfficeId DsCache.AddRelation("SuspensionTaxOffice", DsCache.Tables["TaxOffice"].Columns["TaxOfficeId"], sponsorTable.Columns["SuspensionTaxOfficeId"]); if (!sponsorTable.Columns.Contains("SuspensionTaxOffice")) sponsorTable.Columns.Add("SuspensionTaxOffice", typeof(string), "Parent(SuspensionTaxOffice).Office"); //map the parent-child relationships hanging off Sponsor ... DataColumn sponsorTableRowGUID = sponsorTable.Columns["RowGUID"]; //SponsorTable tweaks: if (!sponsorTable.Columns.Contains("CanSellForms")) { sponsorTable.Columns.Add("CanSellForms", typeof(bool), "Active AND ISNULL(SuspensionExpiry, #1/1/01#) = #1/1/01#"); sponsorTable.Columns["Active"].ReadOnly = true; //block access to this field from the UI, elsewhere in this class we temporarily open it up to make validated changes (see CheckClientActiveRules method) } //Dependents: DsCache.AddRelation("Sponsor_Client", sponsorTableRowGUID, ClientTable.Columns["SponsorGUID"]); HouseMembers = Fields.CreateChildView("Sponsor_Client"); HouseMembers.Sort = "IsSponsor desc, IsSpouse desc, LName, FName"; //if brand new sponsor, add a default row to fill out for convenience if (HouseMembers.Count == 0) AddMember(); //set ShowDeactive to true, if there's not an Active Sponsor ShowDeactiveMembers = !HouseMembers[0].Field<bool>("Active") || !HouseMembers[0].Field<bool>("IsSponsor"); if (!ClientTable.Columns.Contains("IsSponsorOrSpouse")) { ClientTable.Columns.Add("IsSponsorOrSpouse", typeof(bool), "IsSponsor OR IsSpouse"); ClientTable.Columns["Active"].ReadOnly = true; //block access to this field from the UI, elsewhere in this class we temporarily open it up to make validated changes (see CheckClientActiveRules method) } //TaxForms: DsCache.AddRelation("Sponsor_TaxForm", sponsorTableRowGUID, DsCache.Tables["Sponsor_TaxForm"].Columns["SponsorGUID"]); RefreshTaxFormsList(false); //Remarks: var remarkTable = DsCache.Tables["Sponsor_Remark"]; DsCache.AddRelation("Sponsor_Remark", sponsorTableRowGUID, remarkTable.Columns["SponsorGUID"]); SponsorRemarks = Fields.CreateChildView("Sponsor_Remark"); ShowDeletedRemarks = false; RemarkModel.CommonRemarkTableSettings(SponsorRemarks); SponsorRemarks.Table.RowChanged += SponsorRemarksRowChanged; SponsorRemarks.Table.ColumnChanging += SponsorRemarksColumnChanging; _potentialClientMatchesBgWorker.OnExecute = PotentialMatchesSearchExecute; _potentialClientMatchesBgWorker.OnCompleted = PotentialMatchesSearchCompleted; }
public static string FullName(TransactionList t) { return(FullName(t.First, t.Last, t.MiddleInitial, t.Suffix, t.Name)); }
public BankAccount() { TransacionList = new TransactionList(); }
internal Invoice() { Adjustments = new AdjustmentList(); Transactions = new TransactionList(); }
internal SingleTrip GetBestTrade(Station source, Station destination, TransactionList tradeList) { SingleTrip trade = new SingleTrip(map, source, destination); float iskLeft = parameters.Isk; float cargoSpaceLeft = parameters.CargoSpace; foreach (Transaction t in tradeList) { Transaction addTransaction = t.GetTransactionByLimits(iskLeft, cargoSpaceLeft); if (addTransaction != null) { iskLeft -= addTransaction.Cost; cargoSpaceLeft -= addTransaction.Volume; trade.AddPurchase(addTransaction); } // We'll break out when isk or cargo is low (but not zero), to prevent looking for filler cargo. if ((cargoSpaceLeft == 3.0f) || (iskLeft == 10.0f)) { break; } } trade.Compress(); return trade; }
internal TransactionList GetItemTransactionList(Station source, Station destination, ItemType type) { TransactionList list = new TransactionList(); Trade[] forSale = source.ItemsForSale[type].ToArray(); Trade[] wanted = destination.ItemsWanted[type].ToArray(); int buyIndex = 0; int sellIndex = 0; int buyAmount = 0; int sellAmount = 0; TransactionItem purchase = null; TransactionItem sale = null; Transaction currentTransaction = null; bool finished = false; int minQtyNeeded = 0; while (!finished) { // Source station has more than destination wants if ((forSale[buyIndex].Quantity - buyAmount) > (wanted[sellIndex].Quantity - sellAmount)) { // Set the amount (qty) of the transaction int amount = (wanted[sellIndex].Quantity - sellAmount); // Create trades purchase = new TransactionItem(forSale[buyIndex], amount); if (minQtyNeeded > 0) { minQtyNeeded -= amount; } else { if (wanted[sellIndex].MinQuantity > amount) { sale = new TransactionItem(wanted[sellIndex]); minQtyNeeded = wanted[sellIndex].MinQuantity - amount; } else { sale = new TransactionItem(wanted[sellIndex], amount); } } // Set the buy amount up by the amount that can be sold buyAmount += amount; // reset the sell amount sellAmount = 0; sellIndex++; } // Source station has less than destination wants else if ((forSale[buyIndex].Quantity - buyAmount) < (wanted[sellIndex].Quantity - sellAmount)) { // Set the amount (qty) of the transaction int amount = (forSale[buyIndex].Quantity - buyAmount); // Create trades purchase = new TransactionItem(forSale[buyIndex], amount); if (minQtyNeeded > 0) { minQtyNeeded -= amount; } else { if (wanted[sellIndex].MinQuantity > amount) { sale = new TransactionItem(wanted[sellIndex]); minQtyNeeded = wanted[sellIndex].MinQuantity - amount; } else { sale = new TransactionItem(wanted[sellIndex], amount); } } // Set the buy amount up by the amount that can be sold sellAmount += amount; // reset the buy amount buyAmount = 0; buyIndex++; } else { // Set the amount (qty) of the transaction int amount = (wanted[sellIndex].Quantity - sellAmount); // Create trades purchase = new TransactionItem(forSale[buyIndex], amount); if (minQtyNeeded > 0) { minQtyNeeded -= amount; } else { if (wanted[sellIndex].MinQuantity > amount) { sale = new TransactionItem(wanted[sellIndex]); minQtyNeeded = wanted[sellIndex].MinQuantity - amount; } else { sale = new TransactionItem(wanted[sellIndex], amount); } } // Reset both buy and sell amount buyAmount = 0; sellAmount = 0; buyIndex++; sellIndex++; } if (currentTransaction == null) { currentTransaction = new Transaction(purchase, sale); } else { currentTransaction.AddPurchase(purchase); if (sale != null) { currentTransaction.AddSale(sale); } } purchase = null; sale = null; if ((wanted.Length <= sellIndex) || (forSale.Length <= buyIndex) || (wanted[sellIndex].UnitPrice <= forSale[buyIndex].UnitPrice)) { finished = true; } // If minimum quantity is achieved, add the transaction if ((finished) || ((minQtyNeeded <= 0) && (!((wanted[sellIndex].UnitPrice == wanted[Math.Max(sellIndex-1, 0)].UnitPrice) && (forSale[buyIndex].UnitPrice == forSale[Math.Max(buyIndex-1, 0)].UnitPrice))) )) { if (currentTransaction.Profit >= 0.0f) { list.Add(currentTransaction); } currentTransaction = null; minQtyNeeded = 0; } } return list; }
internal TransactionList GetProfitableTransactions(Station source, Station destination) { TransactionList list = new TransactionList(); foreach (KeyValuePair<ItemType, TradeList> element in source.ItemsForSale) { if (destination.ItemsWanted.ContainsKey(element.Key)) { // Element 0 should have the highest buy price and lowest sell price respectively if (destination.ItemsWanted[element.Key][0].UnitPrice > source.ItemsForSale[element.Key][0].UnitPrice) { // Get all the transactions for this item and station pair list.AddRange(GetItemTransactionList(source, destination, element.Key)); } } } return list; }
public TransDataSource() { TransactionList = new TransactionList(); BudgetList = new ObservableCollection<Budget>(); }
public void TransactionListConstructor() { var transationList = new TransactionList(); }
internal override void ReadXml(XmlTextReader reader) { while (reader.Read()) { // End of invoice element, get out of here if (reader.Name == "invoice" && reader.NodeType == XmlNodeType.EndElement) break; if (reader.NodeType != XmlNodeType.Element) continue; switch (reader.Name) { case "account": var accountHref = reader.GetAttribute("href"); AccountCode = Uri.UnescapeDataString(accountHref.Substring(accountHref.LastIndexOf("/") + 1)); break; case "subscription": var subHref = reader.GetAttribute("href"); SubscriptionUuid = Uri.UnescapeDataString(subHref.Substring(subHref.LastIndexOf("/") + 1)); break; case "original_invoice": var originalInvoiceHref = reader.GetAttribute("href"); var invoiceNumber = Uri.UnescapeDataString(originalInvoiceHref.Substring(originalInvoiceHref.LastIndexOf("/") + 1)); MatchCollection matches = Regex.Matches(invoiceNumber, "([^\\d]{2})(\\d+)"); if (matches.Count == 1) { OriginalInvoiceNumberPrefix = matches[0].Groups[1].Value; OriginalInvoiceNumber = int.Parse(matches[0].Groups[2].Value); } else { OriginalInvoiceNumber = int.Parse(invoiceNumber); } break; case "uuid": Uuid = reader.ReadElementContentAsString(); break; case "state": State = reader.ReadElementContentAsString().ParseAsEnum<InvoiceState>(); break; case "invoice_number": int invNumber; if (Int32.TryParse(reader.ReadElementContentAsString(), out invNumber)) InvoiceNumber = invNumber; break; case "invoice_number_prefix": InvoiceNumberPrefix = reader.ReadElementContentAsString(); break; case "po_number": PoNumber = reader.ReadElementContentAsString(); break; case "vat_number": VatNumber = reader.ReadElementContentAsString(); break; case "subtotal_in_cents": SubtotalInCents = reader.ReadElementContentAsInt(); break; case "tax_in_cents": TaxInCents = reader.ReadElementContentAsInt(); break; case "total_in_cents": TotalInCents = reader.ReadElementContentAsInt(); break; case "currency": Currency = reader.ReadElementContentAsString(); break; case "created_at": DateTime createdAt; if (DateTime.TryParse(reader.ReadElementContentAsString(), out createdAt)) CreatedAt = createdAt; break; case "closed_at": DateTime closedAt; if (DateTime.TryParse(reader.ReadElementContentAsString(), out closedAt)) ClosedAt = closedAt; break; case "tax_type": TaxType = reader.ReadElementContentAsString(); break; case "tax_rate": TaxRate = reader.ReadElementContentAsDecimal(); break; case "tax_region": TaxRegion = reader.ReadElementContentAsString(); break; case "net_terms": NetTerms = reader.ReadElementContentAsInt(); break; case "collection_method": CollectionMethod = reader.ReadElementContentAsString(); break; case "customer_notes": CustomerNotes = reader.ReadElementContentAsString(); break; case "terms_and_conditions": TermsAndConditions = reader.ReadElementContentAsString(); break; case "vat_reverse_charge_notes": VatReverseChargeNotes = reader.ReadElementContentAsString(); break; case "line_items": // overrite existing value with the Recurly API response Adjustments = new AdjustmentList(); Adjustments.ReadXml(reader); break; case "transactions": // overrite existing value with the Recurly API response Transactions = new TransactionList(); Transactions.ReadXml(reader); break; case "address": Address = new Address(reader); break; } } }
public TransactionList GetAllTransactions(int userId) { return null; try { TransactionList transList = new TransactionList(); using (EntityContext context = new EntityContext()) { var query = (from i in context.Transaction .Include(i => i.Category) .Include(i => i.CreatedUser) .Include(i => i.ModifiedUser) .Include(i => i.TransactionReasonType) .Include(i => i.TransactionType) where !i.IsDeleted && i.ModifiedUser.UserId == userId select new { transaction = i, category = i.Category.IsDeleted ? null : i.Category, categoryOther = context.Category.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)), transReason = i.TransactionReasonType.IsDeleted ? null : i.TransactionReasonType, transReasonOther = context.TransactionReason.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)) }).ToList(); foreach (var item in query) { var trans = item.transaction; if (item.category == null) { trans.Category = item.categoryOther; trans.TransactionReasonType = item.transReasonOther; } if (item.transReason == null) { trans.TransactionReasonType = item.transReasonOther; } transList.Add(trans); } transList.AcceptChanges(); return transList; } } catch (Exception) { throw; } }
public void AddTransaction(ITransaction transaction) { TransactionList.Add(transaction); TransactionList.Sort((x, y) => x.Timestamp.CompareTo(y.Timestamp)); }
public TransactionList GetLatestTransactionsLimit(int latestRecs, int userId) { try { TransactionList transList = new TransactionList(); using (EntityContext context = new EntityContext()) { context.Configuration.LazyLoadingEnabled = true; var query1 = (from i in context.Transaction .Include(i => i.TransactionType) .Include(i => i.TransactionReasonType) .Include(i => i.Category) .Include(i => i.Category.TypeTransactionReasons) .Include(i => i.ModifiedUser) .Include(i => i.CreatedUser) where !i.IsDeleted && i.ModifiedUser.UserId == userId orderby i.TransactionDate descending select i).Take(latestRecs == 0 ? int.MaxValue : latestRecs).ToList(); //investigate if there is a better way to convert the generic list to ObservableCollection foreach (var item in query1) { //item.trans.HasPhotos = item.hasPhotos; item.HasPhotos = context.TransactionImage.Count(x => x.Transaction.TransactionId == item.TransactionId && !x.IsDeleted) > 0; //var trans = item.item; if (item.Category.IsDeleted) { item.Category = context.Category.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)); item.TransactionReasonType = context.TransactionReason.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)); } if (item.TransactionReasonType.IsDeleted) { item.TransactionReasonType = context.TransactionReason.FirstOrDefault(x => x.Name.Equals("other", StringComparison.InvariantCultureIgnoreCase)); } transList.Add(item); } transList.PrepareForServiceSerialization(); return transList; } } catch (Exception) { throw; } }
/// <summary> /// Lists transactions by state and type. Defaults to all. /// </summary> /// <param name="state"></param> /// <param name="type"></param> /// <returns></returns> public static RecurlyList<Transaction> List(TransactionList.TransactionState state = TransactionList.TransactionState.All, TransactionList.TransactionType type = TransactionList.TransactionType.All) { return new TransactionList("/transactions/" + Build.QueryStringWith(state != TransactionList.TransactionState.All ? "state=" +state.ToString().EnumNameToTransportCase() : "") .AndWith(type != TransactionList.TransactionType.All ? "type=" +type.ToString().EnumNameToTransportCase() : "") ); }
public TransactionList GetTransactionsForBudget(int budgetId) { try { TransactionList transactionList = new TransactionList(); using (EntityContext context = new EntityContext()) { // DateTime d = DateTime.Now.AddDays(100); var query = from i in context.Transaction .Include(i => i.TransactionType).Where(k => !k.IsDeleted) .Include(i => i.TransactionReasonType).Where(k => !k.IsDeleted) .Include(i => i.Category).Where(k => !k.IsDeleted) //.Include(i => i.CreatedUser) //.Include(i => i.ModifiedUser) where i.CreatedDate >= context.Budget.Where(b => b.BudgetId == budgetId).Select(b => b.FromDate).FirstOrDefault() && i.CreatedDate <= context.Budget.Where(b => b.BudgetId == budgetId).Select(b => b.ToDate).FirstOrDefault() && !i.IsDeleted orderby i.CreatedDate descending select i; foreach (var item in query) transactionList.Add(item); transactionList.AcceptChanges(); return transactionList; } } catch (Exception) { throw; } }
/// <summary> /// Returns a list of transactions for this account, by transaction type /// </summary> /// <param name="state">Transactions of this state will be retrieved. Optional, default: All.</param> /// <param name="type">Transactions of this type will be retrieved. Optional, default: All.</param> /// <returns></returns> public RecurlyList<Transaction> GetTransactions(TransactionList.TransactionState state = TransactionList.TransactionState.All, TransactionList.TransactionType type = TransactionList.TransactionType.All) { return new TransactionList(UrlPrefix + Uri.EscapeUriString(AccountCode) + "/transactions/" + Build.QueryStringWith(state != TransactionList.TransactionState.All ? "state=" + state.ToString().EnumNameToTransportCase() : "") .AndWith(type != TransactionList.TransactionType.All ? "type=" + type.ToString().EnumNameToTransportCase() : "")); }
public ServiceData() { TransactionList = new TransactionList(); TransactionImageList = new TransactionImageList(); BudgetList = new BudgetList(); }
internal override void ReadXml(XmlTextReader reader) { while (reader.Read()) { // End of invoice element, get out of here if (reader.Name == "invoice" && reader.NodeType == XmlNodeType.EndElement) break; if (reader.NodeType != XmlNodeType.Element) continue; switch (reader.Name) { case "account": var accountHref = reader.GetAttribute("href"); AccountCode = Uri.UnescapeDataString(accountHref.Substring(accountHref.LastIndexOf("/") + 1)); break; case "subscription": var subHref = reader.GetAttribute("href"); SubscriptionUuid = Uri.UnescapeDataString(subHref.Substring(subHref.LastIndexOf("/") + 1)); break; case "uuid": Uuid = reader.ReadElementContentAsString(); break; case "state": State = reader.ReadElementContentAsString().ParseAsEnum<InvoiceState>(); break; case "invoice_number": int invNumber; if (Int32.TryParse(reader.ReadElementContentAsString(), out invNumber)) InvoiceNumber = invNumber; break; case "po_number": PoNumber = reader.ReadElementContentAsString(); break; case "vat_number": VatNumber = reader.ReadElementContentAsString(); break; case "subtotal_in_cents": SubtotalInCents = reader.ReadElementContentAsInt(); break; case "tax_in_cents": TaxInCents = reader.ReadElementContentAsInt(); break; case "total_in_cents": TotalInCents = reader.ReadElementContentAsInt(); break; case "currency": Currency = reader.ReadElementContentAsString(); break; case "created_at": DateTime createdAt; if (DateTime.TryParse(reader.ReadElementContentAsString(), out createdAt)) CreatedAt = createdAt; break; case "closed_at": DateTime closedAt; if (DateTime.TryParse(reader.ReadElementContentAsString(), out closedAt)) ClosedAt = closedAt; break; case "tax_type": TaxType = reader.ReadElementContentAsString(); break; case "tax_rate": TaxRate = reader.ReadElementContentAsDecimal(); break; case "net_terms": NetTerms = reader.ReadElementContentAsInt(); break; case "collection_method": CollectionMethod = reader.ReadElementContentAsString(); break; case "line_items": // overrite existing value with the Recurly API response Adjustments = new AdjustmentList(); Adjustments.ReadXml(reader); break; case "transactions": // overrite existing value with the Recurly API response Transactions = new TransactionList(); Transactions.ReadXml(reader); break; } } }
public bool CanSave(object param) { var checkmaster = MasterList.Where(x => x.IsCheckedMaster == true).ToList(); var check = TransactionList.Where(x => x.IsChecked == true).ToList(); string date = this.DateFormat as string; int count = 0; if (check != null && check.Count != 0) { foreach (var item in check) { try { if (!string.IsNullOrEmpty(item.StartDate) && !string.IsNullOrWhiteSpace(item.StartDate) && !string.IsNullOrEmpty(item.EndDate) && !string.IsNullOrEmpty(item.EndDate)) { //item.StartDate = item.StartDate.Replace('.', '/'); //item.StartDate = item.StartDate.Replace('-', '/'); //item.EndDate = item.EndDate.Replace('.', '/'); //item.EndDate = item.EndDate.Replace('-', '/'); var Start = (DateTime.ParseExact(item.StartDate, date, CultureInfo.InvariantCulture)); var End = (DateTime.ParseExact(item.EndDate, date, CultureInfo.InvariantCulture)); this.DateErrors = ""; if (End > Start) { count++; } else { this.DateErrors = "End Date should be greater than start date!"; return(false); } } } catch (Exception ex) { this.DateErrors = "Please enter the date in " + date + " format!"; return(false); } } var checkedcount = check.Count(); if (checkedcount == count && checkedcount > 0) { return(true); } else { return(false); } } else if (checkmaster != null) { var checkedcount = checkmaster.Count(); if (checkedcount > 0) { return(true); } else { return(false); } } else { return(false); } }