merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

orders.typ (2038B)


      1 #import "@taler-merchant/common:0.0.0": format_timestamp, format_amount
      2 
      3 #let breakable_hyp(s) = s.replace("-", "-#zwsp")
      4 
      5 #let form(data) = {
      6   set page(
      7     paper: "a4",
      8     margin: (left: 2cm, right: 2cm, top: 2cm, bottom: 2.5cm),
      9     footer: context [
     10       #grid(
     11         columns: (1fr, 1fr),
     12         align: (left, right),
     13         text(size: 8pt)[],
     14         text(size: 8pt)[
     15           Page #here().page() of #counter(page).final().first()
     16         ]
     17       )
     18     ]
     19   )
     20 
     21   heading(level: 1)[GNU Taler Merchant Orders: #data.business_name]
     22 
     23   v(0.5cm)
     24 
     25   table(
     26     columns: (auto, auto, auto),
     27     align: (left, right, right),
     28     // Header row
     29     table.header(
     30       [*Order ID*],
     31       [*Timestamp*],
     32       [*Price* #text(fill: red)[$-$ *Refund*]],
     33     ),
     34     // Data rows
     35     ..data.orders.map(o => (
     36       table.cell()[#text(8pt, o.order_id)],
     37       table.cell(stroke: (bottom: none))[#format_timestamp(o.timestamp)],
     38       table.cell(stroke: (bottom: none))[#format_amount(o.amount)],
     39       table.cell(colspan:2, x: 0, stroke: (top: none))[
     40         #grid(
     41           columns: (1fr, auto),
     42           o.summary,
     43           if o.paid {
     44             text(fill: green)[✓ (paid)]
     45           } else {
     46             text(fill: red)[✗ (unpaid)]
     47           },
     48         )
     49       ],
     50       table.cell(stroke: (top: none))[#{
     51         let r = o.at("refund_amount", default: none)
     52         if (r != none) {
     53           text(fill: red)[$-$ #format_amount(r)]
     54         } else {
     55           "-"
     56         }
     57       }],
     58     )).flatten(),
     59     // Footer row
     60     table.footer(
     61       table.cell(colspan: 2, stroke: (bottom: none))[*Total (paid only)*],
     62       table.cell(stroke: (bottom: none))[
     63         *#format_amount(data.total_amount)*
     64       ],
     65       table.cell(colspan: 2, x: 0, stroke: (top: none))[*Total (refunds)*],
     66       table.cell(stroke: (top: none))[#{
     67         let r = data.total_refund_amount
     68         if r != none {
     69           text(fill: red)[$-$ *#format_amount(data.total_refund_amount)*]
     70         } else {
     71           ["-"]
     72         }
     73       }],
     74     ),
     75   )
     76 }