use of org.compiere.FA.exceptions.AssetInvoiceWithMixedLines_LRO in project adempiere by adempiere.
the class ModelValidator method validateFixedAssetsInvoice_LRO.
/**
* Check if is a valid fixed asset related invoice (LRO)
* @param invoice
*/
private void validateFixedAssetsInvoice_LRO(MInvoice invoice) {
if (invoice.get_ValueAsBoolean("IsFixedAssetInvoice")) {
boolean hasFixedAssetLines = false;
boolean hasNormalLines = false;
for (MInvoiceLine line : invoice.getLines()) {
if (line.get_ValueAsBoolean("IsFixedAssetInvoice")) {
hasFixedAssetLines = true;
} else if (line.getM_Product_ID() > 0) {
MProduct product = MProduct.get(line.getCtx(), line.getM_Product_ID());
if (product.isItem()) {
// Only items are forbiden for FA invoices because in Romania these should use
// V_Liability vendor account and not V_Liability_FixedAssets vendor account
hasNormalLines = true;
}
}
// No mixed lines are allowed
if (hasFixedAssetLines && hasNormalLines) {
throw new AssetInvoiceWithMixedLines_LRO();
}
}
}
}
Aggregations