GnuCashew ~ GnuCash Enabled Web
GCW
Item.h
Go to the documentation of this file.
1 #line 2 "src/Dbo/Customers/Item.h"
2 
3 #ifndef __DBO_CUSTOMERS_ITEM_H___
4 #define __DBO_CUSTOMERS_ITEM_H___
5 
6 #include "../BaseItem.h"
7 #include "Definition.h"
8 
9 /*
10 ** Predefine the Account class that fixin to come up.
11 **
12 */
13 namespace GCW {
14  namespace Dbo {
15  namespace Customers {
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 */
28 template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::Customers::Item >
29 : public Wt::Dbo::dbo_default_traits
30 {
31  using IdType = std::string;
32  static IdType invalidId() { return std::string(); }
33  static const char * surrogateIdField() { return nullptr; }
34  static const char * versionField() { return nullptr; }
35 };
36 
37 template<>
38  struct Wt::Dbo::dbo_traits< const GCW::Dbo::Customers::Item >
39  : Wt::Dbo::dbo_traits< GCW::Dbo::Customers::Item > {};
40 
41 /*
42 ** Now we can start building our class!
43 **
44 */
45 namespace GCW {
46  namespace Dbo {
47  namespace Customers {
48 
49 /*!
50 ** \brief Customer Item Class
51 **
52 ** This class represents an 'customer' within gnucash. This is a Dbo object
53 ** so this class is used as the interface between the gnucashew application
54 ** and the back-end database.
55 **
56 ** \par Native GnuCash Account Sqlite Schema
57 ** \code
58 ** CREATE TABLE customers
59 ** (
60 ** guid text(32) PRIMARY KEY NOT NULL,
61 ** name text(2048) NOT NULL,
62 ** id text(2048) NOT NULL,
63 ** notes text(2048) NOT NULL,
64 ** active integer NOT NULL,
65 ** discount_num bigint NOT NULL,
66 ** discount_denom bigint NOT NULL,
67 ** credit_num bigint NOT NULL,
68 ** credit_denom bigint NOT NULL,
69 ** currency text(32) NOT NULL,
70 ** tax_override integer NOT NULL,
71 ** addr_name text(1024),
72 ** addr_addr1 text(1024),
73 ** addr_addr2 text(1024),
74 ** addr_addr3 text(1024),
75 ** addr_addr4 text(1024),
76 ** addr_phone text(128),
77 ** addr_fax text(128),
78 ** addr_email text(256),
79 ** shipaddr_name text(1024),
80 ** shipaddr_addr1 text(1024),
81 ** shipaddr_addr2 text(1024),
82 ** shipaddr_addr3 text(1024),
83 ** shipaddr_addr4 text(1024),
84 ** shipaddr_phone text(128),
85 ** shipaddr_fax text(128),
86 ** shipaddr_email text(256),
87 ** terms text(32),
88 ** tax_included integer,
89 ** taxtable text(32)
90 ** );
91 **
92 ** sqlite> select * from customers;
93 ** f7bc3a5dec934b30bfa185060838a256|BishBash CPA|BBS||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|Dick C. Cavett CPA PC|Sheffield Road, #720|Deluth, TX 22313-8178|||442-344-1886||jim@holocow.com||||||||||3|
94 ** 3168628916994bf985b1477c3635ed4f|Flourtems|FTM||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|Flourtems Fine Services|f442 Sadly Trail|Suite 123|Point, TX 42233||535-233-2477||femoins@ffs.com||||||||||3|
95 ** 6f61a67518544d5bad98b571324a0ad3|Kid Bright|KFP||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|Kid Bright Pediatrics|1234 Lavon Hollow|Suite #13|Brunch, TX 32345||972-233-4463|223-440-2442|mary@fbp.com||||||||||3|
96 ** cb894898e1654cd1a074c047a9c10fb3|BYOB|BYB||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|BYOB Distribution|1230 Francis Drive|Suite 2220|Alabama, TX 22334||442-785-0083||hank@justsayno.co||||||||||3|
97 ** e640931e57854e60ad100b55d7492e27|Pishaww Colifloury|PCU||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|Pichschaw Ancilary|3224 North 55th Street|Suite 123|Frankfruit, TX 22141||777-332-3567|332-322-6698|bilbowbagins@flouride.com||||||||||3|
98 ** b16870d305cd43d0b75aca0363fc5b0a|Ping Pong Botch|PPB||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|Yes to Everything|1122 East Campgranada Road|Suite 220|Anklebracelette, Texas 75281||522-344-3500|234-332-3232|info@yesyesyes.com||||||||||3|
99 ** 1dfb5117a9564046b833e6544df6ed22|Test|TST||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0||||||||||||||||||3|
100 ** d246b19706cb43df8e3b4cad1b78142a|Transfiber|TFT||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|Telezokim Flampourneet|523 N. Ankle Street|Suite #3722|Alabony, TX 75211||224-344-0222|244-322-4442|gbckkd@hispster.com||||||||||3|
101 ** 74031f41723a414e8f43ba1b36bf711d|Bring Broth Better|BBB||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|Brunch Partners Recruiting|||||224-444-4211||heberewt@ddalzatraz.com||||||||||3|
102 ** a4279e038684453a848dab6efbb87d38|Ten Nine Eight|TNE||1|0|1|0|1|3d1e5462691a4289baec562fa9c26cfd|0|Ten Eight Nine|1235 Capitalone Hollow|Suite 125|Carrolzby, TN 22331||922-333-9177||cccounting@teneightyeleven.com|||||||||83bb345e87544d3e9c6b501881edd8fc|3|
103 ** sqlite>
104 ** \endcode
105 **
106 */
107 class Item
108 : public GCW::Dbo::BaseItem< Item >
109 {
110  public:
111 
112  const std::string & guid () const { return m_guid ; }
113  const std::string & name () const { return m_name ; }
114  const std::string & id () const { return m_id ; }
115 
116  template< class Action > void persist( Action & action )
117  {
118  Wt::Dbo::id ( action, m_guid , GCW::Dbo::Customers::Field::guid , 32 ); // text(32) PRIMARY KEY NOT NULL
119  Wt::Dbo::field( action, m_name , GCW::Dbo::Customers::Field::name , 2048 ); // text(2048) NOT NULL
120  Wt::Dbo::field( action, m_id , GCW::Dbo::Customers::Field::id , 2048 ); // text(2048) NOT NULL
121  Wt::Dbo::field( action, m_notes , GCW::Dbo::Customers::Field::notes , 2048 ); // text(2048) NOT NULL,
122  Wt::Dbo::field( action, m_active , GCW::Dbo::Customers::Field::active ); // integer NOT NULL,
123  Wt::Dbo::field( action, m_discount_num , GCW::Dbo::Customers::Field::discount_num ); // bigint NOT NULL,
124  Wt::Dbo::field( action, m_discount_denom , GCW::Dbo::Customers::Field::discount_denom ); // bigint NOT NULL,
125  Wt::Dbo::field( action, m_credit_num , GCW::Dbo::Customers::Field::credit_num ); // bigint NOT NULL,
126  Wt::Dbo::field( action, m_credit_denom , GCW::Dbo::Customers::Field::credit_denom ); // bigint NOT NULL,
127  Wt::Dbo::field( action, m_currency , GCW::Dbo::Customers::Field::currency , 32 ); // text(32) NOT NULL,
128  Wt::Dbo::field( action, m_tax_override , GCW::Dbo::Customers::Field::tax_override ); // integer NOT NULL,
129  Wt::Dbo::field( action, m_addr_name , GCW::Dbo::Customers::Field::addr_name , 1024 ); // text(1024),
130  Wt::Dbo::field( action, m_addr_addr1 , GCW::Dbo::Customers::Field::addr_addr1 , 1024 ); // text(1024),
131  Wt::Dbo::field( action, m_addr_addr2 , GCW::Dbo::Customers::Field::addr_addr2 , 1024 ); // text(1024),
132  Wt::Dbo::field( action, m_addr_addr3 , GCW::Dbo::Customers::Field::addr_addr3 , 1024 ); // text(1024),
133  Wt::Dbo::field( action, m_addr_addr4 , GCW::Dbo::Customers::Field::addr_addr4 , 1024 ); // text(1024),
134  Wt::Dbo::field( action, m_addr_phone , GCW::Dbo::Customers::Field::addr_phone , 128 ); // text(128),
135  Wt::Dbo::field( action, m_addr_fax , GCW::Dbo::Customers::Field::addr_fax , 128 ); // text(128),
136  Wt::Dbo::field( action, m_addr_email , GCW::Dbo::Customers::Field::addr_email , 256 ); // text(256),
137  Wt::Dbo::field( action, m_shipaddr_name , GCW::Dbo::Customers::Field::shipaddr_name , 1024 ); // text(1024),
138  Wt::Dbo::field( action, m_shipaddr_addr1 , GCW::Dbo::Customers::Field::shipaddr_addr1 , 1024 ); // text(1024),
139  Wt::Dbo::field( action, m_shipaddr_addr2 , GCW::Dbo::Customers::Field::shipaddr_addr2 , 1024 ); // text(1024),
140  Wt::Dbo::field( action, m_shipaddr_addr3 , GCW::Dbo::Customers::Field::shipaddr_addr3 , 1024 ); // text(1024),
141  Wt::Dbo::field( action, m_shipaddr_addr4 , GCW::Dbo::Customers::Field::shipaddr_addr4 , 1024 ); // text(1024),
142  Wt::Dbo::field( action, m_shipaddr_phone , GCW::Dbo::Customers::Field::shipaddr_phone , 128 ); // text(128),
143  Wt::Dbo::field( action, m_shipaddr_fax , GCW::Dbo::Customers::Field::shipaddr_fax , 128 ); // text(128),
144  Wt::Dbo::field( action, m_shipaddr_email , GCW::Dbo::Customers::Field::shipaddr_email , 256 ); // text(256),
145  Wt::Dbo::field( action, m_terms , GCW::Dbo::Customers::Field::terms , 32 ); // text(32),
146  Wt::Dbo::field( action, m_tax_included , GCW::Dbo::Customers::Field::tax_included ); // integer,
147  Wt::Dbo::field( action, m_taxtable , GCW::Dbo::Customers::Field::taxtable , 32 ); // text(32)
148 
149  } // endtemplate< class Action > void persist( Action & action )
150 
151  private:
152 
153  std::string m_guid ;
154  std::string m_name ;
155  std::string m_id ;
156  std::string m_notes ; // text(2048) NOT NULL,
157  int m_active ; // integer NOT NULL,
158  int m_discount_num ; // bigint NOT NULL,
159  int m_discount_denom ; // bigint NOT NULL,
160  int m_credit_num ; // bigint NOT NULL,
161  int m_credit_denom ; // bigint NOT NULL,
162  std::string m_currency ; // text(32) NOT NULL,
163  int m_tax_override ; // integer NOT NULL,
164  std::string m_addr_name ; // text(1024),
165  std::string m_addr_addr1 ; // text(1024),
166  std::string m_addr_addr2 ; // text(1024),
167  std::string m_addr_addr3 ; // text(1024),
168  std::string m_addr_addr4 ; // text(1024),
169  std::string m_addr_phone ; // text(128),
170  std::string m_addr_fax ; // text(128),
171  std::string m_addr_email ; // text(256),
172  std::string m_shipaddr_name ; // text(1024),
173  std::string m_shipaddr_addr1 ; // text(1024),
174  std::string m_shipaddr_addr2 ; // text(1024),
175  std::string m_shipaddr_addr3 ; // text(1024),
176  std::string m_shipaddr_addr4 ; // text(1024),
177  std::string m_shipaddr_phone ; // text(128),
178  std::string m_shipaddr_fax ; // text(128),
179  std::string m_shipaddr_email ; // text(256),
180  std::string m_terms ; // text(32),
181  int m_tax_included ; // integer,
182  std::string m_taxtable ; // text(32)
183 
184 
185 }; // endclass Item
186 
187 extern const char * s_tableName;
188 
189  } // endnamespace Customers {
190  } // endnamespace Dbo {
191 } // endnamespace GCW {
192 
193 #endif // #ifndef __CUSTOMERS_H___
194 
195 
Customer Item Class.
Definition: Item.h:109
std::string m_addr_addr3
Definition: Item.h:167
std::string m_addr_phone
Definition: Item.h:169
std::string m_terms
Definition: Item.h:180
std::string m_addr_addr4
Definition: Item.h:168
std::string m_taxtable
Definition: Item.h:182
std::string m_shipaddr_addr2
Definition: Item.h:174
std::string m_shipaddr_email
Definition: Item.h:179
std::string m_guid
Definition: Item.h:153
std::string m_shipaddr_phone
Definition: Item.h:177
std::string m_name
Definition: Item.h:154
std::string m_shipaddr_addr4
Definition: Item.h:176
std::string m_addr_addr1
Definition: Item.h:165
void persist(Action &action)
Definition: Item.h:116
const std::string & guid() const
Definition: Item.h:112
std::string m_shipaddr_fax
Definition: Item.h:178
std::string m_currency
Definition: Item.h:162
std::string m_shipaddr_name
Definition: Item.h:172
std::string m_shipaddr_addr3
Definition: Item.h:175
const std::string & id() const
Definition: Item.h:114
std::string m_addr_name
Definition: Item.h:164
std::string m_id
Definition: Item.h:155
std::string m_addr_fax
Definition: Item.h:170
std::string m_notes
Definition: Item.h:156
std::string m_addr_addr2
Definition: Item.h:166
std::string m_addr_email
Definition: Item.h:171
std::string m_shipaddr_addr1
Definition: Item.h:173
const std::string & name() const
Definition: Item.h:113
Wt::WFormModel::Field addr_addr1
Definition: Customers.cpp:20
Wt::WFormModel::Field addr_name
Definition: Customers.cpp:19
Wt::WFormModel::Field tax_included
Definition: Customers.cpp:36
Wt::WFormModel::Field discount_denom
Definition: Customers.cpp:14
Wt::WFormModel::Field notes
Definition: Customers.cpp:11
Wt::WFormModel::Field shipaddr_addr4
Definition: Customers.cpp:31
Wt::WFormModel::Field addr_fax
Definition: Customers.cpp:25
Wt::WFormModel::Field shipaddr_email
Definition: Customers.cpp:34
Wt::WFormModel::Field taxtable
Definition: Customers.cpp:37
Wt::WFormModel::Field guid
Definition: Customers.cpp:8
Wt::WFormModel::Field addr_addr3
Definition: Customers.cpp:22
Wt::WFormModel::Field tax_override
Definition: Customers.cpp:18
Wt::WFormModel::Field active
Definition: Customers.cpp:12
Wt::WFormModel::Field shipaddr_fax
Definition: Customers.cpp:33
Wt::WFormModel::Field addr_phone
Definition: Customers.cpp:24
Wt::WFormModel::Field credit_denom
Definition: Customers.cpp:16
Wt::WFormModel::Field shipaddr_addr3
Definition: Customers.cpp:30
Wt::WFormModel::Field addr_email
Definition: Customers.cpp:26
Wt::WFormModel::Field name
Definition: Customers.cpp:9
Wt::WFormModel::Field discount_num
Definition: Customers.cpp:13
Wt::WFormModel::Field currency
Definition: Customers.cpp:17
Wt::WFormModel::Field terms
Definition: Customers.cpp:35
Wt::WFormModel::Field shipaddr_addr1
Definition: Customers.cpp:28
Wt::WFormModel::Field addr_addr2
Definition: Customers.cpp:21
Wt::WFormModel::Field shipaddr_name
Definition: Customers.cpp:27
Wt::WFormModel::Field credit_num
Definition: Customers.cpp:15
Wt::WFormModel::Field id
Definition: Customers.cpp:10
Wt::WFormModel::Field shipaddr_phone
Definition: Customers.cpp:32
Wt::WFormModel::Field shipaddr_addr2
Definition: Customers.cpp:29
Wt::WFormModel::Field addr_addr4
Definition: Customers.cpp:23
const char * s_tableName
Definition: Customers.cpp:6
const Wt::WFormModel::Field action
Definition: Entries.cpp:14
const Wt::WFormModel::Field id
Definition: Definition.h:17
Definition: App.h:17
static const char * surrogateIdField()
Definition: Item.h:33