Browse Source

feat(server): Add currencyCode to ProductVariant

Michael Bromley 7 years ago
parent
commit
a86460b8c1

+ 6 - 0
server/src/entity/product-variant/product-variant.entity.ts

@@ -1,5 +1,6 @@
 import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany } from 'typeorm';
 
+import { CurrencyCode } from '../../../../shared/generated-types';
 import { DeepPartial, HasCustomFields } from '../../../../shared/shared-types';
 import { LocaleString, Translatable, Translation } from '../../common/types/locale-types';
 import { Asset } from '../asset/asset.entity';
@@ -34,6 +35,11 @@ export class ProductVariant extends VendureEntity implements Translatable, HasCu
     })
     price: number;
 
+    /**
+     * Calculated at run-time
+     */
+    currencyCode: CurrencyCode;
+
     /**
      * Calculated at run-time
      */

+ 1 - 0
server/src/entity/product-variant/product-variant.graphql

@@ -8,6 +8,7 @@ type ProductVariant implements Node {
     featuredAsset: Asset
     assets: [Asset!]!
     price: Int!
+    currencyCode: CurrencyCode!
     priceIncludesTax: Boolean!
     priceWithTax: Int!
     taxRateApplied: TaxRate!

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

@@ -231,6 +231,7 @@ export class ProductVariantService {
         variant.priceIncludesTax = priceIncludesTax;
         variant.priceWithTax = priceWithTax;
         variant.taxRateApplied = applicableTaxRate;
+        variant.currencyCode = ctx.channel.currencyCode;
         return variant;
     }