GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
InvoicesModel.cpp
Go to the documentation of this file.
1#line 2 "src/Eng/InvoicesModel.cpp"
2
3#include "../App.h"
4#include "InvoicesModel.h"
5
8: Wt::Dbo::QueryModel< GCW::Dbo::Invoices::Item::Ptr >()
9{
11
12} // endGCW::Eng::CustomersModel::CustomersModel()
13
15InvoicesModel( const std::vector< Wt::WFormModel::Field > & _fields )
16: Wt::Dbo::QueryModel< GCW::Dbo::Invoices::Item::Ptr >(),
17 m_fields( _fields )
18{
20
21}
22
23auto
25setCustomerGuid( const std::string & _guid )-> void
26{
27 m_customerGuid = _guid;
28
29 refreshFromDisk();
30
31} // endsetCustomerGuid( const std::string & _guid )-> void
32
33
34
35/*!
36** \brief Refresh From Disk
37**
38*/
39auto
41refreshFromDisk()-> void
42{
43 if( GCW::app()-> gnucashew_session().isOpen() )
44 {
45 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
46
47 if( m_customerGuid == "" )
48 {
49 auto results =
50 GCW::app()-> gnucashew_session().find< GCW::Dbo::Invoices::Item >()
51 ;
52
53 std::cout << __FILE__ << ":" << __LINE__
54 << " " << m_customerGuid
55 << " " << results.resultList().size()
56 << std::endl;
57
58 setQuery( results );
59 }
60
61 else
62 {
63 auto results =
64 GCW::app()-> gnucashew_session().find< GCW::Dbo::Invoices::Item >()
65 .where( "owner_guid = ? OR owner_guid in (select guid from jobs where owner_guid = ?)" )
66// .where( "billto_guid = ?" )
67// .where( "owner_guid = ?" )
68 .bind( m_customerGuid )
69 .bind( m_customerGuid )
70 ;
71
72 std::cout << __FILE__ << ":" << __LINE__
73 << " " << m_customerGuid
74 << " " << results.resultList().size()
75 << std::endl;
76
77 setQuery( results );
78 }
79
80 } // endif( GCW::app()-> gnucashew_session().isOpen() )
81
82 if( m_fields.size() > 0 )
83 {
84 for( auto field : m_fields )
85 addColumn( field );
86 }
87
88 else
89 {
90 addAllFieldsAsColumns();
91 }
92
93 reload();
94
95 std::cout << __FILE__ << ":" << __LINE__ << " " << rowCount() << std::endl;
96
97} // endGCW::Eng::InvoicesModel::refreshFromDisk()
98
99
100
auto setCustomerGuid(const std::string &_guid) -> void
auto refreshFromDisk() -> void
Refresh From Disk.
Definition App.h:18
App * app()
Definition App.cpp:75