GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Dbo/Invoices/Item.h
Go to the documentation of this file.
1#line 2 "src/Dbo/Invoices/Item.h"
2
3#ifndef __DBO_INVOICES_ITEM_H___
4#define __DBO_INVOICES_ITEM_H___
5
6#include "../BaseItem.h"
7#include "Definition.h"
8
9/*
10** Predefine the Entries class that fixin to come up.
11**
12*/
13namespace GCW {
14 namespace Dbo {
15 namespace Invoices {
16 class Item;
17 }
18 }
19}
20
21/*
22** Define these dbo_traits to prevent the system from
23** automatically generating an ID field or a VERSION
24** field, and instead substitute the guid field
25** as the primary key.
26**
27*/
28template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::Invoices::Item >
30{
31 using IdType = std::string;
32 static auto invalidId()-> IdType { return std::string(); }
33 static auto surrogateIdField()-> const char * { return nullptr; }
34 static auto versionField()-> const char * { return nullptr; }
35};
36
37template<> struct Wt::Dbo::dbo_traits< const GCW::Dbo::Invoices::Item > : Wt::Dbo::dbo_traits< GCW::Dbo::Invoices::Item > {};
38
39/*
40** Now we can start building our class!
41**
42*/
43namespace GCW {
44 namespace Dbo {
45 namespace Invoices {
46
47/*!
48** \brief Invoices Class
49**
50**
51** \dot
52** digraph InvoicesMap
53** {
54** InvoicesItem;
55** }
56** \enddot
57**
58** \par Native GnuCash Invoice Sqlite Schema
59** \code
60** CREATE TABLE invoices
61** (
62** guid text(32) PRIMARY KEY NOT NULL,
63** id text(2048) NOT NULL,
64** date_opened text(19),
65** date_posted text(19),
66** notes text(2048) NOT NULL,
67** active integer NOT NULL,
68** currency text(32) NOT NULL,
69** owner_type integer,
70** owner_guid text(32),
71** terms text(32),
72** billing_id text(2048),
73** post_txn text(32),
74** post_lot text(32),
75** post_acc text(32),
76** billto_type integer,
77** billto_guid text(32),
78** charge_amt_num bigint,
79** charge_amt_denom bigint
80** );
81** \endcode
82**
83*/
84class Item
85: public GCW::Dbo::BaseItem< Item >
86{
87 public:
88
89 /*!
90 ** \brief ctor
91 */
92 Item(){}
93
94 /*!
95 ** \brief ctor with guid
96 */
97 Item( const std::string & _guid ): m_guid( _guid ){}
98
99 /*!
100 ** \brief GUID
101 **
102 ** Return account 'guid' value - the primary key for the account
103 */
104 auto guid() const-> const std::string & { return m_guid; }
105
106 template< class Action > auto
107 persist( Action & action )-> void
108 {
109 Wt::Dbo::id ( action, m_guid , GCW::Dbo::Invoices::Field::guid , 32 ); // text(32) PRIMARY KEY NOT NULL,
110 Wt::Dbo::field( action, m_id , GCW::Dbo::Invoices::Field::id , 2048 ); // text(2048) NOT NULL,
113 Wt::Dbo::field( action, m_notes , GCW::Dbo::Invoices::Field::notes , 2048 ); // text(2048) NOT NULL,
114 Wt::Dbo::field( action, m_active , GCW::Dbo::Invoices::Field::active ); // integer NOT NULL,
115 Wt::Dbo::field( action, m_currency , GCW::Dbo::Invoices::Field::currency , 32 ); // text(32) NOT NULL,
118 Wt::Dbo::field( action, m_terms , GCW::Dbo::Invoices::Field::terms , 32 ); // text(32),
119 Wt::Dbo::field( action, m_billing_id , GCW::Dbo::Invoices::Field::billing_id , 2048 ); // text(2048),
127
128 } // endpersist( Action & action )-> void
129
130 private:
131
132 std::string m_guid ; // text(32) PRIMARY KEY NOT NULL,
133 std::string m_id ; // text(2048) NOT NULL,
134 std::string m_date_opened ; // text(19),
135 std::string m_date_posted ; // text(19),
136 std::string m_notes ; // text(2048) NOT NULL,
137 int m_active ; // integer NOT NULL,
138 std::string m_currency ; // text(32) NOT NULL,
139 int m_owner_type ; // integer,
140 std::string m_owner_guid ; // text(32),
141 std::string m_terms ; // text(32),
142 std::string m_billing_id ; // text(2048),
143 std::string m_post_txn ; // text(32),
144 std::string m_post_lot ; // text(32),
145 std::string m_post_acc ; // text(32),
146 int m_billto_type ; // integer,
147 std::string m_billto_guid ; // text(32),
148 int m_charge_amt_num ; // bigint,
149 int m_charge_amt_denom ; // bigint
150
151}; // endclass Item
152
153 } // endnamespace Invoices {
154 } // endnamespace Dbo {
155} // endnamespace GCW {
156
157#endif // __DBO_INVOICES_ITEM_H___
158
Item(const std::string &_guid)
ctor with guid
auto guid() const -> const std::string &
GUID.
auto persist(Action &action) -> void
void id(Action &action, V &value, const std::string &name="id", int size=-1)
void field(Action &action, V &value, const std::string &name, int size=-1)
const Wt::WFormModel::Field notes
const Wt::WFormModel::Field currency
const Wt::WFormModel::Field billing_id
const Wt::WFormModel::Field billto_guid
const Wt::WFormModel::Field date_posted
const Wt::WFormModel::Field active
const Wt::WFormModel::Field id
const Wt::WFormModel::Field post_lot
const Wt::WFormModel::Field billto_type
const Wt::WFormModel::Field post_acc
const Wt::WFormModel::Field owner_type
const Wt::WFormModel::Field date_opened
const Wt::WFormModel::Field charge_amt_num
const Wt::WFormModel::Field owner_guid
const Wt::WFormModel::Field post_txn
const Wt::WFormModel::Field guid
const Wt::WFormModel::Field charge_amt_denom
const Wt::WFormModel::Field terms
Definition App.h:18