GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Dbo/BillTerms/Item.h
Go to the documentation of this file.
1#line 2 "src/Dbo/BillTermis/Item.h"
2
3#ifndef __DBO_BILLTERMS_ITEM_H___
4#define __DBO_BILLTERMS_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 BillTerms {
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::BillTerms::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::BillTerms::Item > : Wt::Dbo::dbo_traits< GCW::Dbo::BillTerms::Item > {};
38
39/*
40** Now we can start building our class!
41**
42*/
43namespace GCW {
44 namespace Dbo {
45 namespace BillTerms {
46
47/*!
48** \brief BillTerms Class
49**
50**
51** \dot
52** digraph BillTermsMap
53** {
54** BillTermsItem;
55** }
56** \enddot
57**
58** \par Native GnuCash BillTerms Sqlite Schema
59** \code
60** CREATE TABLE billterms
61** (
62** guid text(32) PRIMARY KEY NOT NULL,
63** name text(2048) NOT NULL,
64** description text(2048) NOT NULL,
65** refcount integer NOT NULL,
66** invisible integer NOT NULL,
67** parent text(32),
68** type text(2048) NOT NULL,
69** duedays integer,
70** discountdays integer,
71** discount_num bigint,
72** discount_denom bigint,
73** cutoff integer
74** );
75** \endcode
76**
77*/
78class Item
79: public GCW::Dbo::BaseItem< Item >
80{
81 public:
82
83 /*!
84 ** \brief ctor
85 */
86 Item(){}
87
88 /*!
89 ** \brief ctor with guid
90 */
91 Item( const std::string & _guid ): m_guid( _guid ){}
92
93 /*!
94 ** \brief GUID
95 **
96 ** Return account 'guid' value - the primary key for the account
97 */
98 auto guid() const-> const std::string & { return m_guid; }
99
100 template< class Action > auto
101 persist( Action & action )-> void
102 {
103 Wt::Dbo::id ( action, m_guid , GCW::Dbo::BillTerms::Field::guid , 32 ); // text(32) PRIMARY KEY NOT NULL,
104 Wt::Dbo::field( action, m_name , GCW::Dbo::BillTerms::Field::name , 32 ); // text(2048) NOT NULL,
105 Wt::Dbo::field( action, m_description , GCW::Dbo::BillTerms::Field::description , 32 ); // text(2048) NOT NULL,
106 Wt::Dbo::field( action, m_refcount , GCW::Dbo::BillTerms::Field::refcount ); // integer NOT NULL,
107 Wt::Dbo::field( action, m_invisible , GCW::Dbo::BillTerms::Field::invisible ); // integer NOT NULL,
108 Wt::Dbo::field( action, m_parent , GCW::Dbo::BillTerms::Field::parent , 32 ); // text(32),
109 Wt::Dbo::field( action, m_type , GCW::Dbo::BillTerms::Field::type , 32 ); // text(2048) NOT NULL,
115
116 } // endpersist( Action & action )-> void
117
118 private:
119
120 std::string m_guid ; // text(32) PRIMARY KEY NOT NULL,
121 std::string m_name ; // text(2048) NOT NULL,
122 std::string m_description ; // text(2048) NOT NULL,
123 int m_refcount ; // integer NOT NULL,
124 int m_invisible ; // integer NOT NULL,
125 std::string m_parent ; // text(32),
126 std::string m_type ; // text(2048) NOT NULL,
127 int m_duedays ; // integer,
128 int m_discountdays ; // integer,
129 int m_discount_num ; // bigint,
130 int m_discount_denom ; // bigint,
131 int m_cutoff ; // integer
132
133}; // endclass Item
134
135 } // endnamespace BillTerms {
136 } // endnamespace Dbo {
137} // endnamespace GCW {
138
139#endif // __DBO_BILLTERMS_ITEM_H___
140
auto persist(Action &action) -> void
auto guid() const -> const std::string &
GUID.
Item(const std::string &_guid)
ctor with 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 description
Definition BillTerms.cpp:12
const Wt::WFormModel::Field refcount
Definition BillTerms.cpp:13
const Wt::WFormModel::Field discount_num
Definition BillTerms.cpp:19
const Wt::WFormModel::Field cutoff
Definition BillTerms.cpp:21
const Wt::WFormModel::Field parent
Definition BillTerms.cpp:15
const Wt::WFormModel::Field guid
Definition BillTerms.cpp:10
const Wt::WFormModel::Field discount_denom
Definition BillTerms.cpp:20
const Wt::WFormModel::Field discountdays
Definition BillTerms.cpp:18
const Wt::WFormModel::Field invisible
Definition BillTerms.cpp:14
const Wt::WFormModel::Field name
Definition BillTerms.cpp:11
const Wt::WFormModel::Field type
Definition BillTerms.cpp:16
const Wt::WFormModel::Field duedays
Definition BillTerms.cpp:17
Definition App.h:18