GnuCashew ~ GnuCash Enabled Web
GCW
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 */
13 namespace 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 */
28 template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::Invoices::Item >
29 : public Wt::Dbo::dbo_default_traits
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 
37 template<> 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 */
43 namespace 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 */
84 class 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,
111  Wt::Dbo::field( action, m_date_opened , GCW::Dbo::Invoices::Field::date_opened , 19 ); // text(19),
112  Wt::Dbo::field( action, m_date_posted , GCW::Dbo::Invoices::Field::date_posted , 19 ); // text(19),
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,
116  Wt::Dbo::field( action, m_owner_type , GCW::Dbo::Invoices::Field::owner_type ); // integer,
117  Wt::Dbo::field( action, m_owner_guid , GCW::Dbo::Invoices::Field::owner_guid , 32 ); // text(32),
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),
120  Wt::Dbo::field( action, m_post_txn , GCW::Dbo::Invoices::Field::post_txn , 32 ); // text(32),
121  Wt::Dbo::field( action, m_post_lot , GCW::Dbo::Invoices::Field::post_lot , 32 ); // text(32),
122  Wt::Dbo::field( action, m_post_acc , GCW::Dbo::Invoices::Field::post_acc , 32 ); // text(32),
123  Wt::Dbo::field( action, m_billto_type , GCW::Dbo::Invoices::Field::billto_type ); // integer,
124  Wt::Dbo::field( action, m_billto_guid , GCW::Dbo::Invoices::Field::billto_guid , 32 ); // text(32),
125  Wt::Dbo::field( action, m_charge_amt_num , GCW::Dbo::Invoices::Field::charge_amt_num ); // bigint,
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 
std::string m_billto_guid
Definition: Item.h:147
std::string m_post_txn
Definition: Item.h:143
Item(const std::string &_guid)
ctor with guid
Definition: Item.h:97
std::string m_date_posted
Definition: Item.h:135
std::string m_owner_guid
Definition: Item.h:140
std::string m_billing_id
Definition: Item.h:142
std::string m_terms
Definition: Item.h:141
std::string m_date_opened
Definition: Item.h:134
std::string m_post_lot
Definition: Item.h:144
auto guid() const -> const std::string &
GUID.
Definition: Item.h:104
std::string m_guid
Definition: Item.h:132
std::string m_post_acc
Definition: Item.h:145
std::string m_id
Definition: Item.h:133
std::string m_notes
Definition: Item.h:136
std::string m_currency
Definition: Item.h:138
auto persist(Action &action) -> void
Definition: Item.h:107
const Wt::WFormModel::Field action
Definition: Entries.cpp:14
const Wt::WFormModel::Field notes
Definition: Definition.h:20
const Wt::WFormModel::Field currency
Definition: Definition.h:22
const Wt::WFormModel::Field billing_id
Definition: Definition.h:26
const Wt::WFormModel::Field billto_guid
Definition: Definition.h:31
const Wt::WFormModel::Field date_posted
Definition: Definition.h:19
const Wt::WFormModel::Field active
Definition: Definition.h:21
const Wt::WFormModel::Field id
Definition: Definition.h:17
const Wt::WFormModel::Field post_lot
Definition: Definition.h:28
const Wt::WFormModel::Field billto_type
Definition: Definition.h:30
const Wt::WFormModel::Field post_acc
Definition: Definition.h:29
const Wt::WFormModel::Field owner_type
Definition: Definition.h:23
const Wt::WFormModel::Field date_opened
Definition: Definition.h:18
const Wt::WFormModel::Field charge_amt_num
Definition: Definition.h:32
const Wt::WFormModel::Field owner_guid
Definition: Definition.h:24
const Wt::WFormModel::Field post_txn
Definition: Definition.h:27
const Wt::WFormModel::Field guid
Definition: Definition.h:16
const Wt::WFormModel::Field charge_amt_denom
Definition: Definition.h:33
const Wt::WFormModel::Field terms
Definition: Definition.h:25
Definition: App.h:17
Definition: guid.cpp:397
static auto surrogateIdField() -> const char *
Definition: Item.h:33
static auto versionField() -> const char *
Definition: Item.h:34
static auto invalidId() -> IdType
Definition: Item.h:32