From f5c4e1159f38e0ac9acb228200608848b63555e0 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 28 Aug 2025 21:55:02 +0200 Subject: [PATCH] Working on MassEdit and SingleEdit --- src/frontend/src/components/UI/Toast.vue | 1 - .../layout/bulkedit/BulkEditRow.vue | 34 +- .../layout/edit/DestinationListView.vue | 2 - .../components/layout/edit/MaterialEdit.vue | 31 +- .../src/components/layout/edit/PriceEdit.vue | 2 +- .../edit/destination/DestinationEdit.vue | 2 +- .../destination/DestinationEditRoutes.vue | 6 +- .../layout/material/SelectMaterial.vue | 2 +- .../src/pages/CalculationMassEdit.vue | 146 ++++--- .../src/pages/CalculationSingleEdit.vue | 50 ++- src/frontend/src/store/premiseEdit.js | 403 +++++++++++++----- .../controller/GlobalExceptionHandler.java | 45 +- .../calculation/PremiseController.java | 6 +- .../destination/DestinationCreateDTO.java | 9 +- .../DestinationSetListItemDTO.java | 6 +- .../destination/DestinationUpdateDTO.java | 45 +- .../edit/masterData/MaterialUpdateDTO.java | 2 +- .../edit/masterData/PackagingUpdateDTO.java | 4 +- .../edit/masterData/PriceUpdateDTO.java | 3 +- .../java/de/avatic/lcc/model/nodes/Node.java | 4 + .../lcc/repositories/MaterialRepository.java | 4 +- .../premise/DestinationRepository.java | 39 +- .../service/access/DestinationService.java | 5 +- .../service/calculation/ChainResolver.java | 1 + .../calculation/ChangeMaterialService.java | 4 +- .../generic/DimensionTransformer.java | 30 +- .../premise/PremiseTransformer.java | 3 + .../transformer/premise/RouteTransformer.java | 4 +- 28 files changed, 604 insertions(+), 289 deletions(-) diff --git a/src/frontend/src/components/UI/Toast.vue b/src/frontend/src/components/UI/Toast.vue index d1032ec..98c90fb 100644 --- a/src/frontend/src/components/UI/Toast.vue +++ b/src/frontend/src/components/UI/Toast.vue @@ -17,7 +17,6 @@ weight="regular" size="24" class="icon-btn" - :class="toast__icon_sizing" />
diff --git a/src/frontend/src/components/layout/bulkedit/BulkEditRow.vue b/src/frontend/src/components/layout/bulkedit/BulkEditRow.vue index b7282ec..b494c2a 100644 --- a/src/frontend/src/components/layout/bulkedit/BulkEditRow.vue +++ b/src/frontend/src/components/layout/bulkedit/BulkEditRow.vue @@ -10,23 +10,24 @@ {{ premise.material.name }}
- + HS Code: {{ premise.material.hs_code }}
-
- - {{ premise.tariff_rate }} +
+ Tariff rate: + {{ toPercent(premise.tariff_rate) }} %
{{ premise.material_cost }} EUR
-
+
Oversea share: {{ toPercent(premise.oversea_share) }} %
+
FCA FEE
- MISSING + INCOMPLETE
@@ -36,11 +37,11 @@ {{ premise.handling_unit.width }} x {{ premise.handling_unit.height }} {{ premise.handling_unit.dimension_unit }}
-
+
{{ premise.handling_unit.weight }} {{ premise.handling_unit.weight_unit }}
-
+
{{ premise.handling_unit.content_unit_count }} pcs.
@@ -51,7 +52,7 @@
- MISSING + INCOMPLETE
@@ -77,7 +78,7 @@
- MISSING + INCOMPLETE
@@ -178,7 +179,9 @@ export default { } }, methods: { - + toPercent(value) { + return value !== null ? (value * 100).toFixed(2) : '0.00'; + }, updateSelected(value) { this.premiseEditStore.setSelectTo([this.id], value); }, @@ -214,10 +217,6 @@ export default { overflow: hidden; } -/*.bulk-edit-row:hover { -// background-color: rgba(107, 134, 156, 0.05); -//} */ - .bulk-edit-row:last-child { border-bottom: none; } @@ -249,11 +248,6 @@ export default { .edit-calculation-cell--copy-mode:hover { cursor: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyOCIgaGVpZ2h0PSIyOCIgdmlld0JveD0iMCAwIDI1NiAyNTYiPgogIDxyZWN0IHg9Ijg0IiB5PSIzMiIgd2lkdGg9IjEzNiIgaGVpZ2h0PSIxMzYiIGZpbGw9IndoaXRlIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iOCIgcng9IjQiLz4KICA8cmVjdCB4PSIzNiIgeT0iODQiIHdpZHRoPSIxMzYiIGhlaWdodD0iMTM2IiBmaWxsPSJ3aGl0ZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjgiIHJ4PSI0Ii8+Cjwvc3ZnPg==") 12 12, pointer; - - /*cursor: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0iI2ZmZmZmZiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjQiIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KICA8cGF0aCBkPSJNMjAwLDMySDE2My43NGE0Ny45Miw0Ny45MiwwLDAsMC03MS40OCwwSDU2QTE2LDE2LDAsMCwwLDQwLDQ4VjIxNmExNiwxNiwwLDAsMCwxNiwxNkgyMDBhMTYsMTYsMCwwLDAsMTYtMTZWNDhBMTYsMTYsMCwwLDAsMjAwLDMyWm0tNzIsMGEzMiwzMiwwLDAsMSwzMiwzMkg5NkEzMiwzMiwwLDAsMSwxMjgsMzJaIj48L3BhdGg+Cjwvc3ZnPg==") 12 12, pointer; -*/ - - background-color: rgba(107, 134, 156, 0.05); border-radius: 0.8rem; box-shadow: 0 0.4rem 0.6rem -0.1rem rgba(0, 0, 0, 0.1); diff --git a/src/frontend/src/components/layout/edit/DestinationListView.vue b/src/frontend/src/components/layout/edit/DestinationListView.vue index c432041..c599753 100644 --- a/src/frontend/src/components/layout/edit/DestinationListView.vue +++ b/src/frontend/src/components/layout/edit/DestinationListView.vue @@ -93,12 +93,10 @@ export default { }, async addDestination(node) { console.log(node) - // todo add to massEdit copy only const [id] = await this.premiseEditStore.addDestination(node); this.editDestination(id); }, deleteDestination(id) { - // todo delete from to massEdit copy only this.premiseEditStore.deleteDestination(id); }, editDestination(id) { diff --git a/src/frontend/src/components/layout/edit/MaterialEdit.vue b/src/frontend/src/components/layout/edit/MaterialEdit.vue index 771b6da..0ae60dd 100644 --- a/src/frontend/src/components/layout/edit/MaterialEdit.vue +++ b/src/frontend/src/components/layout/edit/MaterialEdit.vue @@ -28,14 +28,14 @@
+ placeholder="Find hs code" no-results-text="Not found.">
Tariff rate [%]
-
@@ -59,6 +59,7 @@ import {mapStores} from "pinia"; import {parseNumberFromString} from "@/common.js"; import Modal from "@/components/UI/Modal.vue"; import SelectMaterial from "@/components/layout/material/SelectMaterial.vue"; +import {useCustomsStore} from "@/store/customs.js"; export default { name: "MaterialEdit", @@ -66,7 +67,7 @@ export default { SelectMaterial, Modal, PhArrowCounterClockwise, ModalDialog, AutosuggestSearchbar, InputField, Flag, IconButton }, - emits: ["update:tariffRate", "updateMaterial", "update:partNumber", "update:hsCode"], + emits: ["update:tariffRate", "updateMaterial", "update:partNumber", "update:hsCode", "save"], props: { description: { type: String, @@ -86,7 +87,7 @@ export default { }, }, computed: { - ...mapStores(useMaterialStore), + ...mapStores(useMaterialStore, useCustomsStore), tariffRatePercent() { return this.tariffRate ? (this.tariffRate * 100).toFixed(2) : ''; } @@ -119,25 +120,25 @@ export default { } }); }, - validateInput(type, event) { - const decimals = 2 - const parsed = parseNumberFromString(event.target.value, decimals); - console.log('validateInput', type, event.target.value, parsed); + validateTariffRate(event) { + const percentValue = parseNumberFromString(event.target.value, 4); - this.$emit(`update:${type}`, parsed); + const validatedPercent = Math.max(0, Math.min(999.99, percentValue)); + const validatedDecimal = validatedPercent / 100; - // Force update the input field with the correctly formatted value - const formattedValue = parsed.toFixed(decimals); - const inputRef = `${type}Input`; - this.updateInputValue(inputRef, formattedValue); + if (validatedDecimal !== this.tariffRate) { + this.$emit('update:tariffRate', validatedDecimal); + } + + event.target.value = validatedPercent.toFixed(2); }, activateEditMode() { this.modalSelectMaterial = true; }, async fetchHsCode(query) { const hsCodeQuery = {searchTerm: query}; - await this.customs.setQuery(hsCodeQuery); - return this.customs.hsCodes; + await this.customsStore.setQuery(hsCodeQuery); + return this.customsStore.hsCodes; } } } diff --git a/src/frontend/src/components/layout/edit/PriceEdit.vue b/src/frontend/src/components/layout/edit/PriceEdit.vue index 47d7170..6e32000 100644 --- a/src/frontend/src/components/layout/edit/PriceEdit.vue +++ b/src/frontend/src/components/layout/edit/PriceEdit.vue @@ -34,7 +34,7 @@ import {parseNumberFromString} from "@/common.js"; export default { name: "PriceEdit", components: {Tooltip, Checkbox}, - emits: ['update:price', 'update:overSeaShare', 'update:includeFcaFee'], + emits: ['update:price', 'update:overSeaShare', 'update:includeFcaFee', 'save'], props: { price: { required: true, diff --git a/src/frontend/src/components/layout/edit/destination/DestinationEdit.vue b/src/frontend/src/components/layout/edit/destination/DestinationEdit.vue index 90da764..6673779 100644 --- a/src/frontend/src/components/layout/edit/destination/DestinationEdit.vue +++ b/src/frontend/src/components/layout/edit/destination/DestinationEdit.vue @@ -65,7 +65,7 @@ export default { flex-direction: column; gap: 1.6rem; flex: 1 0 min(60vw, 120rem); - height: min(70vh, 50rem); + height: min(60vh, 120rem); min-height: 0; /* Critical: allows flex child to shrink below content size */ } diff --git a/src/frontend/src/components/layout/edit/destination/DestinationEditRoutes.vue b/src/frontend/src/components/layout/edit/destination/DestinationEditRoutes.vue index 43c342c..3c1c4db 100644 --- a/src/frontend/src/components/layout/edit/destination/DestinationEditRoutes.vue +++ b/src/frontend/src/components/layout/edit/destination/DestinationEditRoutes.vue @@ -102,13 +102,13 @@ export default { return `Annual quantity that "${this.destination.destination_node.name}" will source from the supplier` }, showMassEditWarning() { - return (this.destination.massEdit ?? false); + return (this.destination.routes ?? null) === null; }, showRoutes() { - return !this.destination.is_d2d && this.destination.routes?.length > 0 | false; + return !this.destination.is_d2d && (this.destination.routes?.length > 0); }, showRouteWarning() { - return !this.destination.is_d2d && this.destination.routes.length === 0; + return !this.destination.is_d2d && this.destination.routes?.length === 0; }, calculationModel: { get() { diff --git a/src/frontend/src/components/layout/material/SelectMaterial.vue b/src/frontend/src/components/layout/material/SelectMaterial.vue index fc25437..a02995f 100644 --- a/src/frontend/src/components/layout/material/SelectMaterial.vue +++ b/src/frontend/src/components/layout/material/SelectMaterial.vue @@ -22,7 +22,7 @@
{{ hsCode }}
+ text="Tick to reload master data from database (if present) and overwrite current values."> update master data
diff --git a/src/frontend/src/pages/CalculationMassEdit.vue b/src/frontend/src/pages/CalculationMassEdit.vue index 478e36e..c32d4fb 100644 --- a/src/frontend/src/pages/CalculationMassEdit.vue +++ b/src/frontend/src/pages/CalculationMassEdit.vue @@ -1,3 +1,5 @@ + +