@@ -61,30 +61,96 @@ def create_farm_calendar_pdf(calendar_data: FarmCalendarData) -> EX:
6161
6262 pdf .set_font ("FreeSerif" , "" , 9 )
6363 pdf .multi_cell (0 , 10 , f"Details: { operation .details } " , ln = True )
64- pdf .cell (0 , 10 , f"Start: { operation .hasStartDatetime } " , ln = True )
65- pdf .cell (0 , 10 , f"End: { operation .hasEndDatetime } " , ln = True )
66- pdf .cell (0 , 10 , f"Responsible: { operation .responsibleAgent } " , ln = True )
64+
65+ if operation .hasStartDatetime :
66+ pdf .cell (
67+ 0 ,
68+ 10 ,
69+ f"Start: { operation .hasStartDatetime } " ,
70+ ln = True ,
71+ )
72+
73+ if operation .hasEndDatetime :
74+ pdf .cell (
75+ 0 ,
76+ 10 ,
77+ f"End: { operation .hasEndDatetime } " ,
78+ ln = True ,
79+ )
80+
81+ (
82+ pdf .cell (0 , 10 , f"Responsible: { operation .responsibleAgent } " , ln = True )
83+ if operation .responsibleAgent
84+ else None
85+ )
86+ pdf .cell (0 , 10 , f"Type: { operation .activityType .get ('@id' , 'N/A' )} " , ln = True )
6787
6888 if operation .usesAgriculturalMachinery :
69- pdf .cell (0 , 10 , "Machinery:" , ln = True )
70- for machinery in operation .usesAgriculturalMachinery :
71- pdf .cell (0 , 10 , f" - { machinery .split (':' )[3 ]} " , ln = True )
89+ machinery_ids = ", " .join (
90+ [
91+ machinery .get ("@id" , "N/A" ).split (":" )[3 ]
92+ for machinery in operation .usesAgriculturalMachinery
93+ ]
94+ )
95+ pdf .cell (0 , 10 , f"Machinery IDs: { machinery_ids } " , ln = True )
7296
7397 for x in calendar_data .observations :
7498 pdf .set_font ("FreeSerif" , "B" , 10 )
7599 pdf .cell (0 , 10 , "Observations:" , ln = True )
76100 pdf .set_font ("FreeSerif" , "" , 10 )
77- pdf .cell (0 , 10 , f"Value: { x .hasValue } " , ln = True )
78- pdf .cell (0 , 10 , f"Property: { x .relatesToProperty } " , ln = True )
101+ (
102+ pdf .cell (0 , 10 , f"Value: { x .hasResult .hasValue } " , ln = True )
103+ if x .hasResult
104+ else None
105+ )
106+ (
107+ pdf .cell (0 , 10 , f"Value unit: { x .hasResult .unit } " , ln = True )
108+ if x .hasResult
109+ else None
110+ )
111+ (
112+ pdf .cell (0 , 10 , f"Property: { x .relatesToProperty } " , ln = True )
113+ if x .relatesToProperty
114+ else None
115+ )
116+ (
117+ pdf .cell (0 , 10 , f"Observed Property: { x .observedProperty } " , ln = True )
118+ if x .observedProperty
119+ else None
120+ )
79121 pdf .cell (0 , 10 , f"Details: { x .details } " , ln = True )
80- pdf .cell (0 , 10 , f"Start: { x .hasStartDatetime } " , ln = True )
81- pdf .cell (0 , 10 , f"End: { x .hasEndDatetime } " , ln = True )
82- pdf .cell (0 , 10 , f"Responsible: { x .responsibleAgent } " , ln = True )
122+
123+ if x .hasStartDatetime :
124+ pdf .cell (
125+ 0 ,
126+ 10 ,
127+ f"Start: { x .hasStartDatetime } " ,
128+ ln = True ,
129+ )
130+
131+ if x .hasEndDatetime :
132+ pdf .cell (
133+ 0 ,
134+ 10 ,
135+ f"Start: { x .hasEndDatetime } " ,
136+ ln = True ,
137+ )
138+
139+ (
140+ pdf .cell (0 , 10 , f"Responsible: { x .responsibleAgent } " , ln = True )
141+ if x .responsibleAgent
142+ else None
143+ )
83144
84145 if x .usesAgriculturalMachinery :
85- pdf .cell (0 , 10 , "Machinery:" , ln = True )
86- for machinery in operation .usesAgriculturalMachinery :
87- pdf .cell (0 , 10 , f" - { machinery .split (':' )[3 ]} " , ln = True )
146+ machinery_ids = ", " .join (
147+ [
148+ machinery .get ("@id" , "N/A" ).split (":" )[3 ]
149+ for machinery in x .usesAgriculturalMachinery
150+ ]
151+ )
152+ pdf .cell (0 , 10 , f"Machinery IDs: { machinery_ids } " , ln = True )
153+
88154 pdf .ln (10 )
89155
90156 return pdf
0 commit comments