mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Code for #1324
This commit is contained in:
@@ -28,13 +28,20 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -70,6 +77,7 @@ class UpgradeDatabase extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->migrateBillsToRules();
|
||||
$this->setTransactionIdentifier();
|
||||
$this->updateAccountCurrencies();
|
||||
$this->createNewTypes();
|
||||
@@ -79,9 +87,118 @@ class UpgradeDatabase extends Command
|
||||
$this->line('Done updating currency information..');
|
||||
$this->migrateNotes();
|
||||
$this->migrateAttachmentData();
|
||||
$this->info('Firefly III database is up to date.');
|
||||
|
||||
return;
|
||||
$this->info('Firefly III database is up to date.');
|
||||
}
|
||||
|
||||
public function migrateBillsToRules()
|
||||
{
|
||||
foreach (User::get() as $user) {
|
||||
/** @var Preference $lang */
|
||||
$lang = Preferences::getForUser($user, 'language', 'en_US');
|
||||
$groupName = (string)trans('firefly.rulegroup_for_bills_title', [], $lang->data);
|
||||
$ruleGroup = $user->ruleGroups()->where('title', $groupName)->first();
|
||||
$currencyPreference = Preferences::getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
|
||||
|
||||
if ($ruleGroup === null) {
|
||||
$array = RuleGroup::get(['order'])->pluck('order')->toArray();
|
||||
$order = count($array) > 0 ? max($array) + 1 : 1;
|
||||
$ruleGroup = RuleGroup::create(
|
||||
[
|
||||
'user_id' => $user->id,
|
||||
'title' => (string)trans('firefly.rulegroup_for_bills_title', [], $lang->data),
|
||||
'description' => (string)trans('firefly.rulegroup_for_bills_description', [], $lang->data),
|
||||
'order' => $order,
|
||||
'active' => 1,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// loop bills.
|
||||
$order = 1;
|
||||
/** @var Bill $bill */
|
||||
foreach ($user->bills()->get() as $bill) {
|
||||
if ($bill->match !== 'MIGRATED_TO_RULES') {
|
||||
$rule = Rule::create(
|
||||
[
|
||||
'user_id' => $user->id,
|
||||
'rule_group_id' => $ruleGroup->id,
|
||||
'title' => (string)trans('firefly.rule_for_bill_title', ['name' => $bill->name], $lang->data),
|
||||
'description' => (string)trans('firefly.rule_for_bill_description', ['name' => $bill->name], $lang->data),
|
||||
'order' => $order,
|
||||
'active' => 1,
|
||||
'stop_processing' => 1,
|
||||
]
|
||||
);
|
||||
// add default trigger
|
||||
RuleTrigger::create(
|
||||
[
|
||||
'rule_id' => $rule->id,
|
||||
'trigger_type' => 'user_action',
|
||||
'trigger_value' => 'store-journal',
|
||||
'active' => 1,
|
||||
'stop_processing' => 0,
|
||||
'order' => 1,
|
||||
]
|
||||
);
|
||||
// add trigger for description
|
||||
$match = implode(' ', explode(',', $bill->match));
|
||||
RuleTrigger::create(
|
||||
[
|
||||
'rule_id' => $rule->id,
|
||||
'trigger_type' => 'description_is',
|
||||
'trigger_value' => $match,
|
||||
'active' => 1,
|
||||
'stop_processing' => 0,
|
||||
'order' => 2,
|
||||
]
|
||||
);
|
||||
|
||||
// add triggers for amounts:
|
||||
RuleTrigger::create(
|
||||
[
|
||||
'rule_id' => $rule->id,
|
||||
'trigger_type' => 'amount_less',
|
||||
'trigger_value' => round($bill->amount_max, $currency->decimal_places),
|
||||
'active' => 1,
|
||||
'stop_processing' => 0,
|
||||
'order' => 3,
|
||||
]
|
||||
);
|
||||
RuleTrigger::create(
|
||||
[
|
||||
'rule_id' => $rule->id,
|
||||
'trigger_type' => 'amount_more',
|
||||
'trigger_value' => round($bill->amount_min, $currency->decimal_places),
|
||||
'active' => 1,
|
||||
'stop_processing' => 0,
|
||||
'order' => 4,
|
||||
]
|
||||
);
|
||||
|
||||
// create action
|
||||
RuleAction::create(
|
||||
[
|
||||
'rule_id' => $rule->id,
|
||||
'action_type' => 'link_to_bill',
|
||||
'action_value' => $bill->name,
|
||||
'order' => 1,
|
||||
'active' => 1,
|
||||
'stop_processing' => 0,
|
||||
]
|
||||
);
|
||||
|
||||
$order++;
|
||||
//$bill->match = 'MIGRATED_TO_RULES';
|
||||
$bill->save();
|
||||
$this->line(sprintf('Updated bill #%d ("%s") so it will use rules.', $bill->id, $bill->name));
|
||||
}
|
||||
}
|
||||
|
||||
$this->line('Exit');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -45,22 +45,19 @@ class BillFactory
|
||||
*/
|
||||
public function create(array $data): ?Bill
|
||||
{
|
||||
$matchArray = explode(',', $data['match']);
|
||||
$matchArray = array_unique($matchArray);
|
||||
$match = implode(',', $matchArray);
|
||||
|
||||
/** @var Bill $bill */
|
||||
$bill = Bill::create(
|
||||
[
|
||||
'name' => $data['name'],
|
||||
'match' => $match,
|
||||
'match' => 'MIGRATED_TO_RULES',
|
||||
'amount_min' => $data['amount_min'],
|
||||
'user_id' => $this->user->id,
|
||||
'currency_id' => $data['currency_id'],
|
||||
'amount_max' => $data['amount_max'],
|
||||
'date' => $data['date'],
|
||||
'repeat_freq' => $data['repeat_freq'],
|
||||
'skip' => $data['skip'],
|
||||
'automatch' => $data['automatch'],
|
||||
'automatch' => true,
|
||||
'active' => $data['active'],
|
||||
]
|
||||
);
|
||||
@@ -94,7 +91,7 @@ class BillFactory
|
||||
}
|
||||
|
||||
// then find by name:
|
||||
if (strlen($billName) > 0) {
|
||||
if (\strlen($billName) > 0) {
|
||||
$bill = $this->findByName($billName);
|
||||
if (null !== $bill) {
|
||||
return $bill;
|
||||
|
@@ -71,7 +71,7 @@ class TagFactory
|
||||
|
||||
/** @var Tag $object */
|
||||
foreach ($this->tags as $object) {
|
||||
if ($object->tag === $tag) {
|
||||
if (strtolower($object->tag) === strtolower($tag)) {
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use ExpandedForm;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Http\Requests\BillFormRequest;
|
||||
@@ -29,6 +30,8 @@ use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\Transformers\BillTransformer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -76,13 +79,15 @@ class BillController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(Request $request)
|
||||
public function create(Request $request, CurrencyRepositoryInterface $repository)
|
||||
{
|
||||
$periods = [];
|
||||
foreach (config('firefly.bill_periods') as $current) {
|
||||
$periods[$current] = strtolower((string)trans('firefly.repeat_freq_' . $current));
|
||||
}
|
||||
$subTitle = trans('firefly.create_new_bill');
|
||||
$subTitle = trans('firefly.create_new_bill');
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$currencies = ExpandedForm::makeSelectList($repository->get());
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (true !== session('bills.create.fromStore')) {
|
||||
@@ -90,7 +95,7 @@ class BillController extends Controller
|
||||
}
|
||||
$request->session()->forget('bills.create.fromStore');
|
||||
|
||||
return view('bills.create', compact('periods', 'subTitle'));
|
||||
return view('bills.create', compact('periods', 'subTitle', 'currencies', 'defaultCurrency'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +275,7 @@ class BillController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(BillFormRequest $request, BillRepositoryInterface $repository)
|
||||
public function store(BillFormRequest $request, BillRepositoryInterface $repository, RuleGroupRepositoryInterface $ruleGroupRepository)
|
||||
{
|
||||
$billData = $request->getBillData();
|
||||
$bill = $repository->store($billData);
|
||||
@@ -291,16 +296,22 @@ class BillController extends Controller
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('bills.create.fromStore', true);
|
||||
|
||||
return redirect(route('bills.create'))->withInput();
|
||||
// @codeCoverageIgnoreEnd
|
||||
// find first rule group, or create one:
|
||||
$count = $ruleGroupRepository->count();
|
||||
if ($count === 0) {
|
||||
$data = [
|
||||
'title' => (string)trans('firefly.rulegroup_for_bills_title'),
|
||||
'description' => (string)trans('firefly.rulegroup_for_bills_description'),
|
||||
];
|
||||
$group = $ruleGroupRepository->store($data);
|
||||
}
|
||||
if ($count > 0) {
|
||||
$group = $ruleGroupRepository->getActiveGroups(auth()->user())->first();
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
return redirect($this->getPreviousUri('bills.create.uri'));
|
||||
|
||||
// redirect to page that will create a new rule.
|
||||
return redirect(route('rules.create', [$group->id]) . '?fromBill=' . $bill->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -34,6 +34,7 @@ use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\TransactionMatcher;
|
||||
@@ -75,8 +76,11 @@ class RuleController extends Controller
|
||||
|
||||
|
||||
*/
|
||||
public function create(Request $request, RuleGroup $ruleGroup)
|
||||
public function create(Request $request, RuleGroupRepositoryInterface $ruleGroupRepository, BillRepositoryInterface $billRepository, RuleGroup $ruleGroup)
|
||||
{
|
||||
$bill = null;
|
||||
$billId = (int)$request->get('fromBill');
|
||||
$preFilled = [];
|
||||
// count for possible present previous entered triggers/actions.
|
||||
$triggerCount = 0;
|
||||
$actionCount = 0;
|
||||
@@ -89,12 +93,60 @@ class RuleController extends Controller
|
||||
if ($request->old()) {
|
||||
// process old triggers.
|
||||
$oldTriggers = $this->getPreviousTriggers($request);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$triggerCount = \count($oldTriggers);
|
||||
|
||||
// process old actions
|
||||
$oldActions = $this->getPreviousActions($request);
|
||||
$actionCount = count($oldActions);
|
||||
$actionCount = \count($oldActions);
|
||||
}
|
||||
if ($billId > 0) {
|
||||
$bill = $billRepository->find($billId);
|
||||
// create some sensible defaults:
|
||||
$preFilled['title'] = trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]);
|
||||
$preFilled['description'] = trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]);
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
// pretend there are old triggers, so the page will fill them in:
|
||||
$oldTriggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => 'amount_more',
|
||||
'oldValue' => round($bill->amount_min,12),
|
||||
'oldChecked' => false,
|
||||
'count' => 1,
|
||||
]
|
||||
)->render();
|
||||
$oldTriggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => 'amount_less',
|
||||
'oldValue' => round($bill->amount_max,12),
|
||||
'oldChecked' => false,
|
||||
'count' => 2,
|
||||
]
|
||||
)->render();
|
||||
$oldTriggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => 'description_contains',
|
||||
'oldValue' => $bill->name,12,
|
||||
'oldChecked' => false,
|
||||
'count' => 3,
|
||||
]
|
||||
)->render();
|
||||
|
||||
$oldActions[] = view(
|
||||
'rules.partials.action',
|
||||
[
|
||||
'oldAction' => 'link_to_bill',
|
||||
'oldValue' => $bill->name,
|
||||
'oldChecked' => false,
|
||||
'count' => 1,
|
||||
]
|
||||
)->render();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$subTitleIcon = 'fa-clone';
|
||||
$subTitle = trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
@@ -107,7 +159,7 @@ class RuleController extends Controller
|
||||
|
||||
return view(
|
||||
'rules.rule.create',
|
||||
compact('subTitleIcon', 'oldTriggers', 'oldActions', 'triggerCount', 'actionCount', 'ruleGroup', 'subTitle')
|
||||
compact('subTitleIcon', 'oldTriggers', 'preFilled', 'bill', 'oldActions', 'triggerCount', 'actionCount', 'ruleGroup', 'subTitle')
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -42,18 +42,15 @@ class BillFormRequest extends Request
|
||||
public function getBillData()
|
||||
{
|
||||
return [
|
||||
'name' => $this->string('name'),
|
||||
'match' => $this->string('match'),
|
||||
'amount_min' => $this->string('amount_min'),
|
||||
'amount_currency_id_amount_min' => $this->integer('amount_currency_id_amount_min'),
|
||||
'amount_currency_id_amount_max' => $this->integer('amount_currency_id_amount_max'),
|
||||
'amount_max' => $this->string('amount_max'),
|
||||
'date' => $this->date('date'),
|
||||
'repeat_freq' => $this->string('repeat_freq'),
|
||||
'skip' => $this->integer('skip'),
|
||||
'automatch' => $this->boolean('automatch'),
|
||||
'active' => $this->boolean('active'),
|
||||
'notes' => $this->string('notes'),
|
||||
'name' => $this->string('name'),
|
||||
'amount_min' => $this->string('amount_min'),
|
||||
'currency_id' => $this->integer('currency_id'),
|
||||
'amount_max' => $this->string('amount_max'),
|
||||
'date' => $this->date('date'),
|
||||
'repeat_freq' => $this->string('repeat_freq'),
|
||||
'skip' => $this->integer('skip'),
|
||||
'active' => $this->boolean('active'),
|
||||
'notes' => $this->string('notes'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -62,25 +59,22 @@ class BillFormRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$nameRule = 'required|between:1,255|uniqueObjectForUser:bills,name';
|
||||
$matchRule = 'required|between:1,255|uniqueObjectForUser:bills,match';
|
||||
$nameRule = 'required|between:1,255|uniqueObjectForUser:bills,name';
|
||||
if ($this->integer('id') > 0) {
|
||||
$nameRule .= ',' . $this->integer('id');
|
||||
$matchRule .= ',' . $this->integer('id');
|
||||
// todo is a fix to do this better.
|
||||
$nameRule .= ',' . $this->integer('id');
|
||||
}
|
||||
// is OK
|
||||
$rules = [
|
||||
'name' => $nameRule,
|
||||
'match' => $matchRule,
|
||||
'amount_min' => 'required|numeric|more:0',
|
||||
'amount_max' => 'required|numeric|more:0',
|
||||
'amount_currency_id_amount_min' => 'required|exists:transaction_currencies,id',
|
||||
'amount_currency_id_amount_max' => 'required|exists:transaction_currencies,id',
|
||||
'date' => 'required|date',
|
||||
'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly',
|
||||
'skip' => 'required|between:0,31',
|
||||
'automatch' => 'in:1',
|
||||
'active' => 'in:1',
|
||||
'name' => $nameRule,
|
||||
'amount_min' => 'required|numeric|more:0',
|
||||
'amount_max' => 'required|numeric|more:0',
|
||||
'currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'date' => 'required|date',
|
||||
'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly',
|
||||
'skip' => 'required|between:0,31',
|
||||
'automatch' => 'in:1',
|
||||
'active' => 'in:1',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
|
@@ -57,7 +57,7 @@ class Bill extends Model
|
||||
*/
|
||||
protected $fillable
|
||||
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
|
||||
'automatch', 'active',];
|
||||
'automatch', 'active','currency_id'];
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@@ -47,6 +47,8 @@ class Rule extends Model
|
||||
'order' => 'int',
|
||||
'stop_processing' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $fillable = ['rule_group_id', 'order', 'active', 'title', 'description', 'user_id'];
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
|
@@ -43,6 +43,9 @@ class RuleAction extends Model
|
||||
'stop_processing' => 'boolean',
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
protected $fillable = ['rule_id', 'action_type', 'action_value', 'order', 'active', 'stop_processing'];
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@@ -43,6 +43,9 @@ class RuleTrigger extends Model
|
||||
'stop_processing' => 'boolean',
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
protected $fillable = ['rule_id', 'trigger_type', 'trigger_value', 'order', 'active', 'stop_processing'];
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@@ -50,8 +50,6 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public function destroy(RuleGroup $ruleGroup, ?RuleGroup $moveTo): bool
|
||||
{
|
||||
|
@@ -51,7 +51,7 @@ trait JournalServiceTrait
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
foreach ($data['tags'] as $string) {
|
||||
if (strlen($string) > 0) {
|
||||
if (\strlen($string) > 0) {
|
||||
$tag = $factory->findOrCreate($string);
|
||||
$set[] = $tag->id;
|
||||
}
|
||||
|
@@ -52,6 +52,34 @@ class ExpandedForm
|
||||
return $this->currencyField($name, 'amount', $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function amountNoCurrency(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
unset($options['currency'], $options['placeholder']);
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (null !== $value && '' !== $value) {
|
||||
$value = round($value, 8);
|
||||
}
|
||||
|
||||
$html = view('form.amount-no-currency', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param null $value
|
||||
|
@@ -128,8 +128,9 @@ return [
|
||||
'expected_in_period' => ['element' => '.expected_in_period'],
|
||||
],
|
||||
'bills_create' => [
|
||||
'intro' => [],
|
||||
'name' => ['element' => '#name_holder'],
|
||||
'match' => ['element' => '#match_holder'],
|
||||
//'match' => ['element' => '#match_holder'],
|
||||
'amount_min_holder' => ['element' => '#amount_min_holder'],
|
||||
'repeat_freq_holder' => ['element' => '#repeat_freq_holder'],
|
||||
'skip_holder' => ['element' => '#skip_holder'],
|
||||
|
@@ -188,7 +188,7 @@ return [
|
||||
'is_safe' => [
|
||||
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
|
||||
'multiRadio', 'file', 'multiCheckbox', 'staticText', 'amountSmall', 'password', 'nonSelectableBalance', 'nonSelectableAmount',
|
||||
'number', 'assetAccountList',
|
||||
'number', 'assetAccountList','amountNoCurrency'
|
||||
],
|
||||
],
|
||||
'Form' => [
|
||||
|
36
database/migrations/2018_04_07_210913_changes_for_v473.php
Normal file
36
database/migrations/2018_04_07_210913_changes_for_v473.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV473
|
||||
*/
|
||||
class ChangesForV473 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table(
|
||||
'bills',
|
||||
function (Blueprint $table) {
|
||||
$table->integer('currency_id', false, true)->nullable()->after('user_id');
|
||||
$table->foreign('currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@@ -410,6 +410,14 @@ return [
|
||||
|
||||
'rules_have_read_warning' => 'Have you read the warning?',
|
||||
'apply_rule_warning' => 'Warning: running a rule(group) on a large selection of transactions could take ages, and it could time-out. If it does, the rule(group) will only be applied to an unknown subset of your transactions. This might leave your financial administration in tatters. Please be careful.',
|
||||
'rulegroup_for_bills_title' => 'Rule group for bills',
|
||||
'rulegroup_for_bills_description' => 'A special rule group for all the rules that involve bills.',
|
||||
'rule_for_bill_title' => 'Auto-generated rule for bill ":name"',
|
||||
'rule_for_bill_description' => 'This rule is auto-generated to try to match bill ":name".',
|
||||
'create_rule_for_bill' => 'Create a new rule for bill ":name"',
|
||||
'create_rule_for_bill_txt' => 'You have just created a new bill called ":name", congratulations! Firefly III can automagically match new withdrawals to this bill. For example, whenever you pay your rent, the bill "rent" will be linked to the expense. This way, Firefly III can accurately show you which bills are due and which ones aren\'t. In order to do so, a new rule must be created. Firefly III has filled in some sensible defaults for you. Please make sure these are correct. If these values are correct, Firefly III will automatically link the correct withdrawal to the correct bill. Please check out the triggers to see if they are correct, and add some if they\'re wrong.',
|
||||
'new_rule_for_bill_title' => 'Rule for bill ":name"',
|
||||
'new_rule_for_bill_description' => 'This rule marks transactions for bill ":name".',
|
||||
|
||||
// tags
|
||||
'store_new_tag' => 'Store new tag',
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* intro.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -100,11 +101,12 @@ return [
|
||||
'bills_show_billChart' => 'This chart shows the transactions linked to this bill.',
|
||||
|
||||
// create bill
|
||||
'bills_create_intro' => 'Use bills to track the amount of money you\'re due every period. Think about expenses like rent, insurance or mortgage payments.',
|
||||
'bills_create_name' => 'Use a descriptive name such as "Rent" or "Health insurance".',
|
||||
'bills_create_match' => 'To match transactions, use terms from those transactions or the expense account involved. All words must match.',
|
||||
//'bills_create_match' => 'To match transactions, use terms from those transactions or the expense account involved. All words must match.',
|
||||
'bills_create_amount_min_holder' => 'Select a minimum and maximum amount for this bill.',
|
||||
'bills_create_repeat_freq_holder' => 'Most bills repeat monthly, but you can set another frequency here.',
|
||||
'bills_create_skip_holder' => 'If a bill repeats every 2 weeks for example, the "skip"-field should be set to "1" to skip every other week.',
|
||||
'bills_create_skip_holder' => 'If a bill repeats every 2 weeks, the "skip"-field should be set to "1" to skip every other week.',
|
||||
|
||||
// rules index
|
||||
'rules_index_intro' => 'Firefly III allows you to manage rules, that will automagically be applied to any transaction you create or edit.',
|
||||
|
@@ -17,9 +17,9 @@
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.text('name') }}
|
||||
{{ ExpandedForm.tags('match') }}
|
||||
{{ ExpandedForm.amount('amount_min') }}
|
||||
{{ ExpandedForm.amount('amount_max') }}
|
||||
{{ ExpandedForm.select('currency_id',currencies, defaultCurrency.id) }}
|
||||
{{ ExpandedForm.amountNoCurrency('amount_min') }}
|
||||
{{ ExpandedForm.amountNoCurrency('amount_max') }}
|
||||
{{ ExpandedForm.date('date',phpdate('Y-m-d')) }}
|
||||
{{ ExpandedForm.select('repeat_freq',periods,'monthly') }}
|
||||
</div>
|
||||
@@ -35,9 +35,7 @@
|
||||
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
|
||||
{{ ExpandedForm.integer('skip',0) }}
|
||||
{{ ExpandedForm.checkbox('automatch',1,true) }}
|
||||
{{ ExpandedForm.checkbox('active',1,true) }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
7
resources/views/form/amount-no-currency.twig
Normal file
7
resources/views/form/amount-no-currency.twig
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="{{ classes }}" id="{{ name }}_holder">
|
||||
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
|
||||
<div class="col-sm-8">
|
||||
{{ Form.input('number', name, value, options) }}
|
||||
{% include 'form/feedback' %}
|
||||
</div>
|
||||
</div>
|
@@ -5,8 +5,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="hidden-sm hidden-xs" data-defaultsort="disabled"> </th>
|
||||
<th>{{ trans('list.name') }}</th>
|
||||
<th data-defaultsign="az" class="hidden-sm hidden-md hidden-xs">{{ trans('list.matchesOn') }}</th>
|
||||
<th data-defaultsign="az">{{ trans('list.name') }}</th>
|
||||
<th data-defaultsort="disabled" class="hidden-sm hidden-md hidden-xs">{{ trans('list.linked_to_rules') }}</th>
|
||||
<th data-defaultsign="_19" style="text-align: right;">{{ trans('list.matchingAmount') }}</th>
|
||||
<th data-defaultsign="month" class="hidden-sm hidden-xs">{{ trans('list.paid_current_period') }}</th>
|
||||
<th data-defaultsign="month" class="hidden-sm hidden-xs">{{ trans('list.next_expected_match') }}</th>
|
||||
@@ -42,10 +42,8 @@
|
||||
{% endif %}
|
||||
|
||||
</td>
|
||||
<td class="hidden-sm hidden-md hidden-xs" data-value="{{ entry.match|join(',') }}">
|
||||
{% for match in entry.match %}
|
||||
<span class="label label-info">{{ match }}</span>
|
||||
{% endfor %}
|
||||
<td class="hidden-sm hidden-md hidden-xs">
|
||||
(rules)
|
||||
</td>
|
||||
<td data-value="{{ entry.amount_min }}" style="text-align: right;">
|
||||
<span style="margin-right:5px;" title="{{ entry.amount_min|formatAmountPlain }} - {{ entry.amount_max|formatAmountPlain }}">
|
||||
|
@@ -10,6 +10,22 @@
|
||||
<input name="_token" type="hidden" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="rule_group_id" value="{{ ruleGroup.id }}"/>
|
||||
<input type="hidden" name="active" value="1"/>
|
||||
{% if bill %}
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="box box-success" id="mandatory">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ trans('firefly.create_rule_for_bill', {name: bill.name}) }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p class="text-info">
|
||||
{{ trans('firefly.create_rule_for_bill_txt', {name: bill.name}) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="box box-primary" id="mandatory">
|
||||
|
Reference in New Issue
Block a user