import { CartData, Discount } from "@frontend/kitui"
import { calcCart } from "./calcCart"
import { FullTariff } from "@root/model/tariff"


describe("Cart calculations", () => {
	describe("without discounts", () => {
		it("calculates cart with 1 item", () => {
			const cart = calcCart([templategenTariff1], [], 0)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 100 * 100,
				priceBeforeDiscounts: 100 * 100,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
                    amount: 100,
										price: 100 * 100,
										appliedPrivilegeDiscount: null,
									},
								],
							}
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("calculates cart with 3 items", () => {
			const cart = calcCart([templategenTariff1, squizTariff, reducerTariff], [], 0)

			const expectedCart: CartData = {
				itemCount: 3,
				priceAfterDiscounts: 100 * 100 + 200 * 200 + 300 * 300,
				priceBeforeDiscounts: 100 * 100 + 200 * 200 + 300 * 300,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
                    amount: 100,
										price: 100 * 100,
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
					{
						serviceKey: "squiz",
						price: 200 * 200,
						tariffs: [
							{
								id: "t2",
								name: "squizTariff",
								price: 200 * 200,
								isCustom: false,
								privileges: [
									{
										description: "d2",
										price: 200 * 200,
										privilegeId: "p2",
										serviceKey: "squiz",
                    amount: 200,
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
					{
						serviceKey: "reducer",
						price: 300 * 300,
						tariffs: [
							{
								id: "t3",
								name: "reducerTariff",
								price: 300 * 300,
								isCustom: false,
								privileges: [
									{
										description: "d3",
										price: 300 * 300,
                    amount: 300,
										privilegeId: "p3",
										serviceKey: "reducer",
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("calculates cart with items for the same service", () => {
			const cart = calcCart([templategenTariff1, templategenTariff2, reducerTariff], [], 0)

			const expectedCart: CartData = {
				itemCount: 3,
				priceAfterDiscounts: 100 * 100 + 600 * 600 + 300 * 300,
				priceBeforeDiscounts: 100 * 100 + 600 * 600 + 300 * 300,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100 + 600 * 600,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100,
                    amount: 100,
										appliedPrivilegeDiscount: null,
									},
								],
							},
							{
								id: "t5",
								name: "templategenTariff2",
								price: 600 * 600,
								isCustom: false,
								privileges: [
									{
										description: "d5",
										price: 600 * 600,
                    amount: 600,
										privilegeId: "p5",
										serviceKey: "templategen",
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
					{
						serviceKey: "reducer",
						price: 300 * 300,
						tariffs: [
							{
								id: "t3",
								name: "reducerTariff",
								price: 300 * 300,
								isCustom: false,
								privileges: [
									{
										description: "d3",
										price: 300 * 300,
                    amount: 300,
										privilegeId: "p3",
										serviceKey: "reducer",
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("returns blank cart when no tariffs", () => {
			const cart = calcCart([], [], 0)

			const expectedCart: CartData = {
				itemCount: 0,
				priceAfterDiscounts: 0,
				priceBeforeDiscounts: 0,
				services: [],
				allAppliedDiscounts: [],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})
	})

	describe("with single discount", () => {
		it("applies privilege discount to tariff 1", () => {
			const cart = calcCart([templategenTariff1], [templategenP1PrivilegeDiscount], 0)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 100 * 100 * 0.9,
				priceBeforeDiscounts: 100 * 100,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100 * 0.9,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100 * 0.9,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100 * 0.9,
                    amount: 100,
										appliedPrivilegeDiscount: templategenP1PrivilegeDiscount,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [templategenP1PrivilegeDiscount],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("applies privilege discount to tariff 2", () => {
			const cart = calcCart([reducerTariff], [reducerPrivilegeDiscount], 0)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 300 * 300 * 0.95,
				priceBeforeDiscounts: 300 * 300,
				services: [
					{
						serviceKey: "reducer",
						price: 300 * 300 * 0.95,
						tariffs: [
							{
								id: "t3",
								name: "reducerTariff",
								price: 300 * 300 * 0.95,
								isCustom: false,
								privileges: [
									{
										description: "d3",
										price: 300 * 300 * 0.95,
                    amount: 300,
										privilegeId: "p3",
										serviceKey: "reducer",
										appliedPrivilegeDiscount: reducerPrivilegeDiscount,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [reducerPrivilegeDiscount],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("applies service discount to tariffs", () => {
			const cart = calcCart([templategenTariff1, templategenTariff2], [templategenServiceDiscount], 0)

			const expectedCart: CartData = {
				itemCount: 2,
				priceAfterDiscounts: (100 * 100 + 600 * 600) * 0.8,
				priceBeforeDiscounts: 100 * 100 + 600 * 600,
				services: [
					{
						serviceKey: "templategen",
						price: (100 * 100 + 600 * 600) * 0.8,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100 * 0.8,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100 * 0.8,
                    amount: 100,
										appliedPrivilegeDiscount: null,
									},
								],
							},
							{
								id: "t5",
								name: "templategenTariff2",
								price: 600 * 600 * 0.8,
								isCustom: false,
								privileges: [
									{
										description: "d5",
										price: 600 * 600 * 0.8,
                    amount: 600,
										privilegeId: "p5",
										serviceKey: "templategen",
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: templategenServiceDiscount,
					},
				],
				allAppliedDiscounts: [templategenServiceDiscount],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("applies privilege discount to 2 tariffs", () => {
			const cart = calcCart([templategenTariff1, templategenTariff2], [templategenP1PrivilegeDiscount], 0)

			const expectedCart: CartData = {
				itemCount: 2,
				priceAfterDiscounts: 100 * 100 * 0.9 + 600 * 600,
				priceBeforeDiscounts: 100 * 100 + 600 * 600,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100 * 0.9 + 600 * 600,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100 * 0.9,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100 * 0.9,
                    amount: 100,
										appliedPrivilegeDiscount: templategenP1PrivilegeDiscount,
									},
								],
							},
							{
								id: "t5",
								name: "templategenTariff2",
								price: 600 * 600,
								isCustom: false,
								privileges: [
									{
										description: "d5",
										price: 600 * 600,
                    amount: 600,
										privilegeId: "p5",
										serviceKey: "templategen",
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [templategenP1PrivilegeDiscount],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("applies cart purchases discount to tariff", () => {
			const cart = calcCart([templategenTariff1], [cartPurchasesDiscount], 0)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 100 * 100 * 0.7,
				priceBeforeDiscounts: 100 * 100,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100,
                    amount: 100,
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [cartPurchasesDiscount],
				appliedCartPurchasesDiscount: cartPurchasesDiscount,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("doesn't apply cart purchases discount when cartPurchasesAmount is not enough", () => {
			const cart = calcCart([templategenTariff1], [highAmountCartPurchasesDiscount], 0)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 100 * 100,
				priceBeforeDiscounts: 100 * 100,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100,
                    amount: 100,
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("applies loyalty discount to tariff", () => {
			const cart = calcCart([templategenTariff1], [loyaltyDiscount], 1001)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 100 * 100 * 0.6,
				priceBeforeDiscounts: 100 * 100,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100,
                    amount: 100,
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [loyaltyDiscount],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: loyaltyDiscount,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("doesn't apply loyalty discount when purchasesAmount is not enough", () => {
			const cart = calcCart([templategenTariff1], [loyaltyDiscount], 0)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 100 * 100,
				priceBeforeDiscounts: 100 * 100,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100,
                    amount: 100,
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})
	})

	describe("with multiple discounts", () => {
		it("applies privilege and service discounts to tariff", () => {
			const cart = calcCart([templategenTariff1], [templategenP1PrivilegeDiscount, templategenServiceDiscount], 0)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 100 * 100 * 0.9 * 0.8,
				priceBeforeDiscounts: 100 * 100,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100 * 0.9 * 0.8,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100 * 0.9 * 0.8,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100 * 0.9 * 0.8,
                    amount: 100,
										appliedPrivilegeDiscount: templategenP1PrivilegeDiscount,
									},
								],
							},
						],
						appliedServiceDiscount: templategenServiceDiscount,
					},
				],
				allAppliedDiscounts: [templategenP1PrivilegeDiscount, templategenServiceDiscount],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("applies all types of discounts to tariff", () => {
			const cart = calcCart(
				[templategenTariff1],
				[templategenP1PrivilegeDiscount, templategenServiceDiscount, cartPurchasesDiscount, loyaltyDiscount],
				1001
			)

			const expectedCart: CartData = {
				itemCount: 1,
				priceAfterDiscounts: 100 * 100 * 0.9 * 0.8 * 0.7 * 0.6,
				priceBeforeDiscounts: 100 * 100,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100 * 0.9 * 0.8,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100 * 0.9 * 0.8,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100 * 0.9 * 0.8,
                    amount: 100,
										appliedPrivilegeDiscount: templategenP1PrivilegeDiscount,
									},
								],
							},
						],
						appliedServiceDiscount: templategenServiceDiscount,
					},
				],
				allAppliedDiscounts: [templategenP1PrivilegeDiscount, templategenServiceDiscount, cartPurchasesDiscount, loyaltyDiscount],
				appliedCartPurchasesDiscount: cartPurchasesDiscount,
				appliedLoyaltyDiscount: loyaltyDiscount,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("applies different discounts to different tariffs", () => {
			const cart = calcCart(
				[templategenTariff1, reducerTariff],
				[templategenP1PrivilegeDiscount, reducerPrivilegeDiscount],
				1001
			)

			const expectedCart: CartData = {
				itemCount: 2,
				priceAfterDiscounts: 100 * 100 * 0.9 + 300 * 300 * 0.95,
				priceBeforeDiscounts: 100 * 100 + 300 * 300,
				services: [
					{
						serviceKey: "templategen",
						price: 100 * 100 * 0.9,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100 * 0.9,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100 * 0.9,
                    amount: 100,
										appliedPrivilegeDiscount: templategenP1PrivilegeDiscount,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
					{
						serviceKey: "reducer",
						price: 300 * 300 * 0.95,
						tariffs: [
							{
								id: "t3",
								name: "reducerTariff",
								price: 300 * 300 * 0.95,
								isCustom: false,
								privileges: [
									{
										description: "d3",
										price: 300 * 300 * 0.95,
                    amount: 300,
										privilegeId: "p3",
										serviceKey: "reducer",
										appliedPrivilegeDiscount: reducerPrivilegeDiscount,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [templategenP1PrivilegeDiscount, reducerPrivilegeDiscount],
				appliedCartPurchasesDiscount: null,
				appliedLoyaltyDiscount: null,
			}
			expect(cart).toStrictEqual(expectedCart)
		})

		it("applies all types of discounts to multiple tariffs", () => {
			const cart = calcCart(
				[templategenTariff1, templategenTariff2, squizTariff, reducerTariff],
				[templategenP1PrivilegeDiscount, reducerPrivilegeDiscount, templategenServiceDiscount, cartPurchasesDiscount, loyaltyDiscount],
				1001
			)

			const expectedCart: CartData = {
				itemCount: 4,
				priceAfterDiscounts: ((100 * 100 * 0.9 + 600 * 600) * 0.8 + 200 * 200 + 300 * 300 * 0.95) * 0.7 * 0.6,
				priceBeforeDiscounts: 100 * 100 + 600 * 600 + 200 * 200 + 300 * 300,
				services: [
					{
						serviceKey: "templategen",
						price: (100 * 100 * 0.9 + 600 * 600) * 0.8,
						tariffs: [
							{
								id: "t1",
								name: "templategenTariff1",
								price: 100 * 100 * 0.9 * 0.8,
								isCustom: false,
								privileges: [
									{
										privilegeId: "p1",
										serviceKey: "templategen",
										description: "d1",
										price: 100 * 100 * 0.9 * 0.8,
                    amount: 100,
										appliedPrivilegeDiscount: templategenP1PrivilegeDiscount,
									},
								],
							},
							{
								id: "t5",
								name: "templategenTariff2",
								price: 600 * 600 * 0.8,
								isCustom: false,
								privileges: [
									{
										description: "d5",
										price: 600 * 600 * 0.8,
                    amount: 600,
										privilegeId: "p5",
										serviceKey: "templategen",
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: templategenServiceDiscount,
					},
					{
						serviceKey: "squiz",
						price: 200 * 200,
						tariffs: [
							{
								id: "t2",
								name: "squizTariff",
								price: 200 * 200,
								isCustom: false,
								privileges: [
									{
										description: "d2",
										price: 200 * 200,
                    amount: 200,
										privilegeId: "p2",
										serviceKey: "squiz",
										appliedPrivilegeDiscount: null,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
					{
						serviceKey: "reducer",
						price: 300 * 300 * 0.95,
						tariffs: [
							{
								id: "t3",
								name: "reducerTariff",
								price: 300 * 300 * 0.95,
								isCustom: false,
								privileges: [
									{
										description: "d3",
										price: 300 * 300 * 0.95,
                    amount: 300,
										privilegeId: "p3",
										serviceKey: "reducer",
										appliedPrivilegeDiscount: reducerPrivilegeDiscount,
									},
								],
							},
						],
						appliedServiceDiscount: null,
					},
				],
				allAppliedDiscounts: [templategenP1PrivilegeDiscount, reducerPrivilegeDiscount, templategenServiceDiscount, cartPurchasesDiscount, loyaltyDiscount],
				appliedCartPurchasesDiscount: cartPurchasesDiscount,
				appliedLoyaltyDiscount: loyaltyDiscount,
			}
			expect(cart).toStrictEqual(expectedCart)
		})
	})
})

const templategenTariff1: FullTariff = {
	_id: "t1",
	name: "templategenTariff1",
	price: 0,
  description: "test",
	isCustom: false,
	privileges: [
		{
			_id: "p1",
			name: "n1",
			privilegeId: "p1",
			serviceKey: "templategen",
			description: "d1",
			type: "count",
			value: "МБ",
			price: 100,
			amount: 100,
		},
	],
	isDeleted: false,
	createdAt: "",
	updatedAt: ""
}

const templategenTariff2: FullTariff = {
	_id: "t5",
	name: "templategenTariff2",
	price: 0,
	isCustom: false,
  description: "test",
	privileges: [
		{
			_id: "p5",
			name: "n5",
			privilegeId: "p5",
			serviceKey: "templategen",
			description: "d5",
			type: "count",
			value: "МБ",
			price: 600,
			amount: 600,
		},
	],
	isDeleted: false,
	createdAt: "",
	updatedAt: ""
}

const squizTariff: FullTariff = {
	_id: "t2",
	name: "squizTariff",
	price: 0,
  description: "test",
	isCustom: false,
	privileges: [
		{
			_id: "p2",
			name: "n2",
			privilegeId: "p2",
			serviceKey: "squiz",
			description: "d2",
			type: "count",
			value: "МБ",
			price: 200,
			amount: 200,
		},
	],
	isDeleted: false,
	createdAt: "",
	updatedAt: ""
}

const reducerTariff: FullTariff = {
	_id: "t3",
	name: "reducerTariff",
  description: "test",
	price: 0,
	isCustom: false,
	privileges: [
		{
			_id: "p3",
			name: "n3",
			privilegeId: "p3",
			serviceKey: "reducer",
			description: "d3",
			type: "count",
			value: "МБ",
			price: 300,
			amount: 300,
		},
	],
	isDeleted: false,
	createdAt: "",
	updatedAt: ""
}

const templategenP1PrivilegeDiscount: Discount = {
	ID: "id1",
	Name: "n1",
	Layer: 1,
	Description: "d1",
	Condition: {
		Period: {
			From: "",
			To: ""
		},
		User: "",
		UserType: "",
		Coupon: "",
		PurchasesAmount: 0,
		CartPurchasesAmount: 0,
		Product: "p1",
		Term: "1000",
		Usage: "0",
		PriceFrom: 0,
		Group: "templategen"
	},
	Target: {
		Products: [
			{
				ID: "p1",
				Factor: 0.9,
				Overhelm: false
			}
		],
		Factor: 0.9,
		TargetScope: "Sum",
		TargetGroup: "templategen",
		Overhelm: false
	},
	Audit: {
		UpdatedAt: "",
		CreatedAt: "",
		Deleted: false
	},
	Deprecated: false
}

const templategenServiceDiscount: Discount = {
	ID: "id2",
	Name: "n2",
	Layer: 2,
	Description: "d2",
	Condition: {
		Period: {
			From: "",
			To: ""
		},
		User: "",
		UserType: "",
		Coupon: "",
		PurchasesAmount: 0,
		CartPurchasesAmount: 0,
		Product: "",
		Term: "1000",
		Usage: "0",
		PriceFrom: 0,
		Group: "templategen"
	},
	Target: {
		Products: [
			{
				ID: "",
				Factor: 0.8,
				Overhelm: false
			}
		],
		Factor: 0.8,
		TargetScope: "Sum",
		TargetGroup: "templategen",
		Overhelm: false
	},
	Audit: {
		UpdatedAt: "",
		CreatedAt: "",
		Deleted: false
	},
	Deprecated: false
}

const reducerPrivilegeDiscount: Discount = {
	ID: "id11",
	Name: "n11",
	Layer: 1,
	Description: "d11",
	Condition: {
		Period: {
			From: "",
			To: ""
		},
		User: "",
		UserType: "",
		Coupon: "",
		PurchasesAmount: 0,
		CartPurchasesAmount: 0,
		Product: "p3",
		Term: "1000",
		Usage: "0",
		PriceFrom: 0,
		Group: "reducer"
	},
	Target: {
		Products: [
			{
				ID: "p1",
				Factor: 0.95,
				Overhelm: false
			}
		],
		Factor: 0.95,
		TargetScope: "Sum",
		TargetGroup: "reducer",
		Overhelm: false
	},
	Audit: {
		UpdatedAt: "",
		CreatedAt: "",
		Deleted: false
	},
	Deprecated: false
}

const cartPurchasesDiscount: Discount = {
	ID: "id3",
	Name: "n3",
	Layer: 3,
	Description: "d3",
	Condition: {
		Period: {
			From: "",
			To: ""
		},
		User: "",
		UserType: "",
		Coupon: "",
		PurchasesAmount: 0,
		CartPurchasesAmount: 1000,
		Product: "",
		Term: "0",
		Usage: "0",
		PriceFrom: 0,
		Group: "templategen"
	},
	Target: {
		Products: [
			{
				ID: "p1",
				Factor: 0.7,
				Overhelm: false
			}
		],
		Factor: 0.7,
		TargetScope: "Sum",
		TargetGroup: "templategen",
		Overhelm: false
	},
	Audit: {
		UpdatedAt: "",
		CreatedAt: "",
		Deleted: false
	},
	Deprecated: false
}

const highAmountCartPurchasesDiscount: Discount = {
	ID: "id3",
	Name: "n3",
	Layer: 3,
	Description: "d3",
	Condition: {
		Period: {
			From: "",
			To: ""
		},
		User: "",
		UserType: "",
		Coupon: "",
		PurchasesAmount: 0,
		CartPurchasesAmount: 1000000,
		Product: "",
		Term: "0",
		Usage: "0",
		PriceFrom: 0,
		Group: "templategen"
	},
	Target: {
		Products: [
			{
				ID: "p1",
				Factor: 0.7,
				Overhelm: false
			}
		],
		Factor: 0.7,
		TargetScope: "Sum",
		TargetGroup: "templategen",
		Overhelm: false
	},
	Audit: {
		UpdatedAt: "",
		CreatedAt: "",
		Deleted: false
	},
	Deprecated: false
}

const loyaltyDiscount: Discount = {
	ID: "id3",
	Name: "n3",
	Layer: 4,
	Description: "d3",
	Condition: {
		Period: {
			From: "",
			To: ""
		},
		User: "",
		UserType: "",
		Coupon: "",
		PurchasesAmount: 1000,
		CartPurchasesAmount: 0,
		Product: "",
		Term: "0",
		Usage: "0",
		PriceFrom: 0,
		Group: "templategen"
	},
	Target: {
		Products: [
			{
				ID: "p1",
				Factor: 0.6,
				Overhelm: false
			}
		],
		Factor: 0.6,
		TargetScope: "Sum",
		TargetGroup: "templategen",
		Overhelm: false
	},
	Audit: {
		UpdatedAt: "",
		CreatedAt: "",
		Deleted: false
	},
	Deprecated: false
}
