GnuCashew ~ GnuCash Enabled Web
GCW
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 
15 InvoicesModel( const std::vector< Wt::WFormModel::Field > & _fields )
16 : Wt::Dbo::QueryModel< GCW::Dbo::Invoices::Item::Ptr >(),
17  m_fields( _fields )
18 {
20 
21 }
22 
23 auto
25 setCustomerGuid( 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 **
39 */
40 auto
42 refreshFromDisk()-> void
43 {
44  if( GCW::app()-> gnucashew_session().isOpen() )
45  {
46  Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
47 
48  if( m_customerGuid == "" )
49  {
50  auto results =
51  GCW::app()-> gnucashew_session().find< GCW::Dbo::Invoices::Item >()
52  ;
53 
54  std::cout << __FILE__ << ":" << __LINE__
55  << " " << m_customerGuid
56  << " " << results.resultList().size()
57  << std::endl;
58 
59  setQuery( results );
60  }
61 
62  else
63  {
64  auto results =
65  GCW::app()-> gnucashew_session().find< GCW::Dbo::Invoices::Item >()
66  .where( "owner_guid = ? OR owner_guid in (select guid from jobs where owner_guid = ?)" )
67 // .where( "billto_guid = ?" )
68 // .where( "owner_guid = ?" )
69  .bind( m_customerGuid )
70  .bind( m_customerGuid )
71  ;
72 
73  std::cout << __FILE__ << ":" << __LINE__
74  << " " << m_customerGuid
75  << " " << results.resultList().size()
76  << std::endl;
77 
78  setQuery( results );
79  }
80 
81  } // endif( GCW::app()-> gnucashew_session().isOpen() )
82 
83  if( m_fields.size() > 0 )
84  {
85  for( auto field : m_fields )
86  addColumn( field );
87  }
88 
89  else
90  {
91  addAllFieldsAsColumns();
92  }
93 
94  reload();
95 
96  std::cout << __FILE__ << ":" << __LINE__ << " " << rowCount() << std::endl;
97 
98 } // endGCW::Eng::InvoicesModel::refreshFromDisk()
99 
100 
101 
Invoices Class.
Definition: Item.h:86
auto setCustomerGuid(const std::string &_guid) -> void
auto refreshFromDisk() -> void
Refresh From Disk.
Definition: App.h:17
App * app()
Definition: App.cpp:67
Definition: GncLock.h:6