-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 74 customer pricelist (#78) - Part 1
This is the first part about the Customer Price List adding the Customer Price List CRUD screens and the sales invoice line calculation. It is missing: - changes in the invoicing screen - setting up the products for the Customer Price List - reports
- Loading branch information
1 parent
ca94e4f
commit f841893
Showing
62 changed files
with
1,974 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
apps/api/src/app/migrations/1618661208366-CustomerPriceList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class CustomerPriceList1618661208366 implements MigrationInterface { | ||
name = 'CustomerPriceList1618661208366'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TABLE "public"."customerProductPrice" ("id" SERIAL NOT NULL, "sellingPrice" numeric(12,2) NOT NULL, "productId" integer NOT NULL, "customerPriceListId" integer NOT NULL, CONSTRAINT "PK_41712b48577a11adfdbb81efdf9" PRIMARY KEY ("id"))`, | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "public"."customerPriceList" ("id" SERIAL NOT NULL, "displayName" character varying NOT NULL, "validFrom" TIMESTAMP, "validTo" TIMESTAMP, "customerGroupId" integer NOT NULL, CONSTRAINT "PK_3a410c80620c92c128634387f20" PRIMARY KEY ("id"))`, | ||
); | ||
await queryRunner.query( | ||
`CREATE UNIQUE INDEX "IDX_customerPriceList_displayName" ON "public"."customerPriceList" ("displayName") `, | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "public"."customerGroup" ("id" SERIAL NOT NULL, "updtTs" TIMESTAMP NOT NULL DEFAULT now(), "isActive" boolean NOT NULL DEFAULT true, "isCurrent" boolean NOT NULL DEFAULT true, "displayName" character varying NOT NULL, "updtOpId" integer NOT NULL, CONSTRAINT "PK_2f921748bb8e683b3d7007182ca" PRIMARY KEY ("id"))`, | ||
); | ||
await queryRunner.query( | ||
`CREATE UNIQUE INDEX "IDX_customerGroup_displayName" ON "public"."customerGroup" ("displayName") `, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."unit_of_measurement_conversion" DROP COLUMN IF EXISTS "end"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."unit_of_measurement_conversion" DROP COLUMN IF EXISTS "start"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customer" ADD "customerGroupId" integer`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."user" ALTER COLUMN "updtOpId" SET DEFAULT 0`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customerProductPrice" ADD CONSTRAINT "FK_51fd886ac463154b1fb68ad944a" FOREIGN KEY ("productId") REFERENCES "public"."product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customerProductPrice" ADD CONSTRAINT "FK_5fad018dfcf766b9fab575e5ea1" FOREIGN KEY ("customerPriceListId") REFERENCES "public"."customerPriceList"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customerPriceList" ADD CONSTRAINT "FK_635c71f6ed02473cca6603a3079" FOREIGN KEY ("customerGroupId") REFERENCES "public"."customerGroup"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customerGroup" ADD CONSTRAINT "FK_6622e70e814cce558a98043c611" FOREIGN KEY ("updtOpId") REFERENCES "public"."user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customer" ADD CONSTRAINT "FK_07b06500ab5d46137b7f87cc53c" FOREIGN KEY ("customerGroupId") REFERENCES "public"."customerGroup"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customer" DROP CONSTRAINT "FK_07b06500ab5d46137b7f87cc53c"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customerGroup" DROP CONSTRAINT "FK_6622e70e814cce558a98043c611"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customerPriceList" DROP CONSTRAINT "FK_635c71f6ed02473cca6603a3079"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customerProductPrice" DROP CONSTRAINT "FK_5fad018dfcf766b9fab575e5ea1"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customerProductPrice" DROP CONSTRAINT "FK_51fd886ac463154b1fb68ad944a"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."user" ALTER COLUMN "updtOpId" SET DEFAULT '0'`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "public"."customer" DROP COLUMN "customerGroupId"`, | ||
); | ||
await queryRunner.query( | ||
`DROP INDEX "public"."IDX_customerGroup_displayName"`, | ||
); | ||
await queryRunner.query(`DROP TABLE "public"."customerGroup"`); | ||
await queryRunner.query( | ||
`DROP INDEX "public"."IDX_customerPriceList_displayName"`, | ||
); | ||
await queryRunner.query(`DROP TABLE "public"."customerPriceList"`); | ||
await queryRunner.query(`DROP TABLE "public"."customerProductPrice"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Args, Int, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { Inject, UseGuards } from '@nestjs/common'; | ||
import { CurrentUser, GqlAuthGuard } from '../../auth'; | ||
import { CustomerGroup } from '../../model/generated/entities/CustomerGroup'; | ||
import { | ||
CustomerGroupModel, | ||
CustomerGroupService, | ||
CustomerGroupServiceKey, | ||
} from '../../model'; | ||
import { getManager } from 'typeorm'; | ||
import { CustomerGroupSaveArgs } from '../saveArgs/customerGroup.save.args'; | ||
|
||
@Resolver(() => CustomerGroup) | ||
@UseGuards(GqlAuthGuard) | ||
export class CustomerGroupResolver { | ||
constructor( | ||
@Inject(CustomerGroupServiceKey) | ||
protected readonly customerGroupService: CustomerGroupService, | ||
) {} | ||
|
||
@Query(() => [CustomerGroup]) | ||
async customerGroups() { | ||
return await this.customerGroupService.loadEntities(getManager()); | ||
} | ||
|
||
@Query(() => CustomerGroup) | ||
async customerGroup(@Args('id', { type: () => Int }) id: number) { | ||
return await this.customerGroupService.loadEntityById(getManager(), id); | ||
} | ||
|
||
@Mutation(() => CustomerGroup) | ||
async saveCustomerGroup( | ||
@Args('args') objData: CustomerGroupSaveArgs, | ||
@CurrentUser() user, | ||
): Promise<CustomerGroupModel> { | ||
return await this.customerGroupService.save(getManager(), objData, user); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
apps/api/src/app/resolvers/customer.price.list.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Args, Int, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { Inject, UseGuards } from '@nestjs/common'; | ||
import { CurrentUser, GqlAuthGuard } from '../../auth'; | ||
import { CustomerPriceList } from '../../model/generated/entities/CustomerPriceList'; | ||
import { | ||
CustomerPriceListModel, | ||
CustomerPriceListService, | ||
CustomerPriceListServiceKey, | ||
} from '../../model'; | ||
import { getManager } from 'typeorm'; | ||
import { CustomerPriceListSaveArgs } from '../saveArgs/customerPriceList.save.args'; | ||
|
||
@Resolver(() => CustomerPriceList) | ||
@UseGuards(GqlAuthGuard) | ||
export class CustomerPriceListResolver { | ||
constructor( | ||
@Inject(CustomerPriceListServiceKey) | ||
protected readonly customerPriceListService: CustomerPriceListService, | ||
) {} | ||
|
||
@Query(() => [CustomerPriceList]) | ||
async customerPriceLists() { | ||
return await this.customerPriceListService.loadEntities(getManager()); | ||
} | ||
|
||
@Query(() => CustomerPriceList) | ||
async customerPriceList(@Args('id', { type: () => Int }) id: number) { | ||
return await this.customerPriceListService.loadEntityById(getManager(), id); | ||
} | ||
|
||
@Mutation(() => CustomerPriceList) | ||
async saveCustomerPriceList( | ||
@Args('args') objData: CustomerPriceListSaveArgs, | ||
@CurrentUser() user, | ||
): Promise<CustomerPriceListModel> { | ||
return await this.customerPriceListService.save( | ||
getManager(), | ||
objData, | ||
user, | ||
); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
apps/api/src/app/resolvers/customer.product.price.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Args, Int, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { Inject, UseGuards } from '@nestjs/common'; | ||
import { CurrentUser, GqlAuthGuard } from '../../auth'; | ||
import { CustomerProductPrice } from '../../model/generated/entities/CustomerProductPrice'; | ||
import { | ||
CustomerProductPriceModel, | ||
CustomerProductPriceService, | ||
CustomerProductPriceServiceKey, | ||
} from '../../model'; | ||
import { getManager } from 'typeorm'; | ||
import { CustomerProductPriceSaveArgs } from '../saveArgs/customer.product.price.save.args'; | ||
|
||
@Resolver(() => CustomerProductPrice) | ||
@UseGuards(GqlAuthGuard) | ||
export class CustomerProductPriceResolver { | ||
constructor( | ||
@Inject(CustomerProductPriceServiceKey) | ||
protected readonly customerProductPriceService: CustomerProductPriceService, | ||
) {} | ||
|
||
@Query(() => [CustomerProductPrice]) | ||
async customerProductPrices() { | ||
return await this.customerProductPriceService.loadEntities(getManager()); | ||
} | ||
|
||
@Query(() => CustomerProductPrice) | ||
async customerProductPrice(@Args('id', { type: () => Int }) id: number) { | ||
return await this.customerProductPriceService.loadEntityById( | ||
getManager(), | ||
id, | ||
); | ||
} | ||
|
||
@Mutation(() => CustomerProductPrice) | ||
async saveCustomerProductPrice( | ||
@Args('args') objData: CustomerProductPriceSaveArgs, | ||
@CurrentUser() user, | ||
): Promise<CustomerProductPriceModel> { | ||
return await this.customerProductPriceService.save( | ||
getManager(), | ||
objData, | ||
user, | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
apps/api/src/app/saveArgs/customer.product.price.save.args.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { BaseSaveArgs } from './base.save.args'; | ||
import { CustomerProductPriceSaveArgsModel } from '../../model'; | ||
import { Field, InputType } from '@nestjs/graphql'; | ||
|
||
@InputType() | ||
export class CustomerProductPriceSaveArgs extends BaseSaveArgs | ||
implements CustomerProductPriceSaveArgsModel { | ||
@Field() | ||
customerPriceListDisplayName: string; | ||
@Field() | ||
productSKU: string; | ||
@Field() | ||
sellingPrice: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { BaseSaveArgs } from './base.save.args'; | ||
import { CustomerGroupSaveArgsModel } from '../../model'; | ||
import { Field, InputType } from '@nestjs/graphql'; | ||
|
||
@InputType() | ||
export class CustomerGroupSaveArgs extends BaseSaveArgs | ||
implements CustomerGroupSaveArgsModel { | ||
@Field() | ||
displayName: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { BaseSaveArgs } from './base.save.args'; | ||
import { CustomerPriceListSaveArgsModel, ProductPrice } from '../../model'; | ||
import { Field, InputType } from '@nestjs/graphql'; | ||
|
||
@InputType() | ||
export class ProductPriceSaveArgs implements ProductPrice { | ||
@Field() | ||
productSKU: string; | ||
@Field() | ||
sellingPrice: number; | ||
} | ||
|
||
@InputType() | ||
export class CustomerPriceListSaveArgs extends BaseSaveArgs | ||
implements CustomerPriceListSaveArgsModel { | ||
@Field() | ||
customerGroupDisplayName: string; | ||
@Field() | ||
displayName: string; | ||
@Field(() => [ProductPriceSaveArgs]) | ||
productPrices: Array<ProductPrice>; | ||
@Field() | ||
validFrom: Date; | ||
@Field() | ||
validTo: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.