"""Formulas from sheet 'P&L' of 'fpna_month_end.xlsx'. Generated by Power Migrate 0.1.0a1 (no-AI mode). One function per logic block, in the order they appear on the sheet; ``model.compute`` runs them in dependency order. """ from .. import xl from ..xl import Book def month(book: Book) -> None: r"""Month 'P&L'!B2:M2 (12 columns, copied across). Excel (B2): =Revenue!B2 Pattern (R1C1): =Revenue!RC Reads: Revenue!B2 """ p_l = book['P&L'] revenue = book['Revenue'] for c in range(2, 14): p_l[2, c] = revenue[2, c] def revenue(book: Book) -> None: r"""Revenue 'P&L'!B3:M3 (12 columns, copied across). Excel (B3): =Revenue!B12 Pattern (R1C1): =Revenue!R[9]C Reads: Revenue!B12 """ p_l = book['P&L'] revenue = book['Revenue'] for c in range(2, 14): p_l[3, c] = revenue[12, c] def costs(book: Book) -> None: r"""Costs 'P&L'!B4:M4 (12 columns, copied across). Excel (B4): =Costs!B6 Pattern (R1C1): =Costs!R[2]C Reads: Costs!B6 """ p_l = book['P&L'] costs = book['Costs'] for c in range(2, 14): p_l[4, c] = costs[6, c] def gross_margin(book: Book) -> None: r"""Gross margin 'P&L'!B5:M5 (12 columns, copied across). Excel (B5): =B3-B4 Pattern (R1C1): =R[-2]C-R[-1]C Reads: 'P&L'!B3, 'P&L'!B4 """ p_l = book['P&L'] for c in range(2, 14): p_l[5, c] = p_l[3, c] - p_l[4, c] def margin(book: Book) -> None: r"""Margin % 'P&L'!B6:M6 (12 columns, copied across). Excel (B6): =IFERROR(B5/B3,"n/a") Pattern (R1C1): =IFERROR(R[-1]C/R[-3]C,"n/a") Reads: 'P&L'!B3, 'P&L'!B5 """ p_l = book['P&L'] for c in range(2, 14): p_l[6, c] = xl.IFERROR(p_l[5, c] / p_l[3, c], 'n/a') def tax(book: Book) -> None: r"""Tax 'P&L'!B7:M7 (12 columns, copied across). Excel (B7): =MAX(0,B5)*TaxRate Pattern (R1C1): =MAX(0,R[-2]C)*TaxRate Reads: Assumptions!B6, 'P&L'!B5, name TaxRate """ p_l = book['P&L'] for c in range(2, 14): p_l[7, c] = xl.MAX(0, p_l[5, c]) * book.name('TaxRate') def net_result(book: Book) -> None: r"""Net result 'P&L'!B8:M8 (12 columns, copied across). Excel (B8): =B5-B7 Pattern (R1C1): =R[-3]C-R[-1]C Reads: 'P&L'!B5, 'P&L'!B7 """ p_l = book['P&L'] for c in range(2, 14): p_l[8, c] = p_l[5, c] - p_l[7, c] def net_ytd(book: Book) -> None: r"""Net YTD 'P&L'!B9 (one cell). Excel (B9): =B8 Reads: 'P&L'!B8 """ p_l = book['P&L'] p_l["B9"] = p_l["B8"] def net_ytd_c9(book: Book) -> None: r"""Net YTD 'P&L'!C9:M9 (11 columns, copied across). Excel (C9): =B9+C8 Pattern (R1C1): =RC[-1]+R[-1]C Reads: 'P&L'!C8, 'P&L'!B9 """ p_l = book['P&L'] for c in range(3, 14): p_l[9, c] = p_l[9, c - 1] + p_l[8, c] def quarter(book: Book) -> None: r"""Quarter 'P&L'!B10:M10 (12 columns, copied across). Excel (B10): ="Q"&ROUNDUP(Costs!B2/3,0) Pattern (R1C1): ="Q"&ROUNDUP(Costs!R[-8]C/3,0) Reads: Costs!B2 """ p_l = book['P&L'] costs = book['Costs'] for c in range(2, 14): p_l[10, c] = xl.concat('Q', xl.ROUNDUP(costs[2, c] / 3, 0)) def revenue_b13(book: Book) -> None: r"""Revenue 'P&L'!B13:B16 (4 rows, copied down). Excel (B13): =SUMIFS($B$3:$M$3,$B$10:$M$10,$A13) Pattern (R1C1): =SUMIFS(R3C2:R3C13,R10C2:R10C13,RC1) Reads: 'P&L'!A13, 'P&L'!B3:M3, 'P&L'!B10:M10 """ p_l = book['P&L'] for r in range(13, 17): p_l[r, 'B'] = xl.SUMIFS(p_l["B3:M3"], p_l["B10:M10"], p_l[r, 'A']) def net_result_c13(book: Book) -> None: r"""Net result 'P&L'!C13:C16 (4 rows, copied down). Excel (C13): =SUMIFS($B$8:$M$8,$B$10:$M$10,$A13) Pattern (R1C1): =SUMIFS(R8C2:R8C13,R10C2:R10C13,RC1) Reads: 'P&L'!A13, 'P&L'!B8:M8, 'P&L'!B10:M10 """ p_l = book['P&L'] for r in range(13, 17): p_l[r, 'C'] = xl.SUMIFS(p_l["B8:M8"], p_l["B10:M10"], p_l[r, 'A'])