File: wocluster.h

package info (click to toggle)
postbooks 4.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 112,660 kB
  • ctags: 22,890
  • sloc: cpp: 310,358; sh: 607; xml: 214; python: 140; awk: 104; makefile: 50
file content (300 lines) | stat: -rw-r--r-- 8,616 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
/*
 * This file is part of the xTuple ERP: PostBooks Edition, a free and
 * open source Enterprise Resource Planning software suite,
 * Copyright (c) 1999-2016 by OpenMFG LLC, d/b/a xTuple.
 * It is licensed to you under the Common Public Attribution License
 * version 1.0, the full text of which (including xTuple-specific Exhibits)
 * is available at www.xtuple.com/CPAL.  By using this software, you agree
 * to be bound by its terms.
 */

#ifndef woCluster_h
#define woCluster_h

#include "widgets.h"

#include <QDate>

#include <xsqlquery.h>
#include "virtualCluster.h"
#include "ui_womatlcluster.h"

class QLabel;
class QPushButton;
class WoCluster;
class XComboBox;
class WarehouseGroup;

//  Possible Work Order Status
#define cWoOpen     WoLineEdit::Open
#define cWoExploded WoLineEdit::Exploded
#define cWoIssued   WoLineEdit::Issued
#define cWoReleased WoLineEdit::Released
#define cWoClosed   WoLineEdit::Closed

class QScriptEngine;

void setupWoCluster(QScriptEngine *engine);

class XTUPLEWIDGETS_EXPORT woList : public VirtualList
{
    Q_OBJECT

public:
    woList(QWidget*, Qt::WindowFlags = 0);

public slots:
    virtual void set(const ParameterList & pParams);
    virtual void sFillList();

private:
    int _woid;
    int _type;
    WarehouseGroup* _warehouse;

};

class XTUPLEWIDGETS_EXPORT woSearch : public VirtualSearch
{
    Q_OBJECT

public:
    woSearch(QWidget*, Qt::WindowFlags = 0);

public slots:
    void set(const ParameterList & pParams);
    void sFillList();

private:
    int _woid;
    int _type;
    WarehouseGroup* _warehouse;
};


class XTUPLEWIDGETS_EXPORT WoLineEdit : public VirtualClusterLineEdit
{
  Q_OBJECT

  Q_ENUMS(WoStatus)

  Q_PROPERTY(int type READ type WRITE setType DESIGNABLE false)

friend class WoCluster;

  public:
    WoLineEdit(QWidget *, const char * = 0);
    WoLineEdit(int, QWidget *, const char * = 0);

    enum WoStatus {
      Open      = 0x01,
      Exploded  = 0x02,
      Issued    = 0x04,
      Released  = 0x08,
      Closed    = 0x10
    };

    Q_INVOKABLE inline int     currentWarehouse() const       { return _currentWarehouseid;  }
    Q_INVOKABLE inline QString method() const                 { return _method;              }
    Q_INVOKABLE void           setType(int pWoType);
    Q_INVOKABLE void           setWarehouse(int pWarehouseid);
    Q_INVOKABLE inline int     type() const                   { return _woType;              }
    Q_INVOKABLE inline int     warehouse() const              { return _warehouseid;         }

  public slots:
    virtual void clear();
    virtual void silentSetId(const int);
    virtual void sList();
    virtual void sSearch();

  private:
    void init();
    void buildExtraClause();

    int     _currentWarehouseid;
    int     _woType;
    int     _warehouseid;
    QChar   _status;
    double  _qtyOrdered;
    double  _qtyReceived;
    QString _method;

  protected:
    woList* listFactory();
    woSearch* searchFactory();

  signals:
    void newItemid(int);
    void warehouseChanged(const QString &);
    void itemNumberChanged(const QString &);
    void uomChanged(const QString &);
    void itemDescrip1Changed(const QString &);
    void itemDescrip2Changed(const QString &);
    void startDateChanged(const QDate &);
    void dueDateChanged(const QDate &);
    void qtyOrderedChanged(const double);
    void qtyReceivedChanged(const double);
    void qtyBalanceChanged(const double);
    void statusChanged(const QString &);
    void methodChanged(const QString &);
};

class XTUPLEWIDGETS_EXPORT WoCluster : public QWidget
{
  Q_OBJECT
  Q_PROPERTY(QString label          READ label          WRITE setLabel)
  Q_PROPERTY(QString fieldName      READ fieldName      WRITE setFieldName)
  Q_PROPERTY(QString number         READ woNumber       WRITE setWoNumber       DESIGNABLE false)
  Q_PROPERTY(QString defaultNumber  READ defaultNumber                          DESIGNABLE false)
  Q_PROPERTY(int     type           READ type           WRITE setType           DESIGNABLE false)
  
  public:
    WoCluster(QWidget *, const char * = 0);
    WoCluster(int, QWidget *, const char * = 0);

    QString  defaultNumber()    { return QString();          }
    QString  fieldName()        { return _fieldName;         }
    QString  woNumber() const;

    virtual Qt::Orientation orientation();
    virtual void setOrientation(Qt::Orientation orientation);

    virtual QString label();
    virtual void setLabel(const QString& p);

    inline void setType(int pWoType)           { _woNumber->setType(pWoType);           }
    inline int  type() const                   { return _woNumber->_woType;              }
    inline void setWarehouse(int pWarehouseid) { _woNumber->setWarehouse(pWarehouseid); }
    Q_INVOKABLE inline int currentWarehouse() const { return _woNumber->currentWarehouse(); }
    Q_INVOKABLE inline int id() const          { return _woNumber->_id;                  }
    Q_INVOKABLE inline bool isValid() const    { return _woNumber->_valid;               }
    Q_INVOKABLE inline char status() const     { return _woNumber->_status.toLatin1();    }
    Q_INVOKABLE inline QString method() const     { return _woNumber->method();          }
    Q_INVOKABLE inline double qtyOrdered() const { return _woNumber->_qtyOrdered;        }
    Q_INVOKABLE inline double qtyReceived() const { return _woNumber->_qtyReceived;      }
    Q_INVOKABLE inline double qtyBalance() const
    {
      if (_woNumber->_qtyOrdered <= _woNumber->_qtyReceived)
        return 0;
      else
        return (_woNumber->_qtyOrdered - _woNumber->_qtyReceived);
    }
    Q_INVOKABLE inline int    warehouse() const   { return _woNumber->warehouse();       }

  public slots:
    void setDataWidgetMap(XDataWidgetMapper* m);
    void setFieldName(const QString& name)        { _fieldName = name; }
    void setId(int);
    void setReadOnly(bool);
    void setWoNumber(const QString& number);

  private:
    void constructor();

    WoLineEdit  *_woNumber;
    QLabel      *_woNumberLit;
    QLabel      *_warehouse;
    QLabel      *_itemNumber;
    QLabel      *_itemNumberLit;
    QLabel      *_uom;
    QLabel      *_uomLit;
    QLabel      *_descrip1;
    QLabel      *_descrip2;
    QLabel      *_status;
    QLabel      *_statusLit;
    QLabel      *_method;
    QLabel      *_methodLit;
    QString      _fieldName;
    QHBoxLayout *_line1Layout;
    QHBoxLayout *_line2Layout;
    QHBoxLayout *_itemLayout;
    QVBoxLayout *_mainLayout;
    QHBoxLayout *_statusLayout;
    QHBoxLayout *_uomLayout;
    QHBoxLayout *_warehouseLayout;
    QHBoxLayout *_woLayout;
    Qt::Orientation _orientation;

  signals:
    void newId(int);
    void newItemid(int);
    void startDateChanged(const QDate &);
    void dueDateChanged(const QDate &);
    void qtyOrderedChanged(const double &);
    void qtyReceivedChanged(const double &);
    void qtyBalanceChanged(const double &);

    void valid(bool);
};

class XTUPLEWIDGETS_EXPORT WomatlCluster : public QWidget, public Ui::WomatlCluster
{
  Q_OBJECT
  Q_PROPERTY(QString fieldName      READ fieldName      WRITE setFieldName)

  public:
    enum SourceTypes
    {
      WorkOrder  = 0x01,
      WoMaterial = 0x02,
      Wooper     = 0x04
    };

    enum IssueTypes
    {
      Pull  = 0x01,
      Push  = 0x02,
      Mixed = 0x04
    };

    WomatlCluster(QWidget *, const char * = 0);
    WomatlCluster(WoCluster *, QWidget *, const char * = 0);

    void setReadOnly(bool);

    Q_INVOKABLE int id()             { return _id;       }
    Q_INVOKABLE int woid()           { return _woid;     }
    Q_INVOKABLE bool isValid()       { return _valid;    }
    Q_INVOKABLE double qtyRequired() { return _required; }
    Q_INVOKABLE double qtyIssued()   { return _issued;   }
    inline QString fieldName()  { return _fieldName;}

  signals:
    void newId(int);
    void valid(bool);
    void newQtyRequired(const double);
    void newQtyIssued(const double);
    void newQtyScrappedFromWIP(const double);

  public slots:
    void setDataWidgetMap(XDataWidgetMapper* m);
    void setFieldName(const QString& name)        { _fieldName = name; }
    void setId(int);
    void setType(int);
    void setWooperid(int);
    void setWoid(int);
    void sPopulateInfo(int);
    void sRefresh();

  protected slots:
    virtual void languageChange();

  private:
    void constructor();

    XSqlQuery _womatl;
    int      _id;
    int      _woid;
    int      _source;
    int      _type;
    int      _sourceId;
    int      _sense;
    bool     _valid;
    double   _required;
    double   _issued;
    QString  _fieldName;
};


#endif