Skip to content

Commit

Permalink
Resolve issue #23 - GetScheduledTransaction error (#24)
Browse files Browse the repository at this point in the history
* Resolved issue of missing enum values for GoalTypes (used in Categories)

* resolve issue #23 - GetScheduledTransaction error

---------

Co-authored-by: Randy Gamage <[email protected]>
Co-authored-by: Joshua Marble <[email protected]>
  • Loading branch information
3 people authored Mar 18, 2024
1 parent f1df294 commit 401a79f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions YNAB.Rest.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ public static async Task Main(string[] args)
Console.WriteLine();
categories.ToList().ForEach(p => Console.WriteLine($"{p.Id} | {p.Name}"));

Console.WriteLine("Getting scheduled transactions...");
var scheduledTransactionsResponse = await api.GetScheduledTransactions(budget.Id);
var scheduledTransactions = scheduledTransactionsResponse.Data.ScheduledTransactions.Where(x => !x.Deleted).ToList();
Console.WriteLine($"Found {scheduledTransactions.Count} scheduled transactions!");
Console.WriteLine();

scheduledTransactions.ToList().ForEach(x => Console.WriteLine($"{x.Id} | {x.PayeeId} | {x.CategoryId} | {x.Amount.YnabLongToDecimal():C2} | {x.FlagColor}"));
}
catch (Exception ex)
{
Expand Down
1 change: 1 addition & 0 deletions YNAB.Rest/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ namespace YNAB.Rest
public static class Extensions
{
public static decimal YnabIntToDecimal(this int source) => ((decimal)source) / 1000;
public static decimal YnabLongToDecimal(this long source) => ((decimal)source) / 1000;
}
}
12 changes: 8 additions & 4 deletions YNAB.Rest/ScheduledTransaction.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;

namespace YNAB.Rest {
public class ScheduledTransaction {
public string id { get; set; }
public string dateFirst { get; set; }
public string dateNext { get; set; }
public string Id { get; set; }
public string DateFirst { get; set; }
public string DateNext { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public Frequency Frequency { get; set; }
public long Amount { get; set; }
public string Memo { get; set; }
public FlagColor FlagColor { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public FlagColor? FlagColor { get; set; }
public string AccountId { get; set; }
public string PayeeId { get; set; }
public string CategoryId { get; set; }
Expand Down

0 comments on commit 401a79f

Please sign in to comment.