Implement banking system features and enhancements
- Added banking mode with checking, savings, and charity accounts, including auto-split options for income. - Introduced banking transaction management, including transfers and charity outflows. - Updated family settings to allow configuration of banking features and interest rates. - Enhanced data export functionality to include bank transactions. - Improved user interface to display banking information and donation goals. - Updated documentation to reflect new banking features and settings.
This commit is contained in:
+23
-2
@@ -2,12 +2,16 @@
|
||||
|
||||
require_once __DIR__ . '/../includes/api_bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/chore_helpers.php';
|
||||
require_once __DIR__ . '/../includes/family_settings.php';
|
||||
require_once __DIR__ . '/../includes/banking_helpers.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
sendJson(['success' => false, 'error' => 'Method not allowed'], 405);
|
||||
}
|
||||
|
||||
$people = migrateAllPeople(normalizePeopleList(readJsonFile('people.json')));
|
||||
$familySettings = loadFamilySettings();
|
||||
$people = bankingApplySavingsInterestToPeople($people, $familySettings);
|
||||
$actor = requireActivePerson($people);
|
||||
if (($actor['role'] ?? '') !== ROLE_HEAD || !isHohVerified()) {
|
||||
sendJson(['success' => false, 'error' => 'Only a verified Head of household can review chores'], 403);
|
||||
@@ -86,8 +90,25 @@ foreach ($people as $pi => $p) {
|
||||
$n = count($assignees);
|
||||
$creditedEach = $n > 0 ? round($value / $n, 2) : 0.0;
|
||||
}
|
||||
$bal = $p['currency_balance'] ?? 0;
|
||||
$people[$pi]['currency_balance'] = (is_numeric($bal) ? (float) $bal : 0.0) + $creditedEach;
|
||||
if (bankingEnabled($familySettings)) {
|
||||
$result = bankingCreditCheckingByRule($people[$pi], $creditedEach, $familySettings);
|
||||
$people[$pi] = $result['person'];
|
||||
appendBankTransaction([
|
||||
'id' => bin2hex(random_bytes(8)),
|
||||
'type' => 'income_chore',
|
||||
'person_id' => $pid,
|
||||
'amount' => bankingRoundMoney($creditedEach),
|
||||
'allocations' => $result['allocations'],
|
||||
'category' => 'chore',
|
||||
'note' => (string) ($row['title'] ?? ''),
|
||||
'created_at' => gmdate('c'),
|
||||
'created_by' => (string) ($actor['id'] ?? ''),
|
||||
]);
|
||||
} else {
|
||||
$bal = $p['currency_balance'] ?? 0;
|
||||
$people[$pi]['currency_balance'] = (is_numeric($bal) ? (float) $bal : 0.0) + $creditedEach;
|
||||
$people[$pi]['checking_balance'] = $people[$pi]['currency_balance'];
|
||||
}
|
||||
$creditedRecipients++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user