Simplify DFC product controller

This commit is contained in:
Maikel Linke
2024-03-12 13:05:48 +11:00
parent 85a47e61fd
commit 1674d8ab5c
2 changed files with 3 additions and 8 deletions

View File

@@ -20,14 +20,8 @@ module DfcProvider
)
product = variant.product
if product.new_record?
product.supplier = current_enterprise
product.save!
end
if variant.new_record?
variant.save!
end
product.save! if product.new_record?
variant.save! if variant.new_record?
supplied_product = SuppliedProductBuilder.supplied_product(variant)
render json: DfcIo.export(supplied_product)

View File

@@ -35,6 +35,7 @@ class SuppliedProductBuilder < DfcBuilder
end
else
product = import_product(supplied_product)
product.supplier = supplier
product.ensure_standard_variant
product.variants.first
end