- if (my $note = $posting->{note}) {
- $note = $self->_format_string($note);
- push @line, " ; $note" if $note ne $memo;
+ my $posting_date = $posting->{date} || '';
+ my $posting_aux_date = $posting->{aux_date} || '';
+ my $posting_note = $self->_format_string($posting->{note} // $posting->{memo} // '');
+ $posting_date = '' if $posting_date eq $date;
+ $posting_aux_date = '' if $posting_aux_date eq $aux_date;
+ $posting_note = '' if $has_note && $posting_note eq $note;
+ my $has_posting_note = defined $posting_note && $posting_note ne '';
+ if ($posting_date || $posting_aux_date || $has_posting_note) {
+ if ($posting_date || $posting_aux_date) {
+ $posting_note = sprintf('[%s%s]%s',
+ $posting_date,
+ $posting_aux_date && "=${posting_aux_date}",
+ $has_posting_note && " ${posting_note}",
+ );
+ }
+ push @line, " ; ${posting_note}";