// An ACCOUNT as its BANK CARD, the balance first (owner, 30 Oct 2026: "the// bank statement should mainly have the balance; maybe this month in and// out"; the ledger-card picture `objects-2/money/5-ledger-card`): a buff// account card of stiff stock with a red signal clip on its top edge and a// punched hole at its foot, lying bare on the money's pink terrazzo// (`FaceGround.terrazzo`). The card, its green ruling (a balance panel, a band of// two cells for the month's in and out, the column heads Date, Particulars,// Dr, Cr, Balance and six rows), the clip and their shadows are PAINTED// (`Media.xcassets`, cut and imported by `scripts/import-money-materials.py`);// the face writes live only what the card decides://// the bank (`subtitle`) in the card's green print at its head;// the account's name (`title`) and masked number (`mask`) typed at the// top of the panel, two lines at most;// the BALANCE (`amount`) typed large in the panel, "Rs" and two places:// the one thing the card is about.//// The core carries this month's recent postings in `rows`, including the// Worker's stored balance after each posting. The face draws those words.// A tap on the screen's sides cuts to the next card (`FaceStep.cut`). Every// word but the card's print (BALANCE, and the painted heads) is the core's.importCottonPaperimportCottonValuesimportSwiftUIenumStatementFaceKnobs {// THE CARD, as painted (`statement-card`, 929 by 1486 pixels): its width// over its height, its shadow's reach as a share of its width, and its// ruling as shares of its height — the head band's double rule, the// balance panel's foot — measured off the painting by the cut (`cut.py`// beside the layers), so a repainted card owes new knobs.staticlet aspect: CGFloat = 929.0 / 1486.0staticlet shadowReach: CGFloat = 0.0753staticlet headRule: CGFloat = 0.1104staticlet panelTop: CGFloat = 0.1165staticlet panelFoot: CGFloat = 0.3666/// The clip (`statement-tab`): its width over its height as painted,/// its shadow's reach, its width and its left edge as shares of the/// card's width, and how much of its height stands over the card's top.staticlet tabAspect: CGFloat = 300.0 / 140.0staticlet tabShadow: CGFloat = 0.0533staticlet tabWidth: CGFloat = 0.17staticlet tabLeft: CGFloat = 0.7staticlet tabOver: CGFloat = 0.42/// The card in the card's room: the most of its height (the clip over/// it included) and width it takes.staticlet fillHeight: CGFloat = 0.97staticlet fillWidth: CGFloat = 0.96/// The writing's side margin, and the type, as shares of the card's width.staticlet side: CGFloat = 0.07staticlet bankSize: CGFloat = 0.05staticlet nameSize: CGFloat = 0.062staticlet labelSize: CGFloat = 0.042staticlet balanceSize: CGFloat = 0.125}publicstructAccountStatementFace: View {let card: DeckCardpublicinit(card: DeckCard) {self.card = card }publicvar body: someView {let knobs = StatementFaceKnobs.selfGeometryReader { box inlet over = knobs.tabOver * knobs.tabWidth * knobs.aspect / knobs.tabAspectlet height = min(box.size.height * knobs.fillHeight / (1 + over), box.size.width * knobs.fillWidth / knobs.aspect)let size = CGSize(width: height * knobs.aspect, height: height)StatementCard(card: card, size: size) .frame(width: size.width, height: size.height) .padding(.top, over * height) .frame(width: box.size.width, height: box.size.height) } }}privatestructStatementCard: View {let card: DeckCardlet size: CGSizevar body: someView {let knobs = StatementFaceKnobs.selflet w = size.widthlet h = size.heightlet tab = CGSize(width: knobs.tabWidth * w, height: knobs.tabWidth * w / knobs.tabAspect) ZStack(alignment: .topLeading) {MoneyPaper(name: "statement-card", size: size, reach: knobs.shadowReach, standIn: MoneyMaterial.card.colour, corner: 0.03)Group { head .frame(width: w - 2 * knobs.side * w, height: knobs.headRule * h, alignment: .leading) .placed(x: knobs.side * w) balance .frame(width: w - 2 * knobs.side * w, height: (knobs.panelFoot - knobs.panelTop) * h) .placed(x: knobs.side * w, y: knobs.panelTop * h) rows } .blendMode(.multiply)MoneyPaper(name: "statement-tab", size: tab, reach: knobs.tabShadow, standIn: MoneyMaterial.tab.colour, corner: 0.1) .offset(x: knobs.tabLeft * w, y: -knobs.tabOver * tab.height) } .frame(width: w, height: h, alignment: .topLeading) .accessibilityElement(children: .contain) .accessibilityIdentifier("statement") }privatevar rows: someView {// Column edges and row baselines follow the painted ruling.let edges: [CGFloat] = [0.046, 0.196, 0.492, 0.644, 0.785, 0.973]let slots = ["date", "narration", "debit", "credit", "balance"]return ZStack(alignment: .topLeading) {ForEach(Array(card.entries("rows").prefix(6).enumerated()), id: \.offset) { row, entry inForEach(0..<slots.count, id: \.self) { column iniflet words = entry[slots[column]]?.text {Text(words) .font(CottonFonts.type(size.width * (column == 1 ? 0.027 : 0.024))) .foregroundStyle(MoneyMaterial.posting.colour) .lineLimit(column == 1 ? 2 : 1) .minimumScaleFactor(0.55) .frame(width: size.width * (edges[column + 1] - edges[column] - 0.012), height: size.height * 0.0587, alignment: column > 1 ? .trailing : .leading) .placed(x: size.width * (edges[column] + 0.006), y: size.height * (0.512 + CGFloat(row) * 0.0587)) } } } } .accessibilityIdentifier("statement-rows") }/// The bank in the card's green print, clear of the clip over the/// card's top edge: two lines at most.privatevar head: someView {let knobs = StatementFaceKnobs.selflet w = size.widthreturn ZStack(alignment: .leading) {iflet bank = card.text("subtitle") {Text(bank.uppercased()) .font(CottonFonts.caslon(knobs.bankSize * w)) .tracking(0.2 * knobs.bankSize * w) .foregroundStyle(MoneyMaterial.ledgerPrint.colour) .lineLimit(2) .minimumScaleFactor(0.7) .frame(width: (knobs.tabLeft - knobs.side - 0.03) * w, alignment: .leading) .facePart(.subtitle) } } .padding(.top, 0.012 * size.height) }/// The account typed, its name and masked number, then the balance/// large under its printed head.privatevar balance: someView {let knobs = StatementFaceKnobs.selflet w = size.widthlet typed = MoneyMaterial.posting.colourlet account = [card.text("title"), card.text("mask")].compactMap { $0 }.joined(separator: " ")return VStack(alignment: .leading, spacing: 0) {if !account.isEmpty {Text(account) .font(CottonFonts.type(knobs.nameSize * w)) .foregroundStyle(typed) .lineLimit(2) .minimumScaleFactor(0.7) .frame(maxWidth: .infinity, alignment: .leading) .padding(.top, 0.022 * size.height) .accessibilityIdentifier("deck-title") .facePart(.title) }Text(StatementPrint.balance) .font(CottonFonts.caslon(knobs.labelSize * w)) .tracking(0.2 * knobs.labelSize * w) .foregroundStyle(MoneyMaterial.ledgerPrint.colour) .padding(.top, 0.03 * size.height)Spacer(minLength: 0)iflet said = card.text("amount") {FittedLine(words: SaidAmount(said).map(MoneyReading.typed) ?? said, font: CottonFonts.type(knobs.balanceSize * w), ink: typed, alignment: .center, shrink: 0.45) .facePart(.amount) }Spacer(minLength: 0) } }}/// The account card's own print beside its painted heads.enumStatementPrint {staticlet balance = "BALANCE"}/// An account as its bank card, by its id beside the account's own face,/// and the accounts it is reviewed in: invented names only.publicenumAccountStatementFaceCatalogue {publicstaticlet stock: FaceStock = .ownpublicstaticlet ground: FaceGround = .terrazzopublicstaticlet face = Face(id: "account.statement", specimens: [Specimen("savings", savings), Specimen("new", new), Specimen("long-name", longName), ], steps: .cut) { card, _, _ inAccountStatementFace(card: card) }staticfunc account(_ fields: [String: RecordValue]) -> DeckCard {DeckCard(face: "account.statement", corner: nil, pressing: false, pace: nil, plate: nil, fields: fields) }/// The reference's account.publicstaticlet savings = account(["title": .text("Savings"),"subtitle": .text("Northern Bank"),"mask": .text("\u{00B7}\u{00B7}\u{00B7}1173"),"amount": .text("\u{20B9}1,24,500"),"rows": .list([ .object(["date": .text("4 Oct"), "narration": .text("Sample groceries"), "debit": .text("₹1,908"), "balance": .text("₹1,24,400")]), .object(["date": .text("5 Oct"), "narration": .text("Sample refund"), "credit": .text("₹100"), "balance": .text("₹1,24,500")]), ]), ])/// An account just opened: nothing in it yet.publicstaticlet new = account(["title": .text("Salary account"),"subtitle": .text("Northern Bank"),"mask": .text("\u{00B7}\u{00B7}\u{00B7}0482"),"amount": .text("\u{20B9}0"), ])/// A long name and a crore figure with paise.publicstaticlet longName = account(["title": .text("Household joint savings for the new house"),"subtitle": .text("Riverside Co-operative Bank"),"mask": .text("\u{00B7}\u{00B7}\u{00B7}5530"),"amount": .text("\u{20B9}1,16,01,625.50"), ])}