|
@@ -56,7 +56,6 @@ export interface VariantFormValue {
|
|
|
sku: string;
|
|
sku: string;
|
|
|
name: string;
|
|
name: string;
|
|
|
price: number;
|
|
price: number;
|
|
|
- priceIncludesTax: boolean;
|
|
|
|
|
priceWithTax: number;
|
|
priceWithTax: number;
|
|
|
taxCategoryId: string;
|
|
taxCategoryId: string;
|
|
|
stockOnHand: number;
|
|
stockOnHand: number;
|
|
@@ -99,6 +98,7 @@ export class ProductDetailComponent
|
|
|
selectedVariantIds: string[] = [];
|
|
selectedVariantIds: string[] = [];
|
|
|
variantDisplayMode: 'card' | 'table' = 'card';
|
|
variantDisplayMode: 'card' | 'table' = 'card';
|
|
|
createVariantsConfig: CreateProductVariantsConfig = { groups: [], variants: [] };
|
|
createVariantsConfig: CreateProductVariantsConfig = { groups: [], variants: [] };
|
|
|
|
|
+ channelPriceIncludesTax$: Observable<boolean>;
|
|
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
|
route: ActivatedRoute,
|
|
route: ActivatedRoute,
|
|
@@ -183,6 +183,11 @@ export class ProductDetailComponent
|
|
|
|
|
|
|
|
this.facetValues$ = merge(productFacetValues$, formChangeFacetValues$);
|
|
this.facetValues$ = merge(productFacetValues$, formChangeFacetValues$);
|
|
|
this.productChannels$ = this.product$.pipe(map(p => p.channels));
|
|
this.productChannels$ = this.product$.pipe(map(p => p.channels));
|
|
|
|
|
+ this.channelPriceIncludesTax$ = this.dataService.settings
|
|
|
|
|
+ .getActiveChannel('cache-first')
|
|
|
|
|
+ .refetchOnChannelChange()
|
|
|
|
|
+ .mapStream(data => data.activeChannel.pricesIncludeTax)
|
|
|
|
|
+ .pipe(shareReplay(1));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
ngOnDestroy() {
|
|
@@ -455,10 +460,10 @@ export class ProductDetailComponent
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
save() {
|
|
save() {
|
|
|
- combineLatest(this.product$, this.languageCode$)
|
|
|
|
|
|
|
+ combineLatest(this.product$, this.languageCode$, this.channelPriceIncludesTax$)
|
|
|
.pipe(
|
|
.pipe(
|
|
|
take(1),
|
|
take(1),
|
|
|
- mergeMap(([product, languageCode]) => {
|
|
|
|
|
|
|
+ mergeMap(([product, languageCode, priceIncludesTax]) => {
|
|
|
const productGroup = this.getProductFormGroup();
|
|
const productGroup = this.getProductFormGroup();
|
|
|
let productInput: UpdateProductInput | undefined;
|
|
let productInput: UpdateProductInput | undefined;
|
|
|
let variantsInput: UpdateProductVariantInput[] | undefined;
|
|
let variantsInput: UpdateProductVariantInput[] | undefined;
|
|
@@ -476,6 +481,7 @@ export class ProductDetailComponent
|
|
|
product,
|
|
product,
|
|
|
variantsArray as FormArray,
|
|
variantsArray as FormArray,
|
|
|
languageCode,
|
|
languageCode,
|
|
|
|
|
+ priceIncludesTax,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -546,7 +552,6 @@ export class ProductDetailComponent
|
|
|
sku: variant.sku,
|
|
sku: variant.sku,
|
|
|
name: variantTranslation ? variantTranslation.name : '',
|
|
name: variantTranslation ? variantTranslation.name : '',
|
|
|
price: variant.price,
|
|
price: variant.price,
|
|
|
- priceIncludesTax: variant.priceIncludesTax,
|
|
|
|
|
priceWithTax: variant.priceWithTax,
|
|
priceWithTax: variant.priceWithTax,
|
|
|
taxCategoryId: variant.taxCategory.id,
|
|
taxCategoryId: variant.taxCategory.id,
|
|
|
stockOnHand: variant.stockOnHand,
|
|
stockOnHand: variant.stockOnHand,
|
|
@@ -627,6 +632,7 @@ export class ProductDetailComponent
|
|
|
product: ProductWithVariants.Fragment,
|
|
product: ProductWithVariants.Fragment,
|
|
|
variantsFormArray: FormArray,
|
|
variantsFormArray: FormArray,
|
|
|
languageCode: LanguageCode,
|
|
languageCode: LanguageCode,
|
|
|
|
|
+ priceIncludesTax: boolean,
|
|
|
): UpdateProductVariantInput[] {
|
|
): UpdateProductVariantInput[] {
|
|
|
const dirtyVariants = product.variants.filter((v, i) => {
|
|
const dirtyVariants = product.variants.filter((v, i) => {
|
|
|
const formRow = variantsFormArray.get(i.toString());
|
|
const formRow = variantsFormArray.get(i.toString());
|
|
@@ -652,6 +658,7 @@ export class ProductDetailComponent
|
|
|
});
|
|
});
|
|
|
result.taxCategoryId = formValue.taxCategoryId;
|
|
result.taxCategoryId = formValue.taxCategoryId;
|
|
|
result.facetValueIds = formValue.facetValueIds;
|
|
result.facetValueIds = formValue.facetValueIds;
|
|
|
|
|
+ result.price = priceIncludesTax ? formValue.priceWithTax : formValue.price;
|
|
|
const assetChanges = this.variantAssetChanges[variant.id];
|
|
const assetChanges = this.variantAssetChanges[variant.id];
|
|
|
if (assetChanges) {
|
|
if (assetChanges) {
|
|
|
result.featuredAssetId = assetChanges.featuredAssetId;
|
|
result.featuredAssetId = assetChanges.featuredAssetId;
|