diff --git a/packages/modules/fulfillment/src/lib/components/fulfillment-view-details.component.html b/packages/modules/fulfillment/src/lib/components/fulfillment-view-details.component.html index 820a766..30eb574 100644 --- a/packages/modules/fulfillment/src/lib/components/fulfillment-view-details.component.html +++ b/packages/modules/fulfillment/src/lib/components/fulfillment-view-details.component.html @@ -188,16 +188,41 @@ Total items size -
...
- +
+
+ Length + {{ + (fulfillment.packaging?.parcels?.[0]?.items || []) | + parcelTotalSize : 'length' }} + Cm +
- - - Total items weight - +
+ Width + {{ (fulfillment.packaging?.parcels?.[0]?.items || []) | + parcelTotalSize : 'width' }} + Cm +
-
...
+
+ Height + {{ (fulfillment.packaging?.parcels?.[0]?.items || []) | + parcelTotalSize : 'height' }} + Cm +
+ +
+ Weight + {{ (fulfillment.packaging?.parcels?.[0]?.items || []) | parcelTotalWeight }} + Kg +
+
diff --git a/packages/modules/fulfillment/src/lib/modules-fulfillment.module.ts b/packages/modules/fulfillment/src/lib/modules-fulfillment.module.ts index 0a560d8..dc98197 100644 --- a/packages/modules/fulfillment/src/lib/modules-fulfillment.module.ts +++ b/packages/modules/fulfillment/src/lib/modules-fulfillment.module.ts @@ -10,6 +10,8 @@ import { FulfillmentViewDetailsComponent } from './components/fulfillment-view-d import { FulfillmentViewComponent } from './components/fulfillment-view.component'; import { FulfillmentTemplateComponent } from './components/template/fulfillment-template.component'; import { modulesFulfillmentRoutes } from './lib.routes'; +import { ParcelsTotalSizePipe } from './pipes/parcels-total-size.pipe'; +import { ParcelsTotalWeightPipe } from './pipes/parcels-total-weight.pipe'; @NgModule({ declarations: [ @@ -19,6 +21,8 @@ import { modulesFulfillmentRoutes } from './lib.routes'; FulfillmentViewComponent, FulfillmentViewDetailsComponent, FulfillmentTemplateComponent, + ParcelsTotalSizePipe, + ParcelsTotalWeightPipe, ], imports: [ ModulesUiModule.forChild(), diff --git a/packages/modules/fulfillment/src/lib/pipes/parcels-total-size.pipe.ts b/packages/modules/fulfillment/src/lib/pipes/parcels-total-size.pipe.ts new file mode 100644 index 0000000..4a46f54 --- /dev/null +++ b/packages/modules/fulfillment/src/lib/pipes/parcels-total-size.pipe.ts @@ -0,0 +1,19 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +import { IoRestorecommerceFulfillmentItem } from '@console-core/graphql'; + +@Pipe({ + name: 'parcelTotalSize', + pure: true, +}) +export class ParcelsTotalSizePipe implements PipeTransform { + transform( + parcels: IoRestorecommerceFulfillmentItem[], + property: 'length' | 'width' | 'height' + ): number { + return parcels.reduce((total, parcel) => { + const propValue = parcel.package?.sizeInCm?.[property] || 0; + return propValue + total; + }, 0); + } +} diff --git a/packages/modules/fulfillment/src/lib/pipes/parcels-total-weight.pipe.ts b/packages/modules/fulfillment/src/lib/pipes/parcels-total-weight.pipe.ts new file mode 100644 index 0000000..7c86880 --- /dev/null +++ b/packages/modules/fulfillment/src/lib/pipes/parcels-total-weight.pipe.ts @@ -0,0 +1,16 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +import { IoRestorecommerceFulfillmentItem } from '@console-core/graphql'; + +@Pipe({ + name: 'parcelTotalWeight', + pure: true, +}) +export class ParcelsTotalWeightPipe implements PipeTransform { + transform(parcels: IoRestorecommerceFulfillmentItem[]): number { + return parcels.reduce((total, parcel) => { + const propValue = parcel.package?.weightInKg || 0; + return propValue + total; + }, 0); + } +}