Files
itflow/api/v1/recurring_expenses/move_on.php
johnnyq ecbb974fff API stage 3, calendar events, trips, accounts and money, contracts, and files and folders: calendars can be read, and calendar events read with their attendees, created once or repeating for a client or nobody, changed, sent as invitations, skipped for a day of a series and deleted, following calendarEventCan(); trips can be read, logged, changed and deleted through tripSave() and tripDelete(), anyone their own and someone else's with Financial; accounts can be read with their balances, added, changed, archived, unarchived and deleted while nothing is on them, other income and transfers read, recorded, changed and deleted, and recurring expenses read, set up, changed, paused and resumed, recorded now, moved on past missed runs and deleted, keeping reconciled lines as they were; contracts can be read with their prepaid hours and signing state, added, changed, made active, renewed, cancelled and deleted, sent for signature or the link sent again, the request withdrawn, prepaid hours added with a draft invoice or deleted, tickets' time drawn or put back, and the billing recurring invoice made, linked or unlinked; a client's files can be read, uploaded as base64, downloaded, renamed, moved, archived, unarchived and deleted once archived, and folders read, made, renamed, moved and deleted with their contents moved up; new api/v1/form_input.php builds a save function's input from the API's field names; the upload allow-list moves from agent/post/file.php into fileUploadExtensions() so Upload Files and the API check the same list; enforce_api_rbac.php maps the new resources, lets events, calendars and trips check their own rules, puts the new state changes at Modify and treats files/download as a read; 26.11.9 changelog entries
2026-11-13 23:51:10 -05:00

41 lines
1.6 KiB
PHP

<?php
/*
* API - Recurring Expenses - Move On
* POST /api/v1/recurring_expenses/move_on.php
*
* Skip the runs it missed without recording them, as Move On does - its next date
* moves on past today. Past its end date, it has ended.
*
* Parameters (POST, JSON body): api_key, recurring_expense_id, client_id (its client -
* needed when the key's user is limited to certain clients)
*
* Answer: next_date.
*/
require_once '../validate_api_key.php';
require_once '../require_post_method.php';
require_once 'recurring_expense_map.php';
$update_count = false;
require_once 're_find.php';
if ($re_row) {
$from = $re_row['recurring_expense_next_date'];
$next = recurringExpenseCatchUp($re_row);
$ends = !empty($re_row['recurring_expense_end_date']) && $next > $re_row['recurring_expense_end_date'];
mysqli_query($mysqli, "UPDATE recurring_expenses SET recurring_expense_next_date = '" . escapeSql($next) . "'" . ($ends ? ', recurring_expense_status = 0' : '') . "
WHERE recurring_expense_id = $recurring_expense_id AND recurring_expense_next_date = '" . escapeSql($from) . "'");
$update_count = 1;
$return_arr['next_date'] = $next;
$label = escapeSql(recurringExpenseLabel($re_row));
logAudit("Recurring Expense", "Move On", "Moved the recurring expense $label on from $from to $next without recording the missed runs via API ($api_key_name)", intval($re_row['recurring_expense_client_id']), $recurring_expense_id);
logAudit("API", "Success", "Moved the recurring expense $label on via API ($api_key_name)", intval($re_row['recurring_expense_client_id']));
}
// Output
require_once '../update_output.php';