Browse Source

fix(server): Fix error on creating ProductVariant and no TaxRate exists

Michael Bromley 7 years ago
parent
commit
0a1da6153d
1 changed files with 5 additions and 0 deletions
  1. 5 0
      server/src/service/services/product-variant.service.ts

+ 5 - 0
server/src/service/services/product-variant.service.ts

@@ -188,6 +188,11 @@ export class ProductVariantService {
             taxCategory = taxCategories[0];
         }
 
+        if (!taxCategory) {
+            // there is no TaxCategory set up, so create a default
+            taxCategory = await this.taxCategoryService.create({ name: 'Standard Tax' });
+        }
+
         const variants: ProductVariant[] = [];
         for (const options of optionCombinations) {
             const name = this.createVariantName(productName, options);