@@ -924,9 +924,18 @@ impl XmlElementBlock<Onix3Thoth> for Work {
924
924
}
925
925
Ok ( ( ) )
926
926
} ) ?;
927
- // 99 Contact supplier
928
927
write_element_block ( "ProductAvailability" , w, |w| {
929
- w. write ( XmlEvent :: Characters ( "99" ) ) . map_err ( |e| e. into ( ) )
928
+ let availability = match self . work_status {
929
+ WorkStatus :: CANCELLED => "01" , // 01 – Cancelled
930
+ WorkStatus :: FORTHCOMING => "10" , // 10 – Not yet available
931
+ WorkStatus :: POSTPONED_INDEFINITELY => "09" , // 09 – Not yet available, postponed indefinitely
932
+ WorkStatus :: ACTIVE => "20" , // 20 – Available
933
+ WorkStatus :: SUPERSEDED => "41" , // 41 – Not available, replaced by new product
934
+ WorkStatus :: WITHDRAWN => "49" , // 49 – Recalled
935
+ WorkStatus :: Other ( _) => unreachable ! ( ) ,
936
+ } ;
937
+ w. write ( XmlEvent :: Characters ( availability) )
938
+ . map_err ( |e| e. into ( ) )
930
939
} ) ?;
931
940
if let Some ( date) = & self . publication_date {
932
941
write_element_block ( "SupplyDate" , w, |w| {
@@ -949,9 +958,9 @@ impl XmlElementBlock<Onix3Thoth> for Work {
949
958
} ) ?;
950
959
}
951
960
if publication. prices . is_empty ( ) {
952
- // 04 Contact supplier
961
+ // 01 Free of charge
953
962
write_element_block ( "UnpricedItemType" , w, |w| {
954
- w. write ( XmlEvent :: Characters ( "04 " ) ) . map_err ( |e| e. into ( ) )
963
+ w. write ( XmlEvent :: Characters ( "01 " ) ) . map_err ( |e| e. into ( ) )
955
964
} )
956
965
} else {
957
966
for price in & publication. prices {
@@ -2836,7 +2845,7 @@ mod tests {
2836
2845
<WebsiteLink>https://www.book.com/pb_landing</WebsiteLink>
2837
2846
</Website>
2838
2847
</Supplier>
2839
- <ProductAvailability>99 </ProductAvailability>
2848
+ <ProductAvailability>20 </ProductAvailability>
2840
2849
<SupplyDate>
2841
2850
<SupplyDateRole>08</SupplyDateRole>
2842
2851
<Date dateformat="00">19991231</Date>
@@ -3357,7 +3366,7 @@ mod tests {
3357
3366
</Website>"#
3358
3367
) ) ;
3359
3368
// UnpricedItemType block instead of any Prices
3360
- assert ! ( output. contains( r#" <UnpricedItemType>04 </UnpricedItemType>"# ) ) ;
3369
+ assert ! ( output. contains( r#" <UnpricedItemType>01 </UnpricedItemType>"# ) ) ;
3361
3370
assert ! ( !output. contains( r#" <Price>"# ) ) ;
3362
3371
3363
3372
// Remove chapter DOI: can't output ContentDetail block
0 commit comments