View Javadoc
1   package com.srv4pos.server.api.sale;
2   
3   import com.srv4pos.server.api.infrastructure.Constraints;
4   import com.srv4pos.server.api.infrastructure.SyncEntityInfo;
5   import com.srv4pos.server.api.infrastructure.journal.JournalDate;
6   import com.srv4pos.server.api.validationGroups.IdentifierValidationGroup;
7   import org.springframework.roo.addon.javabean.RooJavaBean;
8   import org.springframework.roo.addon.json.RooJson;
9   import org.springframework.roo.addon.tostring.RooToString;
10  
11  import javax.validation.Valid;
12  import javax.validation.constraints.Min;
13  import javax.validation.constraints.NotNull;
14  import javax.validation.constraints.Pattern;
15  import javax.validation.constraints.Size;
16  import java.util.ArrayList;
17  import java.util.Date;
18  import java.util.List;
19  
20  /**
21   * Set of field as in Sale entity.
22   * <p>User: Pavel Abizyaev, Date: 04.09.2014 17:41</p>
23   */
24  @RooJavaBean
25  @RooToString
26  @RooJson(deepSerialize = true)
27  public class SaleInfo implements SyncEntityInfo {
28  
29      /**
30       * List of fields for ordering.
31       */
32      public enum Fields { ID, BRUTTO }
33  
34      /**
35       * Sale identifier.
36       */
37      private long id;
38  
39      @NotNull(groups = IdentifierValidationGroup.class)
40      @Size(max = 50, min = 1)
41      @Pattern(regexp = Constraints.WINDOWS_FILENAME_REGEX)
42      private String identifier;
43  
44      /**
45       *  Seller identifier (country + corporate id).
46      */
47      @NotNull
48      private String sellerIdentifier;
49  
50      /**
51       * Sale state.
52      */
53      @NotNull
54      private SaleState saleState;
55  
56      /**
57       * True if it is a refund sale.
58       */
59      private boolean refund;
60  
61      /**
62       * Identifier of refunded sale.
63      */
64      private Integer refundFor;
65  
66      /**
67       * Sale absolute discount.
68       */
69      @Min(0)
70      private long absoluteDiscount;
71  
72      /**
73       * Sale relative discount.
74       */
75      @Min(0)
76      private int relativeDiscount;
77  
78      /**
79       * Sale brutto without discount.
80       *
81       * Sum of {@link SaleProductInfo#brutto}
82       */
83      @Min(0)
84      private long vanillaBrutto;
85  
86      /**
87       * Sale discount.
88       *
89       * discount = {@link SaleInfo#relativeDiscount} != 0 ? {@link SaleInfo#vanillaBrutto} / (1 + {@link SaleInfo#relativeDiscount})
90       * : {@link SaleInfo#absoluteDiscount}
91       */
92      @Min(0)
93      private long discount;
94  
95      /**
96       * Total sale brutto.
97       *
98       * Sum of {@link SaleInfo#vatRateSums} brutto
99       */
100     @Min(0)
101     private long brutto;
102 
103     /**
104      * Total sale VAT.
105      *
106      * Sum of {@link SaleInfo#vatRateSums} vat
107      */
108     @Min(0)
109     private long vat;
110 
111     /**
112      * Control unit Id.
113      */
114     @Size(max = 20)
115     private String controlUnitId;
116 
117     /**
118      * Treasurer name.
119      */
120     @Size(max = 50, min = 1)
121     @Pattern(regexp = Constraints.WINDOWS_FILENAME_REGEX)
122     private String treasurer;
123 
124     /**
125      * Close receipt date.
126     */
127     @JournalDate
128     private Date close;
129 
130     /**
131      * Day identifier.
132      */
133     private String day;
134 
135     private Integer version;
136 
137     /**
138      * List of products.
139      */
140     @Valid
141     private List<SaleProductInfo> saleProducts = new ArrayList<SaleProductInfo>();
142 
143     /**
144      * List of print types.
145      */
146     @Valid
147     private List<PrintInfo> prints = new ArrayList<PrintInfo>();
148 
149     /**
150      * List of payments.
151      */
152     @Valid
153     private List<PaymentInfo> payments = new ArrayList<PaymentInfo>();
154 
155     @Valid
156     private List<VatRateSumInfo> vatRateSums = new ArrayList<VatRateSumInfo>();
157 
158     @Size(max = 50, min = 1)
159     @Pattern(regexp = Constraints.WINDOWS_FILENAME_REGEX)
160     private String tripIdentifier;
161 }