Skip to content

Commit

Permalink
Add Validation for Invoice Table on Model Validator
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosaparadam committed Dec 20, 2019
1 parent 076f714 commit 1a7ccdb
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions core/src/main/java/base/org/erpya/lve/model/LVE.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,21 @@ public String docValidate(PO po, int timing) {
shipment.saveEx();
}
} else if(timing == TIMING_AFTER_COMPLETE) {
MInvoice invoice = (MInvoice) po;
if(!invoice.isReversal()) {
MDocType documentType = MDocType.get(invoice.getCtx(), invoice.getC_DocTypeTarget_ID());
if(documentType.get_ValueAsBoolean(ColumnsAdded.COLUMNNAME_IsAllocateInvoice)) {
AllocationManager allocationManager = new AllocationManager(invoice);
Arrays.asList(invoice.getLines())
.stream()
.filter(invoiceLine -> invoiceLine.get_ValueAsInt(ColumnsAdded.COLUMNNAME_InvoiceToAllocate_ID) != 0)
.forEach(invoiceLine -> {
allocationManager.addAllocateDocument(invoiceLine.get_ValueAsInt(ColumnsAdded.COLUMNNAME_InvoiceToAllocate_ID), invoiceLine.getLineTotalAmt(), Env.ZERO, Env.ZERO);
});
// Create Allocation
allocationManager.createAllocation();
if (po.get_TableName().equals(MInvoice.Table_Name)) {
MInvoice invoice = (MInvoice) po;
if(!invoice.isReversal()) {
MDocType documentType = MDocType.get(invoice.getCtx(), invoice.getC_DocTypeTarget_ID());
if(documentType.get_ValueAsBoolean(ColumnsAdded.COLUMNNAME_IsAllocateInvoice)) {
AllocationManager allocationManager = new AllocationManager(invoice);
Arrays.asList(invoice.getLines())
.stream()
.filter(invoiceLine -> invoiceLine.get_ValueAsInt(ColumnsAdded.COLUMNNAME_InvoiceToAllocate_ID) != 0)
.forEach(invoiceLine -> {
allocationManager.addAllocateDocument(invoiceLine.get_ValueAsInt(ColumnsAdded.COLUMNNAME_InvoiceToAllocate_ID), invoiceLine.getLineTotalAmt(), Env.ZERO, Env.ZERO);
});
// Create Allocation
allocationManager.createAllocation();
}
}
}
}
Expand Down

0 comments on commit 1a7ccdb

Please sign in to comment.