+ if (defined $posting->{amount}) {
+ push @line, $self->_format_amount($posting->{amount}, $posting->{commodity});
+ my $lot = $posting->{lot} || {};
+ if (my $lot_price = $lot->{price} // $posting->{lot_price}) {
+ my $is_fixed = $lot_price->{fixed} // $posting->{lot_fixed};
+ my $fixed_symbol = $is_fixed ? '=' : '';
+ push @line, " {${fixed_symbol}",
+ $self->_format_amount($lot_price->{amount}, $lot_price->{commodity}),
+ '}';
+ }
+ if (my $lot_date = $lot->{date} // $posting->{lot_date}) {
+ push @line, " [${lot_date}]";
+ }
+ if (my $lot_note = $self->_format_string($lot->{note} // $posting->{lot_note} // '')) {
+ $lot_note =~ s/[\(\)]+//; # cleanup
+ $lot_note =~ s/^\@+//;
+ push @line, " (${lot_note})" if $lot_note;
+ }
+ if (my $cost = $posting->{total_cost} // $posting->{cost}) {
+ my $is_total = defined $posting->{total_cost};
+ my $cost_symbol = $is_total ? '@@' : '@';
+ push @line, ' ', $cost_symbol, ' ',
+ $self->_format_amount($cost->{amount}, $cost->{commodity});
+ }
+ }
+ 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}";
+ }