19 package org.turro.financials.handshake;
21 import com.google.gson.Gson;
22 import com.google.gson.GsonBuilder;
24 import java.io.IOException;
25 import java.util.ArrayList;
26 import java.util.Date;
27 import java.util.HashSet;
28 import java.util.List;
29 import java.util.Objects;
31 import java.util.logging.Level;
32 import java.util.logging.Logger;
33 import org.turro.elephant.context.ElephantContext;
34 import org.turro.elephant.impl.util.FileUtil;
35 import org.turro.financials.db.FinancialsPU;
36 import org.turro.financials.entity.Company;
37 import org.turro.financials.entity.Contract;
38 import org.turro.financials.entity.Document;
39 import org.turro.financials.entity.DocumentLine;
40 import org.turro.financials.entity.DocumentRelation;
41 import org.turro.financials.model.business.CompanyWrapper;
42 import org.turro.jpa.Dao;
43 import org.turro.util.IdGenerator;
51 public final static String
59 public List<HandshakeDocLine>
lines =
new ArrayList<>();
60 public List<HandshakeDocument>
expiries =
new ArrayList<>();
63 Gson gson =
new GsonBuilder().setDateFormat(
"yyyy/MM/dd").create();
66 return gson.toJson(hd);
87 hdl.
price = dl.getPrice();
88 if(dl.getProduct() !=
null) {
93 hdl.
tax = dl.getTax();
109 Gson gson =
new GsonBuilder().setDateFormat(
"yyyy/MM/dd").create();
116 }
catch (IOException ex) {
123 Gson gson =
new GsonBuilder().setDateFormat(
"yyyy/MM/dd").create();
126 }
catch (IOException ex) {
134 "select d from Document d " +
135 "where d.contract.id = ? " +
136 "and d.documentNumber = ? " +
137 "and d.documentDate = ?",
154 if(!folder.exists()) { folder.mkdirs(); }
155 for(File file : folder.listFiles()) {
164 private static long mapDocumentDefinition(
Document document) {
181 hash = 61 * hash + Objects.hashCode(this.contract);
182 hash = 61 * hash + Objects.hashCode(this.documentNumber);
183 hash = 61 * hash + Objects.hashCode(this.documentDate);
192 if (getClass() != obj.getClass()) {
196 if (!Objects.equals(
this.contract, other.
contract)) {
202 if (!Objects.equals(
this.documentDate, other.
documentDate)) {
209 Set<HandshakeProduct> products =
new HashSet<>();
210 addProducts(products,
this);
220 for(HandshakeDocument dhd : hd.
expiries) {
221 addProducts(products, dhd);
static String getRealPath(String path)
static String logMsg(String msg)
static void setContent(File file, String value)
static String getContent(File file)
Set< DocumentRelation > getDescendants()
String getDocumentNumber()
Set< DocumentLine > getDocumentLines()
DocumentDefinition getDocumentDefinition()
static HandshakeContract createHandshakeFromContract(Contract contract)
double equivalenceSurcharge
boolean equals(Object obj)
static final String HANDSHAKE_FOLDER
static HandshakeDocument createHandshakeFromFile(File file)
static HandshakeDocument createHandshakeFromDocument(Document document)
static HandshakeDocument createHandshakeFromJson(String value)
Iterable< HandshakeProduct > getProducts()
List< HandshakeDocument > expiries
static void saveHandshakeDocument(HandshakeDocument hd)
static boolean existsHandshake(HandshakeDocument hd)
static String createJsonFromDocument(Document document)
List< HandshakeDocLine > lines
HandshakeContract contract
static Document getDocumentFromHandshake(Contract contract, HandshakeDocument hd)
static void saveHandshakeToFile(File file, HandshakeDocument hd)
static HandshakeProduct createHandshakeFromProduct(Product product)
static Company getDefaultCompany()
Object getSingleResultOrNull(SqlClause sc)