- line_keys = self.postvars.keys_prefixed('line_')
- lineno_to_inputs: dict[int, list[str]] = {}
- for key in line_keys:
- toks = key.split('_', maxsplit=2)
- lineno = int(toks[1])
- if lineno not in lineno_to_inputs:
- lineno_to_inputs[lineno] = []
- lineno_to_inputs[lineno] += [toks[2]]
- new_dat_lines = []
- indent = ' '
- for lineno, input_names in lineno_to_inputs.items():
- data = ''
- comment = self.postvars.first(f'line_{lineno}_comment')
- for name in input_names:
- input_ = self.postvars.first(f'line_{lineno}_{name}')
- if name == 'date':
- data = input_
- elif name == 'target':
- data += f' {input_}'
- elif name == 'error':
- data = f'{indent}{input_}'
- elif name == 'account':
- data = f'{indent}{input_}'
- elif name in {'amount', 'currency'}:
- data += f' {input_}'
- new_dat_lines += [
+ if self.postvars.first('apply'):
+ line_keys = self.postvars.keys_prefixed('line_')
+ lineno_to_inputs: dict[int, list[str]] = {}
+ for key in line_keys:
+ toks = key.split('_', maxsplit=2)
+ lineno = int(toks[1])
+ if lineno not in lineno_to_inputs:
+ lineno_to_inputs[lineno] = []
+ lineno_to_inputs[lineno] += [toks[2]]
+ new_dat_lines = []
+ indent = ' '
+ for lineno, input_names in lineno_to_inputs.items():
+ data = ''
+ comment = self.postvars.first(f'line_{lineno}_comment')
+ for name in input_names:
+ input_ = self.postvars.first(f'line_{lineno}_{name}')
+ if name == 'date':
+ data = input_
+ elif name == 'target':
+ data += f' {input_}'
+ elif name == 'error':
+ data = f'{indent}{input_}'
+ elif name == 'account':
+ data = f'{indent}{input_}'
+ elif name in {'amount', 'currency'}:
+ data += f' {input_}'
+ new_dat_lines += [