mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-04 11:43:02 +00:00
Make sure edit of liability always works.
This commit is contained in:
@@ -82,7 +82,8 @@ class AccountFormRequest extends FormRequest
|
||||
$data['account_type_name'] = null;
|
||||
$data['account_type_id'] = $this->convertInteger('liability_type_id');
|
||||
if ('' !== $data['opening_balance']) {
|
||||
$data['opening_balance'] = app('steam')->negative($data['opening_balance']);
|
||||
// opening balance is always positive for liabilities
|
||||
$data['opening_balance'] = app('steam')->positive($data['opening_balance']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -298,6 +298,11 @@ class AccountUpdateService
|
||||
$openingBalance = $data['opening_balance'];
|
||||
$openingBalanceDate = $data['opening_balance_date'];
|
||||
|
||||
// if liability, make sure the amount is positive for a credit, and negative for a debit.
|
||||
if($this->isLiability($account)) {
|
||||
$openingBalance = 'credit' === $data['liability_direction'] ? app('steam')->positive($openingBalance) : app('steam')->negative($openingBalance);
|
||||
}
|
||||
|
||||
$this->updateOBGroupV2($account, $openingBalance, $openingBalanceDate);
|
||||
}
|
||||
|
||||
|
16
public/v1/js/ff/accounts/edit.js
vendored
16
public/v1/js/ff/accounts/edit.js
vendored
@@ -30,5 +30,21 @@ $(document).ready(function () {
|
||||
}
|
||||
);
|
||||
}
|
||||
// change the 'ffInput_opening_balance' text based on the
|
||||
// selection of the direction.
|
||||
$("#ffInput_liability_direction").change(triggerDirection);
|
||||
triggerDirection();
|
||||
|
||||
});
|
||||
|
||||
function triggerDirection() {
|
||||
let obj = $("#ffInput_liability_direction");
|
||||
let direction = obj.val();
|
||||
console.log('Direction is now ' + direction);
|
||||
if('credit' === direction) {
|
||||
$('label[for="ffInput_opening_balance"]').text(iAmOwed);
|
||||
}
|
||||
if('debit' === direction) {
|
||||
$('label[for="ffInput_opening_balance"]').text(iOwe);
|
||||
}
|
||||
}
|
||||
|
@@ -1715,6 +1715,8 @@ return [
|
||||
'extension_date_is' => 'Extension date is {date}',
|
||||
|
||||
// accounts:
|
||||
'i_am_owed_amount' => 'I am owed amount',
|
||||
'i_owe_amount' => 'I owe amount',
|
||||
'inactive_account_link' => 'You have :count inactive (archived) account, which you can view on this separate page.|You have :count inactive (archived) accounts, which you can view on this separate page.',
|
||||
'all_accounts_inactive' => 'These are your inactive accounts.',
|
||||
'active_account_link' => 'This link goes back to your active accounts.',
|
||||
@@ -2468,7 +2470,7 @@ return [
|
||||
|
||||
// recurring transactions
|
||||
'create_right_now' => 'Create right now',
|
||||
'no_new_transaction_in_recurrence' => 'No new transaction was created. Perhaps it was already fired for this date?',
|
||||
'no_new_transaction_in_recurrence' => 'No new transaction was created. Perhaps it was already fired for this date?',
|
||||
'recurrences' => 'Recurring transactions',
|
||||
'repeat_until_in_past' => 'This recurring transaction stopped repeating on :date.',
|
||||
'recurring_calendar_view' => 'Calendar',
|
||||
|
@@ -35,7 +35,7 @@
|
||||
|
||||
{% if objectType == 'liabilities' %}
|
||||
{{ ExpandedForm.select('liability_type_id', liabilityTypes) }}
|
||||
{{ ExpandedForm.amountNoCurrency('opening_balance', null, {label:'debt_start_amount'|_, helpText: 'debt_start_amount_help'|_}) }}
|
||||
{{ ExpandedForm.amountNoCurrency('opening_balance', null, {label:'debt_start_amount'|_}) }}
|
||||
{{ ExpandedForm.select('liability_direction', liabilityDirections) }}
|
||||
{{ ExpandedForm.date('opening_balance_date', null, {label:'debt_start_date'|_}) }}
|
||||
{{ ExpandedForm.percentage('interest') }}
|
||||
@@ -115,6 +115,10 @@
|
||||
</form>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script type="text/javascript" nonce="{{ JS_NONCE }}">
|
||||
var iAmOwed = '{{ 'i_am_owed_amount'|_|escape('js') }}';
|
||||
var iOwe = '{{ 'i_owe_amount'|_|escape('js') }}';
|
||||
</script>
|
||||
<script src="v1/lib/leaflet/leaflet.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
|
||||
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
|
||||
<script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
|
||||
|
Reference in New Issue
Block a user