Files
scripts_serv/ledger/custom/balance_sheet.tex
T
2026-10-02 22:35:11 +02:00

137 lines
3.7 KiB
TeX

<?lsmb# This is a comment block; it's ignored by the template engine.
Version: 1.4
Date: 2025-08-31
File: balance_sheet.tex
Set: demo
Template version numbers are explicitly not aligned across templates or
releases. No explicit versioning was applied before 2021-01-04.
Version Changes
1.1 Merged xelatex targetting templates with those targetting pdflatex
1.2 Fixed company address not showing
1.3 Simplify indentation calculations; as of 1.13, many pre-calculated
values are provided as variables
1.4 Support for sections in the column dimension (used for
foreign currency reports)
-?>
<?lsmb FILTER latex { format="$FORMAT($PROCESSOR)" } -?>
<?lsmb
max_col_path_depth = report.cheads.max_path_depth;
max_row_path_depth = report.rheads.max_path_depth;
leaf_columns = 0;
FOREACH col IN report.sorted_col_ids ;
IF report.cheads.ids.$col.is_leaf ;
leaf_columns = leaf_columns + 1;
END;
END;
last_col_no = max_row_path_depth + 1 + leaf_columns;
IF report.legacy_hierarchy ;
hierarchy = 'flat-hierarchy';
ELSE ;
hierarchy = 'full-hierarchy';
END ;
-?>
\documentclass[10pt]{article}
\usepackage{longtable}
\usepackage{multirow}
\usepackage[<?lsmb SETTINGS.papersize ?>paper,top=2cm,bottom=1.5cm,left=1.1cm,right=1.5cm]{geometry}
\begin{document}
\renewcommand\baselinestretch{1.2}\selectfont
\begin{center}
\Huge{<?lsmb text('Balance Sheet') ?>}
<?lsmb HLINES.1 ?>
\small{
\texttt{<?lsmb SETTINGS.company_name ?>}
\texttt{<?lsmb SETTINGS.company_address ?>}
}
\end{center}
\begin{longtable}{@{\extracolsep{10pt}}<?lsmb l = 'l'; l.repeat(max_row_path_depth) -?>p{2cm}<?lsmb
l = 'r'; l.repeat(report.sorted_col_ids.size); -?>}
\\
<?lsmb head_level = 1;
WHILE head_level <= max_col_path_depth; ?>
\multicolumn{<?lsmb max_row_path_depth ?>}{l}{} &%
<?lsmb
FOREACH col IN report.sorted_col_ids;
IF report.cheads.ids.$col.props.section_for;
NEXT;
END;
IF head_level == report.cheads.ids.$col.path.size ;
' & \multicolumn{'; report.cheads.ids.$col.leaves ; '}{l}{\multirow{'; report.cheads.ids.$col.is_leaf ? (max_col_path_depth - report.cheads.ids.$col.path.size + 1) : 1 ; '}{*}{\shortstack{';
report.cheads.ids.$col.props.description ;
'}}} ';
ELSIF head_level > report.cheads.ids.$col.path.size ;
' & ';
END;
END;
?> \\
<?lsmb head_level = head_level + 1;
END ?>
\\
<?lsmb FOREACH row IN report.sorted_row_ids;
row_data = report.rheads.ids.$row;
path_depth = row_data.path_depth;
path_prefix_len = row_data.path_prefix_len;
path_suffix_len = row_data.path_suffix_len;
IF row_data.props.section_for ;
IF row_data.heading_props.account_category == 'QL';
NEXT;
END;
END;
desc = row_data.props.row_description;
IF report.rheads.ids.$row.props.account_type != 'A';
IF NOT report.rheads.ids.$row.props.section_for ;
'\cline{' _ path_depth _ '-' _ last_col_no _ '} ';
ELSE;
desc = '\Large{' _ row_data.props.row_description _ '}';
END;
desc = '\textbf{\emph{' _ desc _ '}}';
END;
-?>%
<?lsmb amp = '& '; amp.repeat(path_prefix_len); -?>
<?lsmb IF path_suffix_len > 1 -?>
\multicolumn{<?lsmb path_suffix_len ?>}{l}{<?lsmb desc ?>}%
<?lsmb ELSE; ?>
<?lsmb desc ?>
<?lsmb END -?>
%
& %
<?lsmb FOREACH col IN report.sorted_col_ids;
IF report.cheads.ids.$col.props.section_for;
NEXT;
END;
' & '; report.cells.$row.$col;
END; -?>
%
\\
%
<?lsmb IF row_data.props.account_type != 'A'; -?>
<?lsmb IF row_data.props.section_for; -?>
\cline{<?lsmb path_depth ?>-<?lsmb last_col_no ?>}
\noalign{\vskip 2pt}
\cline{<?lsmb path_depth ?>-<?lsmb last_col_no ?>}
<?lsmb ELSE -?>
\\
<?lsmb END -?>
<?lsmb END ?>
<?lsmb END ?>
\end{longtable}
\end{document}
<?lsmb END -?>