fix invoice.reminder
This commit is contained in:
parent
96ef6030ac
commit
b8627ca83a
3 changed files with 126 additions and 7 deletions
|
|
@ -89,7 +89,7 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
int errors = 0;
|
||||
int count = 0;
|
||||
public static String _QUERY = "($modelversion:rechnungsausgang-de-1.0)\n" + //
|
||||
"AND $created:[20240604 TO 20240613]";
|
||||
"AND $created:[20240604 TO 20240619]";
|
||||
|
||||
@Inject
|
||||
DocumentService documentService;
|
||||
|
|
@ -119,12 +119,12 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
|
||||
logger.info("query=" + _QUERY);
|
||||
log = "Query\n" + _QUERY;
|
||||
List<ItemCollection> result = documentService.find(_QUERY, 999, 0);
|
||||
List<ItemCollection> result = documentService.find(_QUERY, 9999, 0);
|
||||
|
||||
log = log + "\n\nCount=" + result.size();
|
||||
|
||||
if (result.size() > 999) {
|
||||
log = log + "\n\nACHTUNG ES GIBT MEHR ALS 1000 RECHNUNGEN !";
|
||||
if (result.size() > 9999) {
|
||||
log = log + "\n\nACHTUNG ES GIBT MEHR ALS 10000 RECHNUNGEN !";
|
||||
}
|
||||
|
||||
return log;
|
||||
|
|
@ -151,7 +151,34 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
logger.info("query=" + _QUERY);
|
||||
log = "Query\n\n" + _QUERY;
|
||||
|
||||
List<ItemCollection> result = documentService.find(_QUERY, 999, 0);
|
||||
List<ItemCollection> result = documentService.find(_QUERY, 9999, 0);
|
||||
|
||||
log = log + "\n\nSelection Count=" + result.size();
|
||||
|
||||
log = log + "\n\nFixes\n\n";
|
||||
|
||||
for (ItemCollection workitem : result) {
|
||||
|
||||
if (!workitem.hasItem("invoice.reminder")) {
|
||||
Date dueDate = workitem.getItemValueDate("invoice.duedate");
|
||||
workitem.setItemValue("invoice.reminder", dueDate);
|
||||
count++;
|
||||
// save only
|
||||
documentService.save(workitem);
|
||||
}
|
||||
}
|
||||
|
||||
log = log + "\n\n=== Completed! " + count + " fixes! ===\n\n";
|
||||
return log;
|
||||
}
|
||||
|
||||
public String fixFehlerhafteCargosoftDatenMitSnapshot()
|
||||
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||
|
||||
logger.info("query=" + _QUERY);
|
||||
log = "Query\n\n" + _QUERY;
|
||||
|
||||
List<ItemCollection> result = documentService.find(_QUERY, 9999, 0);
|
||||
|
||||
log = log + "\n\nSelection Count=" + result.size();
|
||||
|
||||
|
|
|
|||
|
|
@ -437,6 +437,8 @@ public class CargosoftXMLInvoiceImportService {
|
|||
|
||||
readXMLValue(doc, "/Invoices/Invoice/InvoiceHeader/PaymentConditions/DueDate",
|
||||
workitem, "invoice.duedate", Date.class);
|
||||
readXMLValue(doc, "/Invoices/Invoice/InvoiceHeader/PaymentConditions/DueDate",
|
||||
workitem, "invoice.reminder", Date.class);
|
||||
|
||||
readXMLValue(doc, "/Invoices/Invoice/InvoiceHeader/InvoiceAddress/Codes/Code",
|
||||
workitem, "dbtr.number", String.class);
|
||||
|
|
|
|||
|
|
@ -8,11 +8,16 @@ import java.io.StringWriter;
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.BodyPart;
|
||||
import javax.mail.Folder;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.Part;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Store;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
|
|
@ -22,6 +27,7 @@ import org.apache.http.entity.StringEntity;
|
|||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.imixs.archive.importer.mail.IMAPImportHelper;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
|
|
@ -91,7 +97,6 @@ public class TestIMAPOutlookOAuth {
|
|||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
store = connect(token, "Imixsbhv@alexander-logistics.com");
|
||||
// store = connect(token, "mgeisler@alexander-logistics.com");
|
||||
|
||||
Assert.assertNotNull(store);
|
||||
|
||||
|
|
@ -115,13 +120,98 @@ public class TestIMAPOutlookOAuth {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestMailboxImixsPL() {
|
||||
Store store = null;
|
||||
String token = null;
|
||||
try {
|
||||
// try to connect...
|
||||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
store = connect(token, "imixspl@alexander-logistics.com");
|
||||
|
||||
Assert.assertNotNull(store);
|
||||
|
||||
if (!store.isConnected()) {
|
||||
// not connected!
|
||||
} else {
|
||||
// read inbox....
|
||||
IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX");
|
||||
inbox.open(Folder.READ_WRITE);
|
||||
// fetches all messages from the INBOX...
|
||||
Message[] messages = inbox.getMessages();
|
||||
System.out.println("..." + messages.length + " new messages found");
|
||||
|
||||
System.out.println("...read message subjects...");
|
||||
|
||||
for (Message message : messages) {
|
||||
Address[] fromAddress = null;
|
||||
String subject = null;
|
||||
// if we can not open the mail (messaging Exception) than we simply skipp this
|
||||
// mail see Issue #175
|
||||
try {
|
||||
fromAddress = message.getFrom();
|
||||
subject = message.getSubject();
|
||||
} catch (MessagingException me) {
|
||||
System.out.println("...Failed to read message from inbox: " + me.getMessage());
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
System.out.println("......received mail from: " + fromAddress[0].toString());
|
||||
System.out.println("......subject = " + subject);
|
||||
|
||||
Object contentObject = message.getContent();
|
||||
if (contentObject instanceof Multipart) {
|
||||
System.out.println("......multipart objects found");
|
||||
|
||||
// here we are save to cast the content to Mulipart
|
||||
Multipart multiPart = (Multipart) message.getContent();
|
||||
for (int i = 0; i < multiPart.getCount(); i++) {
|
||||
|
||||
BodyPart bodyPart = multiPart.getBodyPart(i);
|
||||
if (bodyPart instanceof MimeBodyPart) {
|
||||
MimeBodyPart mimeBodyPart = (MimeBodyPart) multiPart.getBodyPart(i);
|
||||
if (Part.ATTACHMENT.equalsIgnoreCase(mimeBodyPart.getDisposition())) {
|
||||
|
||||
String fileName = mimeBodyPart.getFileName();
|
||||
if (fileName == null) {
|
||||
System.out.println("...skip detaching file, because of missing filename");
|
||||
continue; // skip this attachment
|
||||
}
|
||||
|
||||
// add this attachment
|
||||
InputStream input = mimeBodyPart.getInputStream();
|
||||
byte[] content = IMAPImportHelper.readAllBytes(input);
|
||||
String contentType = mimeBodyPart.getContentType();
|
||||
|
||||
System.out
|
||||
.println("...Attachment '" + fileName + "' is ok - size=" + content.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
System.out.println("...completed!");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestMailboxImixsDWC() {
|
||||
Store store = null;
|
||||
String token = null;
|
||||
try {
|
||||
// try to connect...
|
||||
// token = getAuthToken("2a41bf2d-ffd8-444d-a2c5-6a4a418650ba");
|
||||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
store = connect(token, "Imixsae@alexander-logistics.com");
|
||||
|
|
|
|||
Loading…
Reference in a new issue