GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Dbo/Entries/Item.h
Go to the documentation of this file.
1#line 2 "src/Dbo/Entries/Item.h"
2
3#ifndef __DBO_ENTRIES_ITEM_H___
4#define __DBO_ENTRIES_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 Entries {
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::Entries::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::Entries::Item > : Wt::Dbo::dbo_traits< GCW::Dbo::Entries::Item > {};
38
39/*
40** Now we can start building our class!
41**
42*/
43namespace GCW {
44 namespace Dbo {
45 namespace Entries {
46
47/*!
48** \brief Entries Class
49**
50**
51** \dot
52** digraph EntriesMap
53** {
54** EntriesItem;
55** }
56** \enddot
57**
58** \par Native GnuCash Entries Sqlite Schema
59** \code
60** CREATE TABLE entries
61** (
62** guid text(32) PRIMARY KEY NOT NULL,
63** date text(19) NOT NULL,
64** date_entered text(19),
65** description text(2048),
66** action text(2048),
67** notes text(2048),
68** quantity_num bigint,
69** quantity_denom bigint,
70** i_acct text(32),
71** i_price_num bigint,
72** i_price_denom bigint,
73** i_discount_num bigint,
74** i_discount_denom bigint,
75** invoice text(32),
76** i_disc_type text(2048),
77** i_disc_how text(2048),
78** i_taxable integer,
79** i_taxincluded integer,
80** i_taxtable text(32),
81** b_acct text(32),
82** b_price_num bigint,
83** b_price_denom bigint,
84** bill text(32),
85** b_taxable integer,
86** b_taxincluded integer,
87** b_taxtable text(32),
88** b_paytype integer,
89** billable integer,
90** billto_type integer,
91** billto_guid text(32),
92** order_guid text(32)
93** );
94** \endcode
95**
96*/
97class Item
98: public GCW::Dbo::BaseItem< Item >
99{
100 public:
101
102 /*!
103 ** \brief ctor
104 */
106
107 /*!
108 ** \brief ctor with guid
109 */
110 Item( const std::string & _guid ): m_guid( _guid ){}
111
112 /*!
113 ** \brief GUID
114 **
115 ** Return account 'guid' value - the primary key for the account
116 */
117 auto guid() const-> const std::string & { return m_guid; }
118
119 template< class Action > auto
120 persist( Action & action )-> void
121 {
122 Wt::Dbo::id ( action, m_guid , GCW::Dbo::Entries::Field::guid , 32 ); // text(32) PRIMARY KEY NOT NULL,
123 Wt::Dbo::field( action, m_date , GCW::Dbo::Entries::Field::date , 19 ); // text(19) NOT NULL,
125 Wt::Dbo::field( action, m_description , GCW::Dbo::Entries::Field::description , 2048 ); // text(2048),
126 Wt::Dbo::field( action, m_action , GCW::Dbo::Entries::Field::action , 2048 ); // text(2048),
127 Wt::Dbo::field( action, m_notes , GCW::Dbo::Entries::Field::notes , 2048 ); // text(2048),
130 Wt::Dbo::field( action, m_i_acct , GCW::Dbo::Entries::Field::i_acct , 32 ); // text(32),
135 Wt::Dbo::field( action, m_invoice , GCW::Dbo::Entries::Field::invoice , 32 ); // text(32),
136 Wt::Dbo::field( action, m_i_disc_type , GCW::Dbo::Entries::Field::i_disc_type , 2048 ); // text(2048),
137 Wt::Dbo::field( action, m_i_disc_how , GCW::Dbo::Entries::Field::i_disc_how , 2048 ); // text(2048),
141 Wt::Dbo::field( action, m_b_acct , GCW::Dbo::Entries::Field::b_acct , 32 ); // text(32),
144 Wt::Dbo::field( action, m_bill , GCW::Dbo::Entries::Field::bill , 32 ); // text(32),
153
154 } // endpersist( Action & action )-> void
155
156 private:
157
158 std::string m_guid ; // text(32) PRIMARY KEY NOT NULL,
159 std::string m_date ; // text(19) NOT NULL,
160 std::string m_date_entered ; // text(19),
161 std::string m_description ; // text(2048),
162 std::string m_action ; // text(2048),
163 std::string m_notes ; // text(2048),
164 int m_quantity_num ; // bigint,
165 int m_quantity_denom ; // bigint,
166 std::string m_i_acct ; // text(32),
167 int m_i_price_num ; // bigint,
168 int m_i_price_denom ; // bigint,
169 int m_i_discount_num ; // bigint,
170 int m_i_discount_denom ; // bigint,
171 std::string m_invoice ; // text(32),
172 std::string m_i_disc_type ; // text(2048),
173 std::string m_i_disc_how ; // text(2048),
174 int m_i_taxable ; // integer,
175 int m_i_taxincluded ; // integer,
176 std::string m_i_taxtable ; // text(32),
177 std::string m_b_acct ; // text(32),
178 int m_b_price_num ; // bigint,
179 int m_b_price_denom ; // bigint,
180 std::string m_bill ; // text(32),
181 int m_b_taxable ; // integer,
182 int m_b_taxincluded ; // integer,
183 std::string m_b_taxtable ; // text(32),
184 int m_b_paytype ; // integer,
185 int m_billable ; // integer,
186 int m_billto_type ; // integer,
187 std::string m_billto_guid ; // text(32),
188 std::string m_order_guid ; // text(32)
189
190}; // endclass Item
191
192 } // endnamespace Entries {
193 } // endnamespace Dbo {
194} // endnamespace GCW {
195
196#endif // __DBO_ENTRIES_ITEM_H___
197
Item(const std::string &_guid)
ctor with guid
auto persist(Action &action) -> void
auto guid() const -> const std::string &
GUID.
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 bill
Definition Entries.cpp:32
const Wt::WFormModel::Field i_taxtable
Definition Entries.cpp:28
const Wt::WFormModel::Field i_discount_denom
Definition Entries.cpp:22
const Wt::WFormModel::Field action
Definition Entries.cpp:14
const Wt::WFormModel::Field billable
Definition Entries.cpp:37
const Wt::WFormModel::Field guid
Definition Entries.cpp:10
const Wt::WFormModel::Field i_disc_how
Definition Entries.cpp:25
const Wt::WFormModel::Field b_taxable
Definition Entries.cpp:33
const Wt::WFormModel::Field b_price_denom
Definition Entries.cpp:31
const Wt::WFormModel::Field date_entered
Definition Entries.cpp:12
const Wt::WFormModel::Field i_disc_type
Definition Entries.cpp:24
const Wt::WFormModel::Field billto_type
Definition Entries.cpp:38
const Wt::WFormModel::Field description
Definition Entries.cpp:13
const Wt::WFormModel::Field b_paytype
Definition Entries.cpp:36
const Wt::WFormModel::Field date
Definition Entries.cpp:11
const Wt::WFormModel::Field billto_guid
Definition Entries.cpp:39
const Wt::WFormModel::Field b_taxtable
Definition Entries.cpp:35
const Wt::WFormModel::Field i_discount_num
Definition Entries.cpp:21
const Wt::WFormModel::Field order_guid
Definition Entries.cpp:40
const Wt::WFormModel::Field i_price_num
Definition Entries.cpp:19
const Wt::WFormModel::Field notes
Definition Entries.cpp:15
const Wt::WFormModel::Field b_price_num
Definition Entries.cpp:30
const Wt::WFormModel::Field i_taxable
Definition Entries.cpp:26
const Wt::WFormModel::Field b_acct
Definition Entries.cpp:29
const Wt::WFormModel::Field i_price_denom
Definition Entries.cpp:20
const Wt::WFormModel::Field i_taxincluded
Definition Entries.cpp:27
const Wt::WFormModel::Field quantity_num
Definition Entries.cpp:16
const Wt::WFormModel::Field invoice
Definition Entries.cpp:23
const Wt::WFormModel::Field quantity_denom
Definition Entries.cpp:17
const Wt::WFormModel::Field b_taxincluded
Definition Entries.cpp:34
const Wt::WFormModel::Field i_acct
Definition Entries.cpp:18
Definition App.h:18
static auto surrogateIdField() -> const char *