Created
August 29, 2019 16:09
-
-
Save plusangel/e07bb911aeffdcfb6e2fdf0458d51da7 to your computer and use it in GitHub Desktop.
invoices example in modern c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef INVOICE_H_ | |
| #define INVOICE_H_ | |
| #include <chrono> | |
| #include <memory> | |
| #include <ostream> | |
| #include <string> | |
| #include <vector> | |
| #include "Customer.h" | |
| #include "InvoiceLineItem.h" | |
| #include "Money.h" | |
| #include "UniqueIdentifier.h" | |
| using InvoiceLineItemPtr = std::shared_ptr<InvoiceLineItem>; | |
| using InvoiceLineItems = std::vector<InvoiceLineItemPtr>; | |
| using InvoiceRecipient = Customer; | |
| using InvoiceRecipientPtr = std::shared_ptr<InvoiceRecipient>; | |
| using DateTime = std::chrono:system_clock::time_point; | |
| class Invoice { | |
| public: | |
| explicit Invoice(const UniqueIdentifier& invoiceNumber); | |
| Invoice() = delete; | |
| void setRecipient(const InvoiceRecipientPtr& recipient); | |
| void setDateTimeOfInvoicing(const DateTime& dateTimeOfInvoicing); | |
| Money getSum() const; | |
| Money getSumWithoutTax() const; | |
| void addLineItem(const InvoiceLineItemPtr& lineItem); | |
| private: | |
| friend std::ostream& operator<<(std::ostream& outstream, const Invoice& invoice); | |
| std::string getDateTimeOInvoicingAsString() const; | |
| UniqueIdentifier invoiceNumber; | |
| DateTime dateTimeOfInvoicing; | |
| InvoiceRecipientPtr recipient; | |
| InvoiceLineItems invoiceLineItems; | |
| }; | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment