/src/classes/com/sapienter/jbilling/server/process/db/ProcessRunTotalDTO.java

https://github.com/bibulous/SkyrackJbill2.2 · Java · 182 lines · 135 code · 28 blank · 19 comment · 1 complexity · e9d55337d3c199771f8243c01f65f4d1 MD5 · raw file

  1. /*
  2. jBilling - The Enterprise Open Source Billing System
  3. Copyright (C) 2003-2009 Enterprise jBilling Software Ltd. and Emiliano Conde
  4. This file is part of jbilling.
  5. jbilling is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU Affero General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. jbilling is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Affero General Public License for more details.
  13. You should have received a copy of the GNU Affero General Public License
  14. along with jbilling. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. package com.sapienter.jbilling.server.process.db;
  17. import java.math.BigDecimal;
  18. import java.util.Set;
  19. import javax.persistence.CascadeType;
  20. import javax.persistence.Column;
  21. import javax.persistence.Entity;
  22. import javax.persistence.FetchType;
  23. import javax.persistence.GeneratedValue;
  24. import javax.persistence.GenerationType;
  25. import javax.persistence.Id;
  26. import javax.persistence.JoinColumn;
  27. import javax.persistence.ManyToOne;
  28. import javax.persistence.OneToMany;
  29. import javax.persistence.Table;
  30. import javax.persistence.TableGenerator;
  31. import javax.persistence.Version;
  32. import com.sapienter.jbilling.server.util.db.CurrencyDTO;
  33. import java.util.HashSet;
  34. import org.hibernate.annotations.Cache;
  35. import org.hibernate.annotations.CacheConcurrencyStrategy;
  36. @Entity
  37. @TableGenerator(
  38. name = "process_run_total_GEN",
  39. table = "jbilling_seqs",
  40. pkColumnName = "name",
  41. valueColumnName = "next_id",
  42. pkColumnValue = "process_run_total",
  43. allocationSize = 100)
  44. @Table(name = "process_run_total")
  45. @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  46. public class ProcessRunTotalDTO implements java.io.Serializable {
  47. private int id;
  48. private ProcessRunDTO processRun;
  49. private CurrencyDTO currencyDTO;
  50. private BigDecimal totalInvoiced;
  51. private BigDecimal totalPaid;
  52. private BigDecimal totalNotPaid;
  53. private Set<ProcessRunTotalPmDTO> totalsPaymentMethod = new HashSet<ProcessRunTotalPmDTO>(0);
  54. private int versionNum;
  55. public ProcessRunTotalDTO() {
  56. }
  57. public ProcessRunTotalDTO(int id, CurrencyDTO currencyDTO) {
  58. this.id = id;
  59. this.currencyDTO = currencyDTO;
  60. }
  61. public ProcessRunTotalDTO(int id, ProcessRunDTO processRun, CurrencyDTO currencyDTO,
  62. BigDecimal totalInvoiced, BigDecimal totalPaid, BigDecimal totalNotPaid) {
  63. this.id = id;
  64. this.processRun = processRun;
  65. this.currencyDTO = currencyDTO;
  66. this.totalInvoiced = totalInvoiced;
  67. this.totalPaid = totalPaid;
  68. this.totalNotPaid = totalNotPaid;
  69. }
  70. @Id
  71. @GeneratedValue(strategy = GenerationType.TABLE, generator = "process_run_total_GEN")
  72. @Column(name = "id", unique = true, nullable = false)
  73. public int getId() {
  74. return this.id;
  75. }
  76. public void setId(int id) {
  77. this.id = id;
  78. }
  79. @ManyToOne(fetch = FetchType.LAZY)
  80. @JoinColumn(name = "process_run_id")
  81. public ProcessRunDTO getProcessRun() {
  82. return this.processRun;
  83. }
  84. public void setProcessRun(ProcessRunDTO processRun) {
  85. this.processRun = processRun;
  86. }
  87. @ManyToOne(fetch = FetchType.LAZY)
  88. @JoinColumn(name = "currency_id", nullable = false)
  89. public CurrencyDTO getCurrency() {
  90. return this.currencyDTO;
  91. }
  92. public void setCurrency(CurrencyDTO currencyDTO) {
  93. this.currencyDTO = currencyDTO;
  94. }
  95. @Column(name = "total_invoiced", precision = 17, scale = 17)
  96. public BigDecimal getTotalInvoiced() {
  97. return this.totalInvoiced;
  98. }
  99. public void setTotalInvoiced(BigDecimal totalInvoiced) {
  100. this.totalInvoiced = totalInvoiced;
  101. }
  102. @Column(name = "total_paid", precision = 17, scale = 17)
  103. public BigDecimal getTotalPaid() {
  104. return this.totalPaid;
  105. }
  106. public void setTotalPaid(BigDecimal totalPaid) {
  107. this.totalPaid = totalPaid;
  108. }
  109. @Column(name = "total_not_paid", precision = 17, scale = 17)
  110. public BigDecimal getTotalNotPaid() {
  111. return this.totalNotPaid;
  112. }
  113. public void setTotalNotPaid(BigDecimal totalNotPaid) {
  114. this.totalNotPaid = totalNotPaid;
  115. }
  116. @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="processRunTotal")
  117. public Set<ProcessRunTotalPmDTO> getTotalsPaymentMethod() {
  118. return totalsPaymentMethod;
  119. }
  120. public void setTotalsPaymentMethod(Set<ProcessRunTotalPmDTO> totalsPaymentMethod) {
  121. this.totalsPaymentMethod = totalsPaymentMethod;
  122. }
  123. @Version
  124. @Column(name="OPTLOCK")
  125. public int getVersionNum() {
  126. return versionNum;
  127. }
  128. public void setVersionNum(int versionNum) {
  129. this.versionNum = versionNum;
  130. }
  131. @Override
  132. public String toString() {
  133. StringBuffer ret = new StringBuffer();
  134. ret.append(" ProcessRunTotalDTO: id: ")
  135. .append(id)
  136. .append(" currency: ")
  137. .append(currencyDTO)
  138. .append(" totalInvoiced: ")
  139. .append(totalInvoiced)
  140. .append(" totalPaid: ")
  141. .append(totalPaid)
  142. .append(" totalNotPaid: ")
  143. .append(totalNotPaid)
  144. .append(" totalsPaymentMethod ");
  145. for (ProcessRunTotalPmDTO pm : totalsPaymentMethod) {
  146. ret.append(pm.toString());
  147. }
  148. return ret.toString();
  149. }
  150. }