mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Filter list of bills.
This commit is contained in:
@@ -315,7 +315,7 @@ let index = function () {
|
|||||||
// need to find the input thing
|
// need to find the input thing
|
||||||
console.log('Clicked edit button for account on index #' + index + ' and field ' + fieldName);
|
console.log('Clicked edit button for account on index #' + index + ' and field ' + fieldName);
|
||||||
const querySelector = 'input[data-field="' + fieldName + '"][data-index="' + index + '"]';
|
const querySelector = 'input[data-field="' + fieldName + '"][data-index="' + index + '"]';
|
||||||
console.log(querySelector);
|
// console.log(querySelector);
|
||||||
const newValue = document.querySelectorAll(querySelector)[0].value ?? '';
|
const newValue = document.querySelectorAll(querySelector)[0].value ?? '';
|
||||||
if ('' === newValue) {
|
if ('' === newValue) {
|
||||||
return;
|
return;
|
||||||
|
@@ -201,7 +201,7 @@ export default () => ({
|
|||||||
balance.amount_formatted = formatMoney(balance.amount, balance.currency_code);
|
balance.amount_formatted = formatMoney(balance.amount, balance.currency_code);
|
||||||
return balance;
|
return balance;
|
||||||
});
|
});
|
||||||
console.log(parent);
|
// console.log(parent);
|
||||||
|
|
||||||
|
|
||||||
// get groups for account:
|
// get groups for account:
|
||||||
|
@@ -76,7 +76,7 @@ export default () => ({
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let key = current.key;
|
let key = current.key;
|
||||||
console.log('NOT NATIVE');
|
// console.log('NOT NATIVE');
|
||||||
if (key.startsWith('balance-in-')) {
|
if (key.startsWith('balance-in-')) {
|
||||||
this.balanceBox.amounts.push(formatMoney(current.monetary_value, current.currency_code));
|
this.balanceBox.amounts.push(formatMoney(current.monetary_value, current.currency_code));
|
||||||
continue;
|
continue;
|
||||||
|
@@ -44,6 +44,18 @@ function addObjectGroupInfo(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parsePayDates(list) {
|
||||||
|
let newList = [];
|
||||||
|
for(let i in list) {
|
||||||
|
if (list.hasOwnProperty(i)) {
|
||||||
|
let current = list[i];
|
||||||
|
// convert to date object:
|
||||||
|
newList.push(new Date(current));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newList;
|
||||||
|
}
|
||||||
|
|
||||||
function parseBillInfo(data) {
|
function parseBillInfo(data) {
|
||||||
let result = {
|
let result = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
@@ -55,7 +67,7 @@ function parseBillInfo(data) {
|
|||||||
// paid transactions:
|
// paid transactions:
|
||||||
transactions: [],
|
transactions: [],
|
||||||
// unpaid moments
|
// unpaid moments
|
||||||
pay_dates: data.attributes.pay_dates,
|
pay_dates: parsePayDates(data.attributes.pay_dates),
|
||||||
paid: data.attributes.paid_dates.length > 0,
|
paid: data.attributes.paid_dates.length > 0,
|
||||||
};
|
};
|
||||||
// set variables
|
// set variables
|
||||||
@@ -64,6 +76,7 @@ function parseBillInfo(data) {
|
|||||||
times: data.attributes.pay_dates.length,
|
times: data.attributes.pay_dates.length,
|
||||||
amount: result.expected_amount
|
amount: result.expected_amount
|
||||||
});
|
});
|
||||||
|
// console.log(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +109,21 @@ function parsePaidTransactions(paid_dates, bill) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isInRange(bill) {
|
||||||
|
let start = new Date(window.store.get('start'));
|
||||||
|
let end = new Date(window.store.get('end'));
|
||||||
|
for(let i in bill.pay_dates) {
|
||||||
|
if (bill.pay_dates.hasOwnProperty(i)) {
|
||||||
|
let currentDate = bill.pay_dates[i];
|
||||||
|
//console.log(currentDate);
|
||||||
|
if (currentDate >= start && currentDate <= end) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function downloadSubscriptions(params) {
|
function downloadSubscriptions(params) {
|
||||||
const getter = new Get();
|
const getter = new Get();
|
||||||
return getter.list(params)
|
return getter.list(params)
|
||||||
@@ -113,10 +141,18 @@ function downloadSubscriptions(params) {
|
|||||||
|
|
||||||
// create and update the bill.
|
// create and update the bill.
|
||||||
let bill = parseBillInfo(current);
|
let bill = parseBillInfo(current);
|
||||||
|
|
||||||
|
// if not yet paid, and pay_dates is not in current rage, ignore it.
|
||||||
|
if (false === bill.paid && !isInRange(bill)) {
|
||||||
|
console.warn('Bill "'+bill.name+'" is not paid and not in range, ignoring: ');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bill.transactions = parsePaidTransactions(current.attributes.paid_dates, bill);
|
bill.transactions = parsePaidTransactions(current.attributes.paid_dates, bill);
|
||||||
|
|
||||||
subscriptionData[objectGroupId].bills.push(bill);
|
subscriptionData[objectGroupId].bills.push(bill);
|
||||||
if (0 === current.attributes.paid_dates.length) {
|
if (false === bill.paid) {
|
||||||
// bill is unpaid, count the "pay_dates" and multiply with the "amount".
|
// bill is unpaid, count the "pay_dates" and multiply with the "amount".
|
||||||
// since bill is unpaid, this can only be in currency amount and native currency amount.
|
// since bill is unpaid, this can only be in currency amount and native currency amount.
|
||||||
const totalAmount = current.attributes.pay_dates.length * bill.amount;
|
const totalAmount = current.attributes.pay_dates.length * bill.amount;
|
||||||
@@ -132,6 +168,7 @@ function downloadSubscriptions(params) {
|
|||||||
//native_unpaid: 0,
|
//native_unpaid: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
subscriptionData[objectGroupId].payment_info[bill.currency_code].unpaid += totalAmount;
|
subscriptionData[objectGroupId].payment_info[bill.currency_code].unpaid += totalAmount;
|
||||||
//subscriptionData[objectGroupId].payment_info[bill.currency_code].native_unpaid += totalNativeAmount;
|
//subscriptionData[objectGroupId].payment_info[bill.currency_code].native_unpaid += totalNativeAmount;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user