{ "version": 3, "sources": ["apps/frontend/src/app/orders/services/order-products.service.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\nimport { Entity, EntityInterface } from '@proman/services/entity.service';\nimport { resourcesConfig } from '@proman/resources';\nimport { OrdersService } from './orders.service';\nimport { OrderEntityInterface } from '@proman/resources/order';\nimport { OrderProduct } from '@proman/interfaces/entity-interfaces';\nimport { TableField } from '@proman/interfaces/object-interfaces';\nimport { Store } from '@ngrx/store';\nimport { getDecimalPlaces } from '@proman/store/system-options';\nimport { isDefinedNotNull, removeHtmlTags, roundNumber } from '@proman/utils';\n\n@Injectable({ providedIn: 'root' })\nexport class OrderProductsService {\n orderProductEntity: EntityInterface;\n orderEntity: OrderEntityInterface;\n getExtraParameters = resourcesConfig['order_product'].params.extraParameters;\n decimalOrderProduct: number;\n decimalProductWeight: number;\n\n constructor(\n private Entity: Entity,\n private Orders: OrdersService,\n private store: Store\n ) {\n this.orderProductEntity = this.Entity.get('order_product');\n this.orderEntity = this.Entity.get('order') as OrderEntityInterface;\n this.store.select(getDecimalPlaces, 'order_product')\n .subscribe((value) => this.decimalOrderProduct = value ?? 2);\n this.store.select(getDecimalPlaces, 'product_weight')\n .subscribe((value) => this.decimalProductWeight = value ?? 2);\n\n }\n\n private setQuantity = (row: OrderProduct, value: number, callback: any) => {\n this.Entity.get('order_product')\n .update({ id: row.id, readyForShipmentQuantity: value })\n .then(callback);\n };\n\n private getRemnant = (row: OrderProduct) => +row.quantity - +row.readyForShipmentQuantity;\n\n getEntity = (): any => {\n return this.orderProductEntity;\n };\n\n getFields = (callback: any): TableField[] => {\n return [\n {\n key: 'photo',\n formatter: 'image'\n },\n {\n name: 'name',\n key: 'product.name',\n maxLength: 50,\n state: {\n name: 'Product',\n key: 'productId',\n id: 'product.id'\n }\n },\n {\n name: 'product_id',\n key: 'product.id'\n },\n {\n name: 'order_id',\n key: 'order.id'\n },\n {\n name: 'order_name',\n key: 'order.name',\n state: {\n name: 'OrderInfo',\n key: 'orderId',\n id: 'order.id'\n }\n },\n {\n name: 'lot_number',\n key: 'product.lotNumber',\n hidden: true,\n },\n {\n name: 'customer',\n key: 'order.customer.name'\n },\n {\n name: 'customer_number',\n key: 'order.customerNumber'\n },\n {\n name: 'vat',\n key: 'product.vat.name',\n extraJoins: ['product.vat'],\n },\n {\n name: 'weight',\n key: 'product.weight',\n formatter: 'numeric',\n getValue: (product: OrderProduct) => roundNumber(+product.product?.weight * +product.quantity, this.decimalProductWeight),\n stats: ['sum'],\n extraJoins: ['product'],\n },\n {\n name: 'manager',\n key: 'order.manager.name'\n },\n {\n name: 'order_status',\n key: 'order.status',\n getValue: (row: OrderProduct) => this.Orders.getOrderStatus(row.order),\n formatter: 'compile',\n filter: {\n type: 'dropdown',\n options: this.Orders.getStatuses()\n }\n },\n {\n name: 'created_at',\n key: 'order.createdAt',\n formatter: 'dateTime',\n formatterConfig: '_short_datetime_js',\n showTime: true\n },\n {\n name: 'order_finish_date',\n key: 'order.finishedAt',\n formatter: 'dateTime',\n formatterConfig: '_short_datetime_js',\n hidden: true,\n },\n {\n name: 'categories',\n key: 'product.article.categories.name',\n getValue: (product: OrderProduct) => product.product?.article?.categories?.map((category) => category?.name).join(', '),\n hidden: true,\n extraJoins: ['product.article.categories'],\n },\n {\n name: 'order_type',\n key: 'order.type.name'\n },\n {\n name: 'quantity',\n key: 'quantity',\n formatter: 'numeric',\n formatterConfig: 0,\n stats: ['sum']\n },\n {\n name: 'discount',\n key: 'discountSum',\n formatter: 'money',\n formatterConfig: 2,\n stats: ['sum']\n },\n {\n name: 'order_parameters',\n key: 'order.parameters',\n filter: {\n type: 'search',\n keys: ['order.parameters.parameter.name', 'order.parameters.parameter.alias', 'order.parameters.value'],\n },\n formatter: 'parameters',\n hidden: true,\n extraJoins: [\n 'order.parameters',\n 'order.parameters.parameter',\n ],\n preloadParametersData: true\n },\n {\n name: 'product_parameters',\n key: 'product.parameters',\n filter: {\n type: 'search',\n keys: ['product.parameters.parameter.name', 'product.parameters.parameter.alias', 'product.parameters.value'],\n },\n formatter: 'parameters',\n hidden: true,\n extraJoins: [\n 'product.parameters',\n 'product.parameters.parameter',\n ],\n preloadParametersData: true\n },\n {\n name: 'ready_for_shipment_quantity',\n key: 'readyForShipmentQuantity',\n callback: (row: OrderProduct, value: number) => this.setQuantity(row, value, callback),\n formatter: 'input',\n stats: ['sum']\n },\n {\n name: 'shipped_quantity',\n key: 'shippedQuantity',\n formatter: 'numeric',\n stats: ['sum']\n },\n {\n name: 'left_to_be_made',\n key: 'remnant',\n getValue: this.getRemnant,\n formatter: 'numeric',\n formatterConfig: 0,\n stats: ['sum']\n },\n {\n name: 'price',\n key: 'customerPrice',\n stats: ['sum'],\n getValue: (item: OrderProduct) => {\n return (item.product && item.product.salePrice && +item.product?.salePrice?.amount !== 0) ? item.product?.salePrice : item.customerPrice;\n },\n formatter: 'money',\n formatterConfig: this.decimalOrderProduct,\n },\n {\n name: 'warehouse',\n key: 'product.warehouseLocation.warehouse.name',\n getValue: (item: OrderProduct) => item.product?.warehouseLocation?.warehouse?.name || '',\n },\n {\n name: 'store_name',\n key: 'product.storeName',\n hidden: true\n },\n {\n name: 'capacity',\n key: 'product.capacity',\n filter: {\n type: 'search',\n keys: ['product.capacity'],\n },\n hidden: true,\n getValue: (item: OrderProduct) => item.product?.capacity,\n },\n {\n name: 'extent',\n key: 'product.extent',\n filter: {\n type: 'search',\n keys: ['product.extent'],\n },\n hidden: true,\n getValue: (item: OrderProduct) => item.product?.extent,\n },\n {\n name: 'comments',\n key: 'product.customerComments',\n getValue: (row: OrderProduct) => row.product && isDefinedNotNull(row.product.customerComments) ? removeHtmlTags(row.product.customerComments) : ''\n },\n {\n name: 'validity',\n key: 'product.validity',\n translate: true\n },\n ];\n };\n\n getCustomFilters = () => this.Orders.getCustomFilters('order.');\n\n}\n"], "mappings": "+IAYA,IAAaA,GAAoB,IAAA,CAA3B,MAAOA,CAAoB,CAO7BC,YACYC,EACAC,EACAC,EAAY,CAFZ,KAAAF,OAAAA,E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AA,CAAA,CAAA,iCAApBvE,EAAoBwE,QAApBxE,EAAoByE,UAAAC,WADP,MAAM,CAAA,CAAA,SACnB1E,CAAoB,GAAA", "names": ["OrderProductsService", "constructor", "Entity", "Orders", "store", "getExtraParameters", "resourcesConfig", "params", "extraParameters", "setQuantity", "row", "value", "callback", "get", "update", "id", "readyForShipmentQuantity", "then", "getRemnant", "quantity", "getEntity", "orderProductEntity", "getFields", "key", "formatter", "name", "maxLength", "state", "hidden", "extraJoins", "getValue", "product", "roundNumber", "weight", "decimalProductWeight", "stats", "getOrderStatus", "order", "filter", "type", "options", "getStatuses", "formatterConfig", "showTime", "article", "categories", "map", "category", "join", "keys", "preloadParametersData", "item", "salePrice", "amount", "customerPrice", "decimalOrderProduct", "warehouseLocation", "warehouse", "capacity", "extent", "isDefinedNotNull", "customerComments", "removeHtmlTags", "translate", "getCustomFilters", "orderEntity", "select", "getDecimalPlaces", "subscribe", "\u0275\u0275inject", "OrdersService", "Store", "factory", "\u0275fac", "providedIn"] }