mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-23 09:26:29 -06:00
Expand API to accept liability accounts.
This commit is contained in:
parent
c4bbbc49b4
commit
3764499714
@ -221,6 +221,11 @@ class AccountController extends Controller
|
||||
'special' => [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION,
|
||||
AccountType::LOAN,],
|
||||
'hidden' => [AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION, AccountType::LOAN,],
|
||||
'liability' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],
|
||||
'liabilities' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],
|
||||
'cc' => [AccountType::CREDITCARD],
|
||||
'creditcard' => [AccountType::CREDITCARD],
|
||||
'credit_card' => [AccountType::CREDITCARD],
|
||||
AccountType::DEFAULT => [AccountType::DEFAULT],
|
||||
AccountType::CASH => [AccountType::CASH],
|
||||
AccountType::ASSET => [AccountType::ASSET],
|
||||
@ -231,6 +236,10 @@ class AccountController extends Controller
|
||||
AccountType::IMPORT => [AccountType::IMPORT],
|
||||
AccountType::RECONCILIATION => [AccountType::RECONCILIATION],
|
||||
AccountType::LOAN => [AccountType::LOAN],
|
||||
AccountType::MORTGAGE => [AccountType::MORTGAGE],
|
||||
AccountType::DEBT => [AccountType::DEBT],
|
||||
AccountType::CREDITCARD => [AccountType::CREDITCARD],
|
||||
|
||||
];
|
||||
$return = $types['all'];
|
||||
if (isset($types[$type])) {
|
||||
|
@ -50,6 +50,7 @@ class AccountRequest extends Request
|
||||
$data = [
|
||||
'name' => $this->string('name'),
|
||||
'active' => $this->boolean('active'),
|
||||
'include_net_worth' => $this->boolean('include_net_worth'),
|
||||
'accountType' => $this->string('type'),
|
||||
'account_type_id' => null,
|
||||
'currency_id' => $this->integer('currency_id'),
|
||||
@ -64,7 +65,21 @@ class AccountRequest extends Request
|
||||
'ccType' => $this->string('cc_type'),
|
||||
'ccMonthlyPaymentDate' => $this->string('cc_monthly_payment_date'),
|
||||
'notes' => $this->string('notes'),
|
||||
'interest' => $this->string('interest'),
|
||||
'interest_period' => $this->string('interest_period'),
|
||||
];
|
||||
// new fields for liabilities
|
||||
// 'liability_type' => $this->string('liability_type'),
|
||||
// 'liability_start_date' => $this->date('liability_start_date'),
|
||||
|
||||
|
||||
//];
|
||||
if ('liability' === $data['accountType']) {
|
||||
$data['openingBalance'] = bcmul($this->string('liability_amount'), '-1');
|
||||
$data['openingBalanceDate'] = $this->date('liability_start_date');
|
||||
$data['accountType'] = $this->string('liability_type');
|
||||
$data['account_type_id'] = null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
@ -91,10 +106,18 @@ class AccountRequest extends Request
|
||||
'account_number' => 'between:1,255|nullable|uniqueAccountNumberForUser',
|
||||
'account_role' => 'in:' . $accountRoles . '|required_if:type,asset',
|
||||
'active' => 'required|boolean',
|
||||
'include_net_worth' => 'required|boolean',
|
||||
'cc_type' => 'in:' . $ccPaymentTypes . '|required_if:account_role,ccAsset',
|
||||
'cc_monthly_payment_date' => 'date' . '|required_if:account_role,ccAsset|required_if:cc_type,monthlyFull',
|
||||
'type' => 'required|in:' . $types,
|
||||
'notes' => 'min:0|max:65536',
|
||||
// required fields for liabilities:
|
||||
'liability_type' => 'required_if:type,liability|in:loan,debt,mortgage,credit card',
|
||||
'liability_amount' => 'required_if:type,liability|min:0|numeric',
|
||||
'liability_start_date' => 'required_if:type,liability|date',
|
||||
'interest' => 'required_if:type,liability|between:0,100|numeric',
|
||||
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
|
||||
|
||||
];
|
||||
switch ($this->method()) {
|
||||
default:
|
||||
|
@ -181,6 +181,7 @@ return [
|
||||
'revenue' => 'Revenue accounts',
|
||||
'cash' => 'Cash accounts',
|
||||
'liabilities' => 'Liabilities',
|
||||
'liability' => 'Liabilities',
|
||||
],
|
||||
'subIconsByIdentifier' =>
|
||||
[
|
||||
@ -215,6 +216,7 @@ return [
|
||||
'import' => ['Import account'],
|
||||
'reconcile' => ['Reconciliation account'],
|
||||
'liabilities' => ['Loan', 'Debt', 'Mortgage', 'Credit card'],
|
||||
'liability' => ['Loan', 'Debt', 'Mortgage', 'Credit card'],
|
||||
],
|
||||
'shortNamesByFullName' =>
|
||||
[
|
||||
|
@ -125,12 +125,13 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'currency_id' => 1,
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
'opening_balance' => '123.45',
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'currency_id' => 1,
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
'opening_balance' => '123.45',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -165,11 +166,12 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'account_role' => 'ccAsset',
|
||||
'currency_id' => 1,
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'account_role' => 'ccAsset',
|
||||
'currency_id' => 1,
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -205,10 +207,11 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -280,11 +283,12 @@ class AccountControllerTest extends TestCase
|
||||
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => $account->name,
|
||||
'currency_id' => 1,
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
'name' => $account->name,
|
||||
'currency_id' => 1,
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -328,11 +332,12 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'currency_id' => 1,
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'currency_id' => 1,
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -374,11 +379,12 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'currency_code' => 'EUR',
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'currency_code' => 'EUR',
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -417,11 +423,12 @@ class AccountControllerTest extends TestCase
|
||||
$account = $this->user()->accounts()->first();
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => $account->name,
|
||||
'currency_id' => 1,
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
'name' => $account->name,
|
||||
'currency_id' => 1,
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -461,11 +468,12 @@ class AccountControllerTest extends TestCase
|
||||
$account = $this->user()->accounts()->first();
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => $account->name,
|
||||
'currency_code' => 'EUR',
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
'name' => $account->name,
|
||||
'currency_code' => 'EUR',
|
||||
'type' => 'asset',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
// test API
|
||||
|
Loading…
Reference in New Issue
Block a user