mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
refactoring: payment made form.
This commit is contained in:
@@ -576,4 +576,28 @@ export function safeSumBy(entries, getter) {
|
||||
.map(row => toSafeNumber(_.get(row, getter)))
|
||||
.sum()
|
||||
.value();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const fullAmountPaymentEntries = (entries) => {
|
||||
return entries.map((item) => ({
|
||||
...item,
|
||||
payment_amount: item.due_amount,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
export const amountPaymentEntries = (amount, entries) => {
|
||||
let total = amount;
|
||||
|
||||
return entries.map((item) => {
|
||||
const diff = Math.min(item.due_amount, total);
|
||||
total -= Math.max(diff, 0);
|
||||
|
||||
return {
|
||||
...item,
|
||||
payment_amount: diff,
|
||||
};
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user