Feat: Price selection implementation (#1158)
* init * added buld id validation to repo * admin done * updated price reqs * initial price selection strategy * update customer seeder * format models * price selection strategy * price selection testing * update price selection tests * update price selection strategy * remove console.warn * update price selection strat * remove console.log * fix unit tests * update product snapshot integration tests * fix failing unit tests * update variant test snapshots * intial implementation of PriceList * integration tests for price lists * updated admin/product integration tests * update updateVariantPrices method * remove comment from error handler * add integration test for batch deleting prices associated with price list * make update to prices through variant service limited to default prices * update store/products.js snapshot * add api unit tests and update product integration tests to validate that prices from Price List are ignored * fix product test * requested changes * cascade * ensure delete variant cascades to MoneyAmount * addresses PR feedback * removed unused endpoint * update mock * fix failing store integration tests * remove medusajs ressource * re add env.template * price selection strategy methods * fix integration tests * update unit tests * update jsdoc * update price selection strategy parameter * fix unit tests * pr feedback Co-authored-by: Kasper <kasper@medusajs.com> Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com>
This commit is contained in:
co-authored by
Kasper
Kasper Fabricius Kristensen
parent
5300926db8
commit
dfa3502e41
@@ -7,7 +7,7 @@ import {
|
||||
Index,
|
||||
ManyToMany,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||
@@ -23,20 +23,14 @@ export class CustomerGroup {
|
||||
@Column()
|
||||
name: string
|
||||
|
||||
@ManyToMany(
|
||||
() => Customer,
|
||||
(customer) => customer.groups,
|
||||
{
|
||||
onDelete: "CASCADE",
|
||||
}
|
||||
)
|
||||
@ManyToMany(() => Customer, (customer) => customer.groups, {
|
||||
onDelete: "CASCADE",
|
||||
})
|
||||
customers: Customer[]
|
||||
|
||||
@ManyToMany(
|
||||
() => PriceList,
|
||||
(priceList) => priceList.customer_groups,
|
||||
{ onDelete: "CASCADE" }
|
||||
)
|
||||
@ManyToMany(() => PriceList, (priceList) => priceList.customer_groups, {
|
||||
onDelete: "CASCADE",
|
||||
})
|
||||
price_lists: PriceList[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
|
||||
@@ -32,19 +32,14 @@ export class ProductVariant {
|
||||
@Column()
|
||||
product_id: string
|
||||
|
||||
@ManyToOne(
|
||||
() => Product,
|
||||
product => product.variants,
|
||||
{ eager: true }
|
||||
)
|
||||
@ManyToOne(() => Product, (product) => product.variants, { eager: true })
|
||||
@JoinColumn({ name: "product_id" })
|
||||
product: Product
|
||||
|
||||
@OneToMany(
|
||||
() => MoneyAmount,
|
||||
ma => ma.variant,
|
||||
{ cascade: true, onDelete: "CASCADE" }
|
||||
)
|
||||
@OneToMany(() => MoneyAmount, (ma) => ma.variant, {
|
||||
cascade: true,
|
||||
onDelete: "CASCADE",
|
||||
})
|
||||
prices: MoneyAmount[]
|
||||
|
||||
@Column({ nullable: true })
|
||||
@@ -99,11 +94,9 @@ export class ProductVariant {
|
||||
@Column({ type: "int", nullable: true })
|
||||
width: number
|
||||
|
||||
@OneToMany(
|
||||
() => ProductOptionValue,
|
||||
optionValue => optionValue.variant,
|
||||
{ cascade: true }
|
||||
)
|
||||
@OneToMany(() => ProductOptionValue, (optionValue) => optionValue.variant, {
|
||||
cascade: true,
|
||||
})
|
||||
options: ProductOptionValue[]
|
||||
|
||||
@CreateDateColumn({ type: resolveDbType("timestamptz") })
|
||||
@@ -120,7 +113,9 @@ export class ProductVariant {
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert() {
|
||||
if (this.id) return
|
||||
if (this.id) {
|
||||
return
|
||||
}
|
||||
const id = ulid()
|
||||
this.id = `variant_${id}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user