% OWD 2023

\documentclass[
  fontsize=11pt,
  paper=a4,
  parskip=half,
  enlargefirstpage,
  fromalign=right,
  fromphone,
  fromlogo,
  addrfield,
  backaddress,
  subject=titled,
  foldmarks,
  firstfoot,
]{scrlttr2}

\usepackage[english]{babel}
\usepackage[calc]{datetime2}
\usepackage[letterspace=75]{microtype}
\usepackage{xcolor, zref-totpages, etoolbox, nth}

\newtoggle{llcopy}

% RECIPIENT DETAILS

\setkomavar{toname}{Mr. V. McMahon}
\newcommand{\housenumber}{-1}
\newcommand{\effectivefrom}{\DTMdisplaydate{1970}{1}{1}{0}}
\newcommand{\refcode}{000}
\toggletrue{llcopy}

% SENDER DETAILS

\setkomavar{fromname}{Mrs. Brenda Dixon}
\setkomavar{fromaddress}{29 Ridings Way \\ Lofthouse \\ Wakefield \\ WF3 3SJ}
\setkomavar{fromphone}{01924 826477}
\setkomavar{signature}{\usekomavar{fromname}, \\ The Landlord}
\setkomavar{date}{\today}
\setkomavar{title}{Advance Notice}
\setkomavar{subject}{Increased Rent for \housenumber\ Stanhope Road}
\setkomavar{toaddress}{\housenumber\ Stanhope Road \\ Thorpe \\ Wakefield
  \\ WF3 3DT}
\setkomavar{fromlogo}{%
  \parbox{.5\linewidth}{%
    \color{gray} \LARGE \itshape
    \fontfamily{qag} \selectfont
    B \& B Properties

    \vspace{.2em}
    \normalsize \upshape \lsstyle
    ``The Sensible Choice''
  }
}

% KOMASCRIPT FORMATTING DIRECTIVES

\setkomafont{subject}{\bfseries}
\setkomafont{backaddress}{\mdseries}
\setkomafont{title}{\scshape}

\setkomavar{backaddressseparator}{\enspace\textperiodcentered\enspace}
\setplength{sigbeforevskip}{3em}
\renewcommand{\arraystretch}{2.5}
\renewcommand{\raggedsignature}{\raggedright}
\AddToHook{env/tabular/begin}{\itshape}
\newcommand{\sigline}{\vrule height .2pt depth .2pt width 2in}

\setkomavar{firstfoot}{%
  \centering
  \parbox{\linewidth}{%
    \centering \scshape%
    \iftoggle{llcopy}{Landlord's Copy}{Tenants' Copy}%
    \normalfont \enspace\textperiodcentered\enspace \scshape%
    Page \thepage\ of \ztotpages
  }
}
\setkomavar{myref}{%
  \DTMsetdatestyle{refdate}%
  OWD-\today-\refcode%
  \iftoggle{llcopy}{L}{T}
}
\setkomavar{nextfoot}{\usekomavar{firstfoot}}
\pagestyle{myheadings}

% DATE-FORMATTING DIRECTIVES

\DTMnewdatestyle{refdate}{%
  \renewcommand*{\DTMdisplaydate}[4]{%
    \DTMtwodigits{##3}\DTMtwodigits{##2}\number##1}%
  \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}%
}

\DTMnewdatestyle{gbdate}{%
  \renewcommand*{\DTMdisplaydate}[4]{%
    \DTMweekdayname{##4}, \nth{\number##3}\ \DTMmonthname{##2} \number##1}%
  \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}%
}

\DTMsetdatestyle{gbdate}

% LETTER BODY

\begin{document}
  \begin{letter}{}
    \opening{Dear \usekomavar{toname},}

    In accordance with Section 13 of the Housing Act 1988, I am writing to
    inform you of a rent increase in the amount of £12.50 per week, to be
    effective from \effectivefrom. This constitutes a new weekly rate of £150,
    superseding the previous periodic charge of £137.50.

    By signing this document, you are affirming your acknowledgement and
    understanding of the revised agreement.

    \begin{center}
      \begin{tabular}{l@{\kern1em\sigline\kern2em}l@{\kern1em\sigline}}
        Landlord & Tenant \\
        Signed   & Signed \\
        Date     & Date   \\
      \end{tabular}
    \end{center}

    \closing{Sincerely,}
    \cc{Mrs. Brenda Dixon (Landlord's Records)}
  \end{letter}
\end{document}

