diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-09 11:15:23 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-09 11:15:23 +0100 |
| commit | 1de8f2f90284c375449326285f0b87e5e700a0c8 (patch) | |
| tree | f5d0d33b7229f4094ae30563b3b7d6ec4b934ea7 /import | |
| parent | a838a2d3963738b2e9bc496b31e078ead79d4a43 (diff) | |
| download | stock-1de8f2f90284c375449326285f0b87e5e700a0c8.tar.gz stock-1de8f2f90284c375449326285f0b87e5e700a0c8.tar.bz2 stock-1de8f2f90284c375449326285f0b87e5e700a0c8.zip | |
stock: PCK/SHT fractional display, movement qty summing, import qty type
Display fixes:
- list_stock, list_movements, view_component: PCK stock divides by
pack_size for fractional strip display; SHT shows 2 decimal places
- list_movements: pack_size fetched per component for PCK display
- All fractional formats use %.2f consistently
StockMovement::getList component filter:
- Replace INNER JOIN on xcmp with EXISTS subquery to avoid duplicate
rows when a component appears multiple times in a movement BOM
- cmp_qty now SUMs all matching xref rows so multi-assembly RQs
show total quantity rather than silently dropping duplicate rows
Movement BOM edit templates:
- stockmovement/edit_xref_bom_item.tpl: proper edit form for SGL/SHT/VOL
lines linking back to view_component
- stockmovement/edit_xref_bompck_item.tpl: same for PCK with pack size hint
Import:
- ImportSimpleComponent: columns 6/7 (qty_type, qty_value) wired up;
PCK/SHT/VOL writes qty xref so movement CSV imports pick up default type
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'import')
| -rw-r--r-- | import/ImportSimpleComponent.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/import/ImportSimpleComponent.php b/import/ImportSimpleComponent.php index 7db7c52..1f87375 100644 --- a/import/ImportSimpleComponent.php +++ b/import/ImportSimpleComponent.php @@ -5,14 +5,20 @@ * CSV column layout (0-based, header row skipped by loader): * 0 title Component name * 1 description Plain-text description (stored as bithtml content body) - * 2 supplier Supplier contact title, case-insensitive (optional) + * 2 supplier Supplier contact SCREF or title, case-insensitive (optional) * 3 supplier_pn Supplier part number → xref #PN in xkey_ext (optional) * 4 supplier_price Supplier price → xref #PR in xkey (optional) + * 5 supplier_url Supplier URL → xref #SUP data (optional) + * 6 qty_type SGL/PCK/SHT/VOL — omit or blank for SGL (optional) + * 7 qty_value Pack size for PCK (pieces per pack); dimensions for SHT (optional) * * Supplier name is matched against liberty_content.title for content_type_guid='contact'. * #SUP stores the contact content_id in the xref column; #PN and #PR share xorder=1 * so they are grouped with the #SUP entry as one supplier set. * + * Setting qty_type to PCK/SHT/VOL writes the appropriate xref on the component so that + * movement CSV imports pick up the correct default qty type without a manual override. + * * Existing components (matched by title) are skipped unless cleared first. * * @package stock @@ -88,6 +94,8 @@ function stockImportSimpleComponent( array $data, int $rowNum ): array { $supplierPn = trim( $data[3] ?? '' ); $supplierPrice = trim( $data[4] ?? '' ); $supplierUrl = trim( $data[5] ?? '' ); + $qtyType = strtoupper( trim( $data[6] ?? '' ) ); + $qtyValue = trim( $data[7] ?? '' ); $component = new StockComponent(); $pHash = [ @@ -123,6 +131,19 @@ function stockImportSimpleComponent( array $data, int $rowNum ): array { } } + // Quantity type xref — sets the default qty type used by movement CSV imports + // and the pack size shown in BOM displays (PCK xref xkey = pieces per pack) + if( in_array( $qtyType, [ 'PCK', 'SHT', 'VOL' ] ) ) { + $gBitDb->associateInsert( BIT_DB_PREFIX.'liberty_xref', [ + 'xref_id' => $gBitDb->GenID( 'liberty_xref_seq' ), + 'content_id' => $contentId, + 'item' => $qtyType, + 'xkey' => substr( $qtyValue, 0, 32 ), + 'xorder' => 0, + 'last_update_date' => $gBitDb->NOW(), + ] ); + } + $result['loaded']++; return $result; } |
