3.0.0 #220
@@ -119,6 +119,12 @@ const getIncomingInvoiceSignedAmount = (invoice: any) => {
|
|||||||
return roundMoney(invoice.expense === false ? amount : amount * -1);
|
return roundMoney(invoice.expense === false ? amount : amount * -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getRemainingSignedAmount = (signedAmount: number, allocatedAmount: number) => {
|
||||||
|
const remainingAbsolute = Math.max(0, Math.abs(Number(signedAmount || 0)) - Math.abs(Number(allocatedAmount || 0)));
|
||||||
|
if (remainingAbsolute <= 0.01) return 0;
|
||||||
|
return roundMoney(Math.sign(Number(signedAmount || 0)) * remainingAbsolute);
|
||||||
|
};
|
||||||
|
|
||||||
const findCancellationDocumentIds = (documents: any[]) => {
|
const findCancellationDocumentIds = (documents: any[]) => {
|
||||||
return new Set(
|
return new Set(
|
||||||
documents
|
documents
|
||||||
@@ -392,7 +398,7 @@ export const generateLiquidityForecast = async (
|
|||||||
.filter((invoice) => !invoice.paid)
|
.filter((invoice) => !invoice.paid)
|
||||||
.forEach((invoice) => {
|
.forEach((invoice) => {
|
||||||
const signedAmount = getIncomingInvoiceSignedAmount(invoice);
|
const signedAmount = getIncomingInvoiceSignedAmount(invoice);
|
||||||
const openAmount = roundMoney(signedAmount - (allocationByIncomingInvoice.get(invoice.id) || 0));
|
const openAmount = getRemainingSignedAmount(signedAmount, allocationByIncomingInvoice.get(invoice.id) || 0);
|
||||||
if (Math.abs(openAmount) <= 0.01) return;
|
if (Math.abs(openAmount) <= 0.01) return;
|
||||||
|
|
||||||
const dueDate = dayjs(invoice.dueDate || invoice.date).isValid()
|
const dueDate = dayjs(invoice.dueDate || invoice.date).isValid()
|
||||||
|
|||||||
Reference in New Issue
Block a user