summaryrefslogtreecommitdiff
path: root/models/fertilizer-product.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'models/fertilizer-product.rkt')
-rw-r--r--models/fertilizer-product.rkt17
1 files changed, 16 insertions, 1 deletions
diff --git a/models/fertilizer-product.rkt b/models/fertilizer-product.rkt
index bd6bba9..0a6c03d 100644
--- a/models/fertilizer-product.rkt
+++ b/models/fertilizer-product.rkt
@@ -30,7 +30,22 @@
"nutrient.rkt")
;; Instances of this struct are persisted in the fertilizer_products table.
-(struct fertilizer-product (id canonical-name nutrient-values brand-name) #:transparent)
+(struct fertilizer-product (id canonical-name nutrient-values brand-name)
+ #:transparent
+ #:property prop:custom-write
+ (λ (v out _mode)
+ (fprintf out "Fertilizer #~a\n" (fertilizer-product-id v))
+ (if (fertilizer-product-brand-name v)
+ (fprintf out "~a (~a)\n"
+ (fertilizer-product-canonical-name v)
+ (fertilizer-product-brand-name v))
+ (fprintf out "~a\n"
+ (fertilizer-product-canonical-name v)))
+ (for ([nv (in-list (fertilizer-product-nutrient-values v))])
+ (match-define (cons n v) nv)
+ (fprintf out "~a ~a\n"
+ (~a (nutrient-name n) #:min-width 14)
+ (~a v #:max-width 6 #:align 'right)))))
;; CREATE
Copyright 2019--2025 Marius PETER