plete=complete;
}
}. javaru.ulstu.secretary.entity;
javax.persistence. GeneratedValue; javax.persistence. Id; javax.persistence. MappedSuperclass;
@ MappedSuperclassclass BaseEntity {
@ Id
@ GeneratedValueint id;
int getId () {id;
}
void setId (int id) {.id=id;
}
}. javaru.ulstu.secretary.entity;
enum Category {
(«auto»), («home»);
final String i18n;
Category (String i18n) {.i18n=i18n;
}
String toString () {i18n;
}
}. javaru.ulstu.secretary.entity;
java.util. ArrayList; java.util. Date; java.util. List;
javax.persistence. CascadeType; javax.persistence. Entity; javax.persistence. FetchType; javax.persistence. Inheritance; javax.persistence. InheritanceType; javax.persistence. OneToMany;
@ Entity
@ Inheritance (strategy=InheritanceType.JOINED) class Debt extends Action {
Date deadline;
Double repay;
Integer frequency;
Unit unit;
@ OneToMany (fetch=FetchType.EAGER, cascade=CascadeType.ALL) List lt; Repay gt; repays;
Debt () {= Unit.DAY;=new ArrayList lt; gt; ();
}
Date getDeadline () {deadline;
}
void setDeadline (Date deadline) {.deadline=deadline;
}
Double getRepay () {repay;
}
void setRepay (Double repay) {.repay=repay;
}
Integer getFrequency () {frequency;
}
void setFrequency (Integer frequency) {.frequency=frequency;
}
Unit getUnit () {unit;
}
void setUnit (Unit unit) {.unit=unit;
}
List lt; Repay gt; getRepays () {repays;
}
public void setRepays (List lt; Repay gt; repays) {.repays=repays;
}
double getUnpaid (Date moment) {(moment.before (getDate ())) {0;
} sum=repays.stream (). filter (repay - gt ;! repay.getDate (). after (moment)). mapToDouble (repay - gt; repay.getBalance ()). sum (); Math.max (0, getBalance () + sum);
}
}. javaru.ulstu.secretary.entity;
javax.persistence. Entity; javax.persistence. Inheritance; javax.persistence. InheritanceType;
@ Entity
@ Inheritance (strategy=InheritanceType.JOINED) class Pay extends Task {} .javaru.ulstu.secretary.entity;
javax.persistence. CascadeType; javax.persistence. Entity; javax.persistence. Inheritance; javax.persistence. InheritanceType; javax.persistence. ManyToOne;
@ Entity
@ Inheritance (strategy=InheritanceType.JOINED) class Repay extends Task {
@ ManyToOne (cascade=CascadeType.ALL) Debt debt;
Debt getDebt () {debt;
}
void setDebt (Debt debt) {.debt=debt;
}
}. javaru.ulstu.secretary.entity;
javax.persistence. Entity; javax.persistence. Inheritance; javax.persistence. InheritanceType;
@ Entity
@ Inheritance (strategy=InheritanceType.JOINED) class Task extends Action {} .javaru.ulstu.secretary.entity; java.util. Calendar;
enum Unit {
(«year», Calendar.YEAR), («month», Calendar.MONTH), («week», Calendar.WEEK_OF_MONTH), («day», Calendar.DAY_OF_WEEK);
final String i18n;
final int code;
Unit (String i18n, int code) {.i18n=i18n; .code=code;
}
int getCode () {code;
}
String toString () {i18n;
}
}. javaru.ulstu.secretary.grid;