Skip to content

Angus Townsley - #52

Open
angustownsley wants to merge 8 commits into
boolean-uk:mainfrom
angustownsley:main
Open

Angus Townsley#52
angustownsley wants to merge 8 commits into
boolean-uk:mainfrom
angustownsley:main

Conversation

@angustownsley

Copy link
Copy Markdown

No description provided.

BankAccount testAccount = new BankAccount("BigSpender");
string jsonExample = """[{"Id":"1","Date":"2024-01-01T10:30:00","Value":10000,"Type":"Credit"}]""";

testAccount.AddTransaction("1", new DateTime(2024, 1, 1, 10, 30, 0), 10000, "Credit");

@vherus vherus Jun 17, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum!

enum TransactionType {
    Credit
    Debit
}

Transaction {
  TransactionType type

  Transaction(..., TransactionType type) {

  }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (type == TransactionType.Credit)

Comment on lines +14 to +16
List<Transaction> transactionHistory;

public BankAccount(string id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it to the constructor

transactionHistory = transactionHistory.OrderBy(e => e.Date).ToList();
}

public string WriteTransactionsJson()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public string ToJson()

Comment on lines +78 to +113
public string PrintStatement()
{
return FormatTransactions(transactionHistory);

}

public void PrintStatementToPDF()
{

string statement = PrintStatement();
PdfDocumentBuilder builder = new PdfDocumentBuilder();

PdfPageBuilder page = builder.AddPage(PageSize.A5);
PdfDocumentBuilder.AddedFont font = builder.AddStandard14Font(Standard14Font.Courier);


string[] statementByLine = PrintStatement().Split('\r');
int xCoOrd = 25;
int yCoOrd = 520;
foreach (string element in statementByLine)
{


page.AddText(element, 12, new PdfPoint(xCoOrd, yCoOrd), font);


yCoOrd -= 25;

}



byte[] documentBytes = builder.Build();

File.WriteAllBytes(@"C:\PDF\Statment.pdf", documentBytes);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public string PrintStatement() {
  return FormatTransactions(transactionHistory);
}

public void PrintStatement(PdfDocumentBuilder pdfBuilder) {
  
}


bankAccount.PrintStatement()
bankAccount.PrintStatement(new PdfDocumentBuilder())

PdfDocumentBuilder.AddedFont font = builder.AddStandard14Font(Standard14Font.Courier);


string[] statementByLine = PrintStatement().Split('\r');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\r\n


string[] statementByLine = PrintStatement().Split('\r');
int xCoOrd = 25;
int yCoOrd = 520;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int fontSize = 12;


byte[] documentBytes = builder.Build();

File.WriteAllBytes(@"C:\PDF\Statment.pdf", documentBytes);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameterise this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants