1
package
hudsonfog.voc.model;
2
3
import
com.fogx.webdav.DavResource;
4
import
com.fogx.webdav.DavClass;
5
import
com.fogx.webdav.DavBean;
6
import
com.fogx.webdav.DavProperty;
7
import
static
com.fogx.webdav.DavProperty.*;
8
import
com.fogx.webdav.packages.DavBeanPackage;
9
import
com.fogx.webdav.util.DavResourceSupport;
10
import
com.fogx.webdav.util.UrlUtil;
11
import
java.util.Date;
12
import
java.util.Map;
13
import
java.util.HashMap;
14
import
java.util.List;
15
import
java.util.Collections;
16
import
java.util.Arrays;
17
18
import
hudsonfog.voc.model.company
.*;
19
import
hudsonfog.voc.model.humanResources
.*;
20
import
hudsonfog.voc.model.products
.*;
21
import
hudsonfog.voc.model.accounting
.*;
22
import
hudsonfog.voc.system.behavior
.*;
23
import
hudsonfog.voc.system.parse
.*;
24
import
hudsonfog.voc.model.work
.*;
25
import
hudsonfog.voc.aspects.commerce
.*;
26
import
hudsonfog.voc.system.primitiveTypes
.*;
27
import
hudsonfog.voc.model.delivery
.*;
28
import
hudsonfog.voc.model.orders
.*;
29
import
hudsonfog.voc.model.top
.*;
30
import
hudsonfog.voc.system.security
.*;
31
import
hudsonfog.voc.system.XMLSchema
.*;
32
33
import
hudsonfog.voc.system.fog
.*;
34
35
36
public
abstract
class
accounting {
37
38
public
static
class
GeneralLedgerAccount {
39
@_autoincrement
40
@_readOnly
41
@
k
public
Integer id;
42
@
r
public
GlAccountType accountType;
43
@_maxSize(
40
)
44
@
r
public
String name;
45
@_backLink(
"GLAccount"
)
46
public
OrganizationGlAccount[] organizationAccounts;
47
@_maxSize(
1000
)
48
public
String description;
49
}
50
51
public
static
enum GlAccountType {
52
@_label(
"Accounts Receivable"
) AccountsReceivable, Revenue, Cash, Asset, @_label(
"Capital Gain"
) CapitalGain, Depreciation, @_label(
"Accumulated Depreciation"
) AccumulatedDepreciation, @_label(
"Accumulated Depreciation for Equipment"
) AccumulatedDepreciationForEquipment, @_label(
"Discount Expense"
) DiscountExpense;
53
}
54
55
@DavClass._label(
"Organization GL Account"
)
56
public
static
class
OrganizationGlAccount {
57
@
k
public
InternalOrganization organization;
58
@
k
public
GeneralLedgerAccount GLAccount;
59
@_backLink(
"account"
)
60
@
r
public
TransactionDetail[] postedDetails;
61
@
r
public
Long fromDate;
62
public
Long thruDate;
63
}
64
65
public
static
class
AccountingPeriod {
66
@_readOnly
67
@
k
public
Integer id;
68
@
r
public
InternalOrganization organization;
69
@
r
public
AccountingPeriodType type;
70
@_maxSize(
10
)
71
@
r
public
String fromDate;
72
@_maxSize(
10
)
73
public
String thruDate;
74
}
75
76
public
static
enum AccountingPeriodType {
77
Quarter, Year;
78
}
79
80
public
static
class
AccountingTransaction
implements
Sealable {
81
@_autoincrement
82
@_readOnly
83
@
k
public
Integer id;
84
@_readOnly
85
@_sortAscending(
false
)
86
@_onCreate
87
public
dateTime date = writeJS(
"date == null ? new Date() : date"
);
88
@_maxSize(
200
)
89
public
String description;
90
@_makeTotal
91
@_min(
0
)
92
@
r
public
Money amount;
93
@_backLink(
"transaction"
)
94
public
TransactionDetail[] details;
95
@_readOnly
96
@_containerMember
97
@_styleSheet(
"font-size:1.5em;"
)
98
public
Payable inRelationTo;
99
@_readOnly
100
@_displayNameElm
101
public
Employee enteredBy = writeJS(
"enteredBy ? enteredBy : getContact()"
);
102
@_readOnly
103
@c
public
Boolean sealed;
//*? transaction gets sealed upon submit and can not be changed later on
104
}
105
106
public
static
class
InternalTransaction
extends
AccountingTransaction {
107
@
k
@s
public
Integer id;
108
@
r
public
InternalOrganization fromOrganization;
109
}
110
111
public
static
enum InternalTransactionType {
112
Depreciation, Capitalization, Amortization;
113
}
114
115
public
static
class
Depreciation
extends
InternalTransaction {
116
@
k
@s
public
Integer id;
117
@
r
public
FixedAsset fixedAsset;
118
}
119
120
public
static
class
ExternalTransaction
extends
AccountingTransaction
implements
BrowserState {
121
@
k
@s
public
Integer id;
122
@c
public
dateTime clientTime;
//* time on the machine from which request arrived
123
}
124
125
/**
126
* this clas is a base class for all transactions that require posting to current register shift
127
*/
128
public
static
interface
RegisterShiftTransaction {
129
@_readOnly
130
@_immutable
131
@_onCreate
132
public
CashRegister register = writeJS(
"makeUri('register=' + getRequest().getRemoteHost())"
);
//* cash register
133
@_readOnly
134
@_notifyContainer
135
@_onCreate
136
public
RegisterShift shift = writeJS(
"getShift()"
);
137
@_avoidDisplaying
// need this prop only to properly calc dependencies for caching
138
public
RegisterShift currentShift = formula(
"register.currentShift"
);
139
}
140
141
/*
142
class Payment extends ExternalTransaction {
143
#int id :: id;
144
// *PayType payType;
145
// *date effectiveDate; // commented out - assume this will be used in billing for scheduled payments only
146
// *int paymentReferenceNumber;
147
// string(240) comment;
148
}
149
*/
150
@DavClass._largeIcon(
"icons/classes/CashRegister-large.gif"
)
151
@DavClass._viewCols(
"register, currentShift, shifts"
)
152
@DavClass._icon(
"icons/classes/CashRegister.gif"
)
153
public
static
class
CashRegister {
154
@_maxSize(
150
)
155
@_displayNameElm
156
@_onCreate
157
@
k
public
String register = writeJS(
"getRequest().getRemoteHost()"
);
//* register's network address
158
@_readOnly
159
@_sortAscending(
false
)
160
@_backLink(
"register"
)
161
public
RegisterShift[] shifts;
162
@_readOnly
163
public
RegisterShift currentShift;
164
}
165
166
public
static
class
CashTransaction
extends
ExternalTransaction
implements
RegisterShiftTransaction {
167
@
k
@s
public
Integer id;
168
@c
public
CashRegister register;
//* cash register
169
@c
public
RegisterShift shift;
170
@c
public
RegisterShift currentShift;
171
@_onCreate
172
@s
public
Boolean sealed = writeJS(
"true"
);
//*? transaction gets sealed upon submit and can not be changed later on
173
}
174
175
/**
176
* Credit Card transaction
177
*/
178
@DavClass._largeIcon(
"icons/classes/CreditCard-large.gif"
)
179
@DavClass._icon(
"icons/classes/CreditCard.gif"
)
180
public
static
class
CardTransaction
extends
ExternalTransaction
implements
RegisterShiftTransaction, CreditCard, CreditCardResponse {
181
@
k
@s
public
Integer id;
182
@c
public
creditCardNumber number;
//* card number
183
@c
public
String cardholderVerificationCode;
//*? 3-digit code located on the back of card next to the account number on signature panel. <br> For American Express it is a 4-digit code located on the front of the card, above on left of account number.
184
@c
public
expirationDate expirationDate;
185
@_onCreate
186
@c
public
String nameOnCard = writeJS(
"nameOnCard ? nameOnCard : inRelationTo && payee ? payee.firstName + ' ' + payee.lastName : null"
);
187
@_readOnly
188
public
Contact payee = writeJS(
"getThisChange().inRelationTo ? inRelationTo.payee : payee"
);
189
@c
public
String track1;
//* track1 on the (magnetic) card
190
@c
public
String track2;
//* track2 on the (magnetic) card
191
@_readOnly
192
@_makeTotal
193
@s
public
Money amount;
194
@_makeTotal
195
@_onCreate
196
@c
public
Money chargeAmount = writeJS(
"chargeAmount ? chargeAmount : inRelationTo.amount > 0 ? inRelationTo.amount : null"
);
//* amount of money that will be charged on a credit card
197
@_onCreate
198
@c
public
Money chargeTaxAmount = writeJS(
"chargeTaxAmount ? chargeTaxAmount : inRelationTo.taxAmount"
);
199
@c
public
Integer responseCode;
//* this code and reason code are important if transaction failed (assigned by card processor)
200
@c
public
Integer reasonCode;
//* this code is important if transaction failed (assigned by card processor)
201
@c
public
String reasonText;
//* descripton of the transaction status (assigned by card processor)
202
@c
public
String authorizationCode;
//* authorization code of the approved transaction (assigned by card processor)
203
@c
public
String AVSCode;
204
@c
public
String cardCodeResponse;
//* (assigned by card processor)
205
@c
public
String transactionId;
//* unique transaction id (assigned by card processor)
206
@c
public
String terminal;
207
@c
public
Boolean transactionFailed;
//* true if this transaction did not go through. See Reason Text for details.
208
@h@s
public
String description;
209
@_backLink(
"transaction"
)
210
@h@s
public
TransactionDetail[] details;
211
@c
public
CashRegister register;
//* cash register
212
@c
public
RegisterShift shift;
213
@c
public
RegisterShift currentShift;
214
@_onCreate
215
@s
public
Boolean sealed = writeJS(
"true"
);
216
}
217
218
/**
219
* Authorization for a card payment checks the card and the availability of funds on it.
220
*/
221
@DavClass._viewCols(
"id, inRelationTo, date, transactionFailed, authorizationAmount, paymentAmount, wasVoided"
)
222
@DavClass._largeIcon(
"icons/classes/CreditCard-large.gif"
)
223
@DavClass._icon(
"icons/classes/CreditCard.gif"
)
224
public
static
class
CardAuthorization
extends
CardTransaction {
225
@
k
@s
public
Integer id;
226
@_backLink(
"priorAuthorization"
)
227
@_notSealed
228
public
CreditCardPayment[] payment;
//* actual payment based on this authorization
229
@_backLink(
"voidedTransaction"
)
230
@_notSealed
231
public
CreditCardVoidForAuth[] voided;
232
@_makeTotal
233
@_readOnly
234
@_oldName(
"totalPayed"
)
235
@_notSealed
236
public
Money paymentAmount = writeJS(
"getThisChange().payment ? payment.SUM('amount') : paymentAmount"
);
237
@_readOnly
238
@_notSealed
239
public
Boolean wasVoided;
240
@_subPropertyOf(
"chargeAmount"
)
241
@s
public
Money authorizationAmount;
242
}
243
244
public
static
class
CardAuthorizationNoCP
extends
CardAuthorization
implements
CardNotPresent {
245
@
k
@s
public
Integer id;
246
}
247
248
/**
249
* A credit card payment. May have an optional prior authorization.
250
*/
251
@DavClass._viewCols(
"id, inRelationTo, date, priorAuthorization, chargeAmount, amount, transactionFailed, wasVoided, returned, returnedAmount"
)
252
public
static
class
CreditCardPayment
extends
CardTransaction
implements
CreditCardResponse {
253
@
k
@s
public
Integer id;
254
@_readOnly
255
@_notifyContainer
256
public
CardAuthorization priorAuthorization;
//* a prior authorization for this payment
257
@c
public
dateTime processed;
258
@_backLink(
"voidedTransaction"
)
259
@_notSealed
260
public
CreditCardVoid[] voided;
261
@_backLink(
"creditForTransaction"
)
262
@_notSealed
263
public
CreditCardReturn[] returned;
//* returns for this transaction
264
@_makeTotal
265
@_readOnly
266
@_oldName(
"totalReturned"
)
267
@_notSealed
268
public
Money returnedAmount = writeJS(
"getThisChange().returned ? returned.SUM('amount') : returnedAmount"
);
269
@_readOnly
270
@_notSealed
271
public
Boolean wasVoided;
272
@_makeTotal
273
@_readOnly
274
@_notSealed
275
public
Money voidedAmount = writeJS(
"getThisChange().voided ? voided.SUM('amount') : voidedAmount"
);
276
@s
public
Money chargeAmount = writeJS(
"getChargeAmount()"
);
277
@_makeTotal
278
@_readOnly
279
public
Money total;
280
}
281
282
public
static
class
CreditCardPaymentNoCP
extends
CreditCardPayment
implements
CardNotPresent {
283
@
k
@s
public
Integer id;
284
}
285
286
/**
287
* A credit card void transaction.
288
*/
289
@DavClass._largeIcon(
"icons/classes/CreditCardVoid-large.gif"
)
290
@DavClass._viewCols(
"id, inRelationTo, date, voidedTransaction, transactionFailed, voidedAmount"
)
291
@DavClass._icon(
"icons/classes/CreditCardVoid.gif"
)
292
public
static
class
CreditCardVoid
extends
CardTransaction {
293
@
k
@s
public
Integer id;
294
@_readOnly
295
@_notifyContainer
296
@
r
public
CreditCardPayment voidedTransaction;
297
@_onCreate
298
@s
public
Payable inRelationTo = writeJS(
"inRelationTo ? inRelationTo : voidedTransaction ? voidedTransaction.inRelationTo : null"
);
299
@s
public
String description;
//*? press submit and payment trasaction will be voided
300
@h@s
public
Money chargeAmount;
301
@_readOnly
302
@_subPropertyOf(
"amount"
)
303
@s
public
Money voidedAmount;
304
@h@s
public
Money chargeTaxAmount;
305
@h@s
public
creditCardNumber number;
306
@h@s
public
String cardholderVerificationCode;
307
@h@s
public
expirationDate expirationDate;
308
@h@s
public
String nameOnCard;
309
@h@s
public
String track1;
310
@h@s
public
String track2;
311
}
312
313
public
static
class
CreditCardVoidNoCP
extends
CreditCardVoid
implements
CardNotPresent {
314
@
k
@s
public
Integer id;
315
}
316
317
/**
318
* A credit card void for credit transaction.
319
*/
320
@DavClass._largeIcon(
"icons/classes/CreditCardVoid-large.gif"
)
321
@DavClass._viewCols(
"id, inRelationTo, date, voidedTransaction, transactionFailed, voidedAmount"
)
322
@DavClass._icon(
"icons/classes/CreditCardVoid.gif"
)
323
public
static
class
CreditCardVoidForReturn
extends
CardTransaction {
324
@
k
@s
public
Integer id;
325
@_readOnly
326
@_notifyContainer
327
@
r
public
CreditCardReturn voidedTransaction;
328
@_onCreate
329
@s
public
Payable inRelationTo = writeJS(
"inRelationTo ? inRelationTo : voidedTransaction ? voidedTransaction.inRelationTo : null"
);
330
@s
public
String description;
//*? press submit and RETURN trasaction will be voided
331
@h@s
public
Money chargeAmount;
332
@_readOnly
333
@_subPropertyOf(
"amount"
)
334
@s
public
Money voidedAmount;
335
@h@s
public
Money chargeTaxAmount;
336
@h@s
public
creditCardNumber number;
337
@h@s
public
String cardholderVerificationCode;
338
@h@s
public
expirationDate expirationDate;
339
@h@s
public
String nameOnCard;
340
@h@s
public
String track1;
341
@h@s
public
String track2;
342
}
343
344
public
static
class
CreditCardVoidForReturnNoCP
extends
CreditCardVoidForReturn
implements
CardNotPresent {
345
@
k
@s
public
Integer id;
346
}
347
348
/**
349
* A credit card void for Authorization transaction.
350
*/
351
@DavClass._viewCols(
"id, inRelationTo, date, voidedTransaction, transactionFailed, voidedAmount"
)
352
@DavClass._largeIcon(
"icons/classes/CreditCardVoid-large.gif"
)
353
@DavClass._icon(
"icons/classes/CreditCardVoid.gif"
)
354
public
static
class
CreditCardVoidForAuth
extends
CardTransaction {
355
@
k
@s
public
Integer id;
356
@_readOnly
357
@_notifyContainer
358
@
r
public
CardAuthorization voidedTransaction;
359
@_onCreate
360
@s
public
Payable inRelationTo = writeJS(
"inRelationTo ? inRelationTo : voidedTransaction ? voidedTransaction.inRelationTo : null"
);
361
@s
public
String description;
//*? press submit and AUTHORIZATION will be voided
362
@h@s
public
Money chargeAmount;
363
@_readOnly
364
@_subPropertyOf(
"amount"
)
365
@s
public
Money voidedAmount;
366
@h@s
public
Money chargeTaxAmount;
367
@h@s
public
creditCardNumber number;
368
@h@s
public
String cardholderVerificationCode;
369
@h@s
public
expirationDate expirationDate;
370
@h@s
public
String nameOnCard;
371
@h@s
public
String track1;
372
@h@s
public
String track2;
373
}
374
375
public
static
class
CreditCardVoidForAuthNoCP
extends
CreditCardVoidForAuth
implements
CardNotPresent {
376
@
k
@s
public
Integer id;
377
}
378
379
/**
380
* A credit card credit/refund transaction.
381
*/
382
@DavClass._largeIcon(
"icons/classes/CreditCardReturn-large.gif"
)
383
@DavClass._viewCols(
"id, inRelationTo, date, creditForTransaction, transactionFailed, amountToReturn, amount"
)
384
@DavClass._icon(
"icons/classes/CreditCardReturn.gif"
)
385
public
static
class
CreditCardReturn
extends
CardTransaction
implements
CreditCardResponse {
386
@
k
@s
public
Integer id;
387
@_readOnly
388
@_notifyContainer
389
@
r
public
CreditCardPayment creditForTransaction;
390
@_readOnly
391
@s
public
creditCardNumber number;
392
@_readOnly
393
@s
public
String cardholderVerificationCode;
394
@_readOnly
395
@s
public
expirationDate expirationDate;
396
@_readOnly
397
@s
public
String nameOnCard;
398
@_onCreate
399
@s
public
Payable inRelationTo = writeJS(
"inRelationTo ? inRelationTo : creditForTransaction ? creditForTransaction.inRelationTo : null"
);
400
@_subPropertyOf(
"chargeAmount"
)
401
@_onCreate
402
@s
public
Money amountToReturn = writeJS(
"amountToReturn ? amountToReturn : creditForTransaction.amount - creditForTransaction.returnedAmount"
);
403
@_readOnly
404
@_subPropertyOf(
"amount"
)
405
@s
public
Money returnedAmount;
406
@h@s
public
Money chargeTaxAmount;
407
@c
public
dateTime processed;
408
@_backLink(
"voidedTransaction"
)
409
@_notSealed
410
public
CreditCardVoidForReturn[] voided;
411
@_readOnly
412
@_notSealed
413
public
Boolean wasVoided;
414
}
415
416
public
static
class
CreditCardReturnNoCP
extends
CreditCardReturn
implements
CardNotPresent {
417
@
k
@s
public
Integer id;
418
}
419
420
/**
421
* Payment by cash
422
*/
423
@DavClass._viewCols(
"id, inRelationTo, date, amountDue, returned, returnedAmount, total"
)
424
@DavClass._largeIcon(
"icons/classes/Cash-large.gif"
)
425
@DavClass._icon(
"icons/classes/Cash.gif"
)
426
public
static
class
CashPayment
extends
CashTransaction {
427
@
k
@s
public
Integer id;
428
@_min(
0
)
429
@
r
public
Money tendered;
//* cash received from customer
430
@_min(
0
)
431
@_onCreate
432
@_subPropertyOf(
"amount"
)
433
@_displayNameElm
434
@
r
@s
public
Money amountDue = writeJS(
"getAmount()"
);
//* cash amount due
435
@_styleSheet(
"font-size:2em;"
)
436
public
Money change = formulaJS(
"tendered && tendered >= amount ? tendered - amount : null"
);
//* amount of change that must be returned
437
@_maxCardinality(
1
)
438
@_backLink(
"returnForTransaction"
)
439
@_notSealed
440
public
CashReturn[] returned;
441
@_readOnly
442
@_makeTotal
443
@_oldName(
"totalReturned"
)
444
@_notSealed
445
public
Money returnedAmount = writeJS(
"getThisChange().returned ? returned.SUM('amount') : returnedAmount"
);
446
@_readOnly
447
@_makeTotal
448
@_notSealed
449
public
Money total = writeJS(
"getThisChange().returned ? amountDue - returnedAmount : (getThisChange().amountDue ? amountDue : total)"
);
450
}
451
452
/**
453
* Cash returned
454
*/
455
@DavClass._viewCols(
"id, inRelationTo, returnForTransaction, date, amount"
)
456
@DavClass._largeIcon(
"icons/classes/CashVoid-large.gif"
)
457
@DavClass._icon(
"icons/classes/CashVoid.gif"
)
458
public
static
class
CashReturn
extends
CashTransaction {
459
@
k
@s
public
Integer id;
460
@_readOnly
461
@_notifyContainer
462
@
r
public
CashPayment returnForTransaction;
463
@_onCreate
464
@s
public
Payable inRelationTo = writeJS(
"inRelationTo ? inRelationTo : returnForTransaction ? returnForTransaction.inRelationTo : null"
);
465
@_oldName(
"amountReturned"
)
466
@_onCreate
467
@_displayNameElm
468
@_label(
"amountReturned"
)
469
@s
public
Money amount = writeJS(
"getAmount()"
);
470
@_sample(
"1"
)
471
@_onCreate
472
public
Money amountLeft = writeJS(
"returnForTransaction.returnedAmount != null ? returnForTransaction.amountDue - returnForTransaction.returnedAmount : returnForTransaction.amountDue"
);
473
}
474
475
/**
476
* Exchange of money
477
*/
478
@DavClass._largeIcon(
"icons/classes/CashExchange-large.gif"
)
479
@DavClass._icon(
"icons/classes/CashExchange.gif"
)
480
public
static
class
CashExchange
extends
CashTransaction {
481
@
k
@s
public
Integer id;
482
public
Money tendered;
//* cash received
483
public
Money needed;
//* amount customer requested
484
@_styleSheet(
"font-size:2em;"
)
485
public
Money change = formulaJS(
"tendered - needed"
);
//* amount of change that must be returned
486
@_readOnly
487
@s
public
Money amount = writeJS(
"null"
);
488
}
489
490
/**
491
* Taking money from the cash register
492
*/
493
@DavClass._largeIcon(
"icons/classes/CashToEmployee-large.gif"
)
494
@DavClass._icon(
"icons/classes/CashToEmployee.gif"
)
495
public
static
class
CashToEmployee
extends
CashTransaction {
496
@
k
@s
public
Integer id;
497
@_styleSheet(
"font-size:2em;"
)
498
@s
public
Money amount;
//* amount of cash taken from register
499
}
500
501
/**
502
* Depositing money to the cash register
503
*/
504
@DavClass._largeIcon(
"icons/classes/CashFromEmployee-large.gif"
)
505
@DavClass._icon(
"icons/classes/CashFromEmployee.gif"
)
506
public
static
class
CashFromEmployee
extends
CashTransaction {
507
@
k
@s
public
Integer id;
508
@_styleSheet(
"font-size:2em;"
)
509
@s
public
Money amount;
//* amount of cash returned to register
510
}
511
512
/**
513
* Cash register requires counting cash when changing shifts.
514
*/
515
@DavClass._nmbGroupColsInEditMode(
2
)
516
@DavClass._largeIcon(
"icons/classes/CashCount-large.gif"
)
517
@DavClass._viewCols(
"register, openingBalance, expectedCashInRegister, totalInRegister, cardsTotal, cashAndCardsTotal, managersAdjustment, timeShiftStarted, timeShiftClosed, openedBy, countedBy, closedBy, status"
)
518
@DavClass._icon(
"icons/classes/CashCount.gif"
)
519
public
static
class
RegisterShift
extends
CashTransaction {
520
@_avoidDisplaying
521
@
k
@s
public
Integer id;
522
@_label(
"General info"
)
523
@_propertyGroupList(
"employeeSecretCode, employeesWithCode, employee, openingBalance, status, managersAdjustment, managersAdjustmentNotes, sealed, closingNotes"
)
524
@_abstract
525
@_propertyGroup(
"true"
)
526
public
Boolean group1;
527
@_label(
"Employee's secret code"
)
528
@_maxSize(
25
)
529
@_parameter
530
@
r
public
password employeeSecretCode;
531
@_where(
"password == employeeSecretCode"
)
532
@h
public
User employeesWithCode = formulaJS(
"ungroup()"
);
533
@_displayNameElm
534
@_readOnly
535
public
Employee employee = writeJS(
"getThisChange().employeeSecretCode ? getEmployee(): employee"
);
536
@_immutable
537
@
r
public
Money openingBalance;
//* cash in the register when shift opened
538
@_readOnly
539
public
ShiftStatus status;
540
@_allowRoles(
"positionTitle==General Manager"
)
541
public
Money managersAdjustment = writeJS(
"getThisChange().managersAdjustment ? Math.round(managersAdjustment * 100) / 100 : managersAdjustment"
);
//* a sum (positive or negative) that allows to make counts meet
542
@_maxSize(
1000
)
543
@_allowRoles(
"positionTitle==General Manager"
)
544
public
String managersAdjustmentNotes;
//* explanation why adjustment was necessary
545
@_readOnly
546
@_onCreate
547
@s
public
Boolean sealed = writeJS(
"false"
);
548
@_maxSize(
1000
)
549
public
String closingNotes;
550
@_label(
"Totals"
)
551
@_propertyGroupList(
"cashPaymentsAmount, cashPaymentsReturnedAmount, cashToEmployeeAmount, cashFromEmployeeAmount, cardPaymentsAmount, cardPaymentsVoidedAmount, cardPaymentsReturnedAmount, expectedCashInRegister, cardsTotal, cashAndCardsTotal"
)
552
@_abstract
553
@_propertyGroup(
"true"
)
554
public
Boolean group2;
555
@_readOnly
556
@_backLink(
"shift"
)
557
public
CashExchange[] cashExchange;
558
@_readOnly
559
@_backLink(
"shift"
)
560
public
CashToEmployee[] cashToEmployee;
561
@_readOnly
562
@_backLink(
"shift"
)
563
public
CashFromEmployee[] cashFromEmployee;
564
@_readOnly
565
@_backLink(
"shift"
)
566
public
CashPayment[] cashPayments;
567
@_readOnly
568
@_backLink(
"shift"
)
569
public
CashReturn[] cashPaymentsReturned;
570
@_readOnly
571
@_backLink(
"shift"
)
572
public
CreditCardPayment[] cardPayments;
573
@_readOnly
574
@_backLink(
"shift"
)
575
public
CreditCardVoid[] cardPaymentsVoided;
576
@_readOnly
577
@_backLink(
"shift"
)
578
public
CreditCardReturn[] cardPaymentsReturned;
579
@_readOnly
580
@_backLink(
"shift"
)
581
public
CertificatePayment[] certificatePayments;
582
@_readOnly
583
@_backLink(
"shift"
)
584
public
CheckPayment[] checkPayments;
585
@_readOnly
586
@_makeTotal
587
@_oldName(
"cashPaymentsTotal"
)
588
public
Money cashPaymentsAmount = writeJS(
"getThisChange().cashPayments ? cashPayments.SUM('amount') : cashPaymentsAmount"
);
589
@_readOnly
590
@_oldName(
"cashPaymentsReturnedTotal"
)
591
public
Money cashPaymentsReturnedAmount = writeJS(
"getThisChange().cashPaymentsReturned ? cashPaymentsReturned.SUM('amount'): cashPaymentsReturnedAmount"
);
592
@_readOnly
593
@_oldName(
"cashToEmployeeTotal"
)
594
public
Money cashToEmployeeAmount = writeJS(
"getThisChange().cashToEmployee ? cashToEmployee.SUM('amount') : cashToEmployeeAmount"
);
595
@_readOnly
596
@_oldName(
"cashFromEmployeeTotal"
)
597
public
Money cashFromEmployeeAmount = writeJS(
"getThisChange().cashFromEmployee ? cashFromEmployee.SUM('amount') : cashFromEmployeeAmount"
);
598
@_makeTotal
599
@_readOnly
600
@_oldName(
"cardPaymentsTotal"
)
601
public
Money cardPaymentsAmount = writeJS(
"getThisChange().cardPayments ? cardPayments.SUM('amount') : cardPaymentsAmount"
);
602
@_readOnly
603
@_oldName(
"cardPaymentsVoidedTotal"
)
604
public
Money cardPaymentsVoidedAmount = writeJS(
"getThisChange().cardPaymentsVoided ? cardPaymentsVoided.SUM('amount') : cardPaymentsVoidedAmount"
);
605
@_readOnly
606
@_oldName(
"cardPaymentsReturnedTotal"
)
607
public
Money cardPaymentsReturnedAmount = writeJS(
"getThisChange().cardPaymentsReturned ? cardPaymentsReturned.SUM('amount'): cardPaymentsReturnedAmount"
);
608
@_readOnly
609
public
Money certificatePaymentsAmount = writeJS(
"getThisChange().certificatePayments ? certificatePayments.SUM('amount') : certificatePaymentsAmount"
);
610
@_readOnly
611
public
Money checkPaymentsAmount = writeJS(
"getThisChange().checkPayments ? checkPayments.SUM('amount') : checkPaymentsAmount"
);
612
@_readOnly
613
public
Money expectedCashInRegister = writeJS(
"Math.round((openingBalance + cashPaymentsAmount - cashPaymentsReturnedAmount - cashToEmployeeAmount + cashFromEmployeeAmount)*100)/100"
);
// expected cash in register (acocunted for returns and including opening balance)
614
@_readOnly
615
public
Money cardsTotal = writeJS(
"Math.round((cardPaymentsAmount - cardPaymentsReturnedAmount - cardPaymentsVoidedAmount)*100)/100"
);
// card total (acocunted for retunrs and voids)
616
@_readOnly
617
public
Money cashAndCardsTotal = writeJS(
"Math.round((expectedCashInRegister - openingBalance + cardsTotal)*100)/100"
);
//* cash and card total (accounted for returns and voids)
618
@_label(
"Bills"
)
619
@_propertyGroupList(
"singles, fives, tens, twenties, fifties, hundreds"
)
620
@_abstract
621
@_propertyGroup(
"true"
)
622
public
Boolean groupBills;
623
public
Integer singles;
624
public
Integer fives;
625
public
Integer tens;
626
public
Integer twenties;
627
public
Integer fifties;
628
public
Integer hundreds;
629
@_label(
"Coins"
)
630
@_propertyGroupList(
"pennies, nickels, dimes, quarters"
)
631
@_abstract
632
@_propertyGroup(
"true"
)
633
public
Boolean groupCoins;
634
public
Integer pennies;
635
public
Integer nickels;
636
public
Integer dimes;
637
public
Integer quarters;
638
@_label(
"Special Coins and Bills"
)
639
@_propertyGroupList(
"halfDollarCoins, dollarCoins, twoDollarBills, totalCoins, totalBills, totalInRegister, openedBy, closedBy, countedBy, amount, register, timeShiftStarted, timeShiftBeganClosing, timeShiftClosed, lastTimeDrawerOpened"
)
640
@_abstract
641
@_propertyGroup(
"true"
)
642
public
Boolean groupSpecialCoins;
643
public
Integer halfDollarCoins;
644
public
Integer dollarCoins;
645
public
Integer twoDollarBills;
646
@_readOnly
647
public
Money totalCoins = writeJS(
" Math.round(pennies + nickels * 5 + dimes * 10 + quarters * 25 + halfDollarCoins * 50 + dollarCoins * 100) / 100"
);
648
@_readOnly
649
public
Money totalBills = writeJS(
"hundreds * 100 + fifties * 50 + twenties * 20 + tens * 10 + fives * 5 + twoDollarBills * 2 + singles"
);
650
@_readOnly
651
public
Money totalInRegister = writeJS(
"totalBills + totalCoins"
);
//* physically present cash in register at the time of shift closing
652
@_subPropertyOf(
"enteredBy"
)
653
@s
public
Employee openedBy;
654
@_readOnly
655
public
Employee closedBy;
656
@_readOnly
657
public
Employee countedBy;
658
@_readOnly
659
@s
public
Money amount;
660
@_displayNameElm
661
@_containerMember
662
@_forwardLink(
"http://www.hudsonfog.com/voc/model/accounting/CashRegister/shifts"
)
663
@s
public
CashRegister register;
664
@_sortAscending(
false
)
665
@_displayNameElm
666
@_readOnly
667
public
dateTime timeShiftStarted;
668
@_readOnly
669
@_notSearchable
670
public
dateTime timeShiftBeganClosing;
671
@_readOnly
672
public
dateTime timeShiftClosed;
673
@_sortAscending(
false
)
674
@_readOnly
675
@_notSearchable
676
@_subPropertyOf(
"date"
)
677
@s
public
dateTime lastTimeDrawerOpened = writeJS(
"new Date().getTime()"
);
//* depending on status this time is: timeShiftStarted or timeShiftBeganClosing or timeShiftCLosed
678
@h@s
public
RegisterShift shift;
679
}
680
681
public
static
enum ShiftStatus {
682
Open, Counting, Closed;
683
}
684
685
/**
686
* Payment by check
687
*/
688
@DavClass._largeIcon(
"icons/classes/CheckPayment-large.gif"
)
689
@DavClass._icon(
"icons/classes/CheckPayment.gif"
)
690
public
static
class
CheckPayment
extends
ExternalTransaction
implements
RegisterShiftTransaction {
691
@
k
@s
public
Integer id;
692
@_maxSize(
50
)
693
@
r
public
String checkNumber;
694
@c
public
CashRegister register;
//* cash register
695
@c
public
RegisterShift shift;
696
@c
public
RegisterShift currentShift;
697
}
698
699
/**
700
* Gift Certificate
701
*/
702
@DavClass._largeIcon(
"icons/classes/Certificate-large.gif"
)
703
@DavClass._viewCols(
"certificateId, recipient, amount, payee, date, inRelationTo, redeemed, redemption, dateRedeemed"
)
704
@DavClass._icon(
"icons/classes/Certificate.gif"
)
705
public
static
class
Certificate
extends
ExternalTransaction {
706
@_readOnly
707
@_subPropertyOf(
"id"
)
708
@_styleSheet(
"font-size:2em;"
)
709
@
k
@s
public
Integer certificateId;
710
@
r
@s
public
Payable inRelationTo;
711
@_displayNameElm
712
@_subPropertyOf(
"description"
)
713
@s
public
String recipient;
//* person to whom this gift is given
714
@_displayNameElm
715
@
r
@s
public
Money amount;
716
@_avoidDisplaying(
false
)
717
@_subPropertyOf(
"sealed"
)
718
@s
public
Boolean redeemed;
719
@_readOnly
720
@_immutable
721
@_notSealed
722
public
CertificatePayment redemption;
723
@_readOnly
724
public
dateTime dateRedeemed = writeJS(
"getThisChange().redemption ? redemption.date: dateRedeemed"
);
725
@_readOnly
726
public
Contact payee = writeJS(
"getThisChange().inRelationTo ? inRelationTo.payee : payee"
);
727
@s
public
Employee enteredBy;
728
@_backLink(
"transaction"
)
729
@h@s
public
TransactionDetail[] details;
730
}
731
732
/**
733
* Payment by the certificate
734
*/
735
@DavClass._viewCols(
"certificate, date, certificateAmount"
)
736
@DavClass._largeIcon(
"icons/classes/CertificatePayment-large.gif"
)
737
@DavClass._icon(
"icons/classes/CertificatePayment.gif"
)
738
public
static
class
CertificatePayment
extends
ExternalTransaction
implements
RegisterShiftTransaction {
739
@
k
@s
public
Integer id;
740
@_where(
"sealed == false"
)
741
@
r
public
Certificate certificate;
742
@_subPropertyOf(
"amount"
)
743
@s
public
Money certificateAmount = writeJS(
"certificate.amount"
);
744
@_subPropertyOf(
"description"
)
745
@s
public
String notes;
746
@c
public
CashRegister register;
//* cash register
747
@c
public
RegisterShift shift;
748
@c
public
RegisterShift currentShift;
749
@_onCreate
750
@s
public
Boolean sealed = writeJS(
"true"
);
751
}
752
753
/** Obligation, like Note, Tax due, Credit memo */
754
public
static
class
Obligation
extends
ExternalTransaction {
755
@
k
@s
public
Integer id;
756
}
757
758
public
static
enum ExternalTransactionType {
759
Invoice, Note, TaxDue, CreditMemo, @_label(
"Payment Receipt for Invoices"
) PaymentReceiptForInvoices, @_label(
"Payment Receipt for Asset Sale"
) PaymentReceiptForAssetSale, @_label(
"Payment Disbursement for Purcharse Order"
) PaymentDisbursementForPurcharseOrder;
760
}
761
762
public
static
class
Disbursement
extends
ExternalTransaction {
763
@
k
@s
public
Integer id;
764
@_backLink(
"disbursement"
)
765
public
DisbursementBudgetAllocation[] bookedAgainst;
766
}
767
768
public
static
class
Receipt
extends
ExternalTransaction {
769
@
k
@s
public
dateTime date;
770
@
k
@s
public
Integer id;
771
}
772
773
public
static
enum PayType {
774
Electronic, Cash, @_label(
"Credit card"
) CreditCard, @_label(
"Certified check"
) CertifiedCheck, Check;
775
}
776
777
@DavClass._uniquePropertySet(
"transaction, seq, inRelationTo"
)
778
@DavClass._viewCols(
"seq, account, inRelationTo, amount"
)
779
public
static
class
TransactionDetail {
780
@_displayNameElm
781
@_readOnly
782
@
k
public
Integer seq;
783
@_displayNameElm
784
@
k
public
AccountingTransaction transaction;
785
@_readOnly
786
public
OrganizationGlAccount account;
787
public
DavResource inRelationTo;
// :: li.item;
788
@_makeTotal
789
@
r
public
Money amount;
790
@_readOnly
791
@_onCreate
792
public
dateTime date = writeJS(
"date ? date : new Date().getTime()"
);
793
}
794
795
public
static
class
Gratuity
extends
TransactionDetail {
796
@
k
@s
public
Integer seq;
797
@_subPropertyOf(
"transaction"
)
798
@
k
@s
public
ExternalTransaction payment;
799
}
800
801
public
static
class
Budget {
802
@_autoincrement
803
@_readOnly
804
@
k
public
Integer budgetId;
805
@_backLink(
"budget"
)
806
@
r
public
BudgetRevision[] revisions;
807
@_maxSize(
240
)
808
public
String description;
809
}
810
811
public
static
class
BudgetRevision {
812
@_readOnly
813
@
k
public
Integer seq;
814
@
k
public
Budget budget;
815
@_maxSize(
2000
)
816
@
r
public
String reason;
817
@_backLink(
"revision"
)
818
@
r
public
BudgetLineItem[] items;
819
public
BudgetRevisionStatus status;
820
}
821
822
public
static
class
BudgetLineItem {
823
@_readOnly
824
@
k
public
Integer seq;
825
@
k
public
BudgetRevision revision;
826
@
r
public
BudgetLineItemType itemType;
827
@
r
public
Money amount;
828
@_maxSize(
30
)
829
@
r
public
String purpose;
830
@_maxSize(
2000
)
831
@
r
public
String justification;
832
@_backLink(
"budgetItem"
)
833
public
WorkOrderBudgetAllocation[] workOrders;
834
public
DisbursementBudgetAllocation disbursements;
835
}
836
837
public
static
enum BudgetLineItemType {
838
Undefined;
839
}
840
841
public
static
enum BudgetRevisionStatus {
842
Started, Done;
843
}
844
845
public
static
class
WorkOrderBudgetAllocation {
846
@
k
public
WorkOrder workOrder;
847
@
k
public
BudgetLineItem budgetItem;
848
}
849
850
public
static
class
DisbursementBudgetAllocation {
851
@
k
public
Disbursement disbursement;
852
@
k
public
BudgetLineItem budgetItem;
853
public
Money amount;
854
}
855
856
@DavClass._label(
"GL Budget Xref"
)
857
public
static
class
GlBudgetXref {
858
@
k
public
BudgetLineItemType itemType;
859
@
k
public
GeneralLedgerAccount GLAccount;
860
@
k
public
Long fromDate;
861
public
Long thruDate;
862
@
r
public
Percent allocationPercentage;
863
}
864
865
public
static
class
Invoice
extends
Obligation {
866
@h@s
public
Integer id;
867
@_maxSize(
40
)
868
@_displayNameElm
869
@
k
public
String number;
870
@_backLink(
"invoice"
)
871
@_displayInline
872
@
r
public
InvoiceItem[] items;
873
@_backLink(
"invoice"
)
874
public
InvoiceTerm[] terms;
875
@_onCreate
876
public
InvoiceStatus status = writeJS(
"status ? status : 'Open'"
);
877
public
PartyAddress billedTo;
878
public
PartyAddress billedFrom;
879
@_maxSize(
2000
)
880
@_displayInline
881
public
String message;
882
}
883
884
public
static
class
InvoiceItem
extends
TransactionDetail {
885
@_subPropertyOf(
"transaction"
)
886
@
k
@s
public
Invoice invoice;
887
@_readOnly
888
@
k
@s
public
Integer seq;
889
}
890
891
public
static
class
ProductInvoiceItem
extends
InvoiceItem {
892
@
k
@s
public
Invoice invoice;
893
@
k
@s
public
Integer seq;
894
public
Product product;
895
@
r
public
Float quantity;
896
@
r
public
Money unitPrice;
897
public
Money total;
898
}
899
900
public
static
class
InvoiceAdjustment
extends
InvoiceItem {
901
@
k
@s
public
Invoice invoice;
902
@
k
@s
public
Integer seq;
903
@
r
@s
public
Money amount;
904
@
r
public
AdjustmentType adjustmentType;
905
}
906
907
public
static
class
InvoiceTerm {
908
@
k
public
Invoice invoice;
909
@
k
public
TermType termType;
910
@_maxSize(
240
)
911
@
r
public
String termValue;
912
}
913
914
public
static
enum InvoiceStatus {
915
Open, @_label(
"Paid in full"
) PaidInFull, @_label(
"Paid partially"
) PaidPartially;
916
}
917
918
public
static
class
PartyAccount {
919
@
k
public
BillingAccount billingAccount;
920
@
k
public
Party party;
921
@
r
public
Boolean primaryResponsibilityFlag;
922
@
r
public
Long fromDate;
923
public
Long thruDate;
924
}
925
926
public
static
class
BillingAccount {
927
@_readOnly
928
@
k
public
Integer id;
929
@
r
public
PartyAddress party;
930
@
r
public
Long fromDate;
931
public
Long thruDate;
932
@_backLink(
"billingAccount"
)
933
public
PartyAccount[] partyAccount;
934
@_maxSize(
40
)
935
public
String description;
936
}
937
}
938