From 900b540be542cc834b3e0195fafe0b3cf5dd81c5 Mon Sep 17 00:00:00 2001 From: Vitaliy Makeev Date: Sun, 15 Aug 2021 22:13:08 +0500 Subject: [PATCH] feat(model): add SalesReturn and SalesReturnPosition --- src/model/AbstractReturn.ts | 21 +++++++++++++++++++++ src/model/MetaType.ts | 11 +++++++---- src/model/Position.ts | 1 + src/model/RetailSalesReturn.ts | 26 ++++++++++++++++++++++++++ src/model/SalesReturn.ts | 10 ++++++++++ src/model/SalesReturnPosition.ts | 28 ++++++++++++++++++++++++++++ src/model/index.ts | 4 ++++ src/model/utils/Patch.ts | 6 +++++- 8 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 src/model/AbstractReturn.ts create mode 100644 src/model/RetailSalesReturn.ts create mode 100644 src/model/SalesReturn.ts create mode 100644 src/model/SalesReturnPosition.ts diff --git a/src/model/AbstractReturn.ts b/src/model/AbstractReturn.ts new file mode 100644 index 0000000..442cbac --- /dev/null +++ b/src/model/AbstractReturn.ts @@ -0,0 +1,21 @@ +import type { + DocumentWithPositions, + DocumentWithPositionsPatch, + EntityRef, + HasVat +} from '.' +import type { PartialNullable } from '../tools' + +export type ReturnMetaType = 'salesreturn' | 'retailsalesreturn' + +export type AbstractReturnFields = { + demand: EntityRef<'demand'> +} + +export type AbstractReturn = + DocumentWithPositions & HasVat + +export type AbstractReturnPatch = + DocumentWithPositionsPatch & + PartialNullable> & + Partial diff --git a/src/model/MetaType.ts b/src/model/MetaType.ts index 3446731..576e9fd 100644 --- a/src/model/MetaType.ts +++ b/src/model/MetaType.ts @@ -30,7 +30,10 @@ import type { ProductFolder, RetailDemand, SelectKeysByType, - State + State, + SalesReturn, + RetailSalesReturn, + SalesReturnPosition } from '.' export type MetaType = @@ -202,11 +205,11 @@ export type EntityByMetaType = { retaildemand: RetailDemand retaildrawercashin: Entity<'retaildrawercashin'> retaildrawercashout: Entity<'retaildrawercashout'> - retailsalesreturn: Entity<'retailsalesreturn'> + retailsalesreturn: RetailSalesReturn retailshift: Entity<'retailshift'> retailstore: Entity<'retailstore'> - salesreturn: Entity<'salesreturn'> - salesreturnposition: Position<'salesreturnposition'> + salesreturn: SalesReturn + salesreturnposition: SalesReturnPosition service: Entity<'service'> specialpricediscount: Entity<'specialpricediscount'> state: State diff --git a/src/model/Position.ts b/src/model/Position.ts index 0cb71e9..0dca693 100644 --- a/src/model/Position.ts +++ b/src/model/Position.ts @@ -37,6 +37,7 @@ export type DocumentPositionType = { purchasereturn: 'purchasereturnposition' retaildemand: 'demandposition' salesreturn: 'salesreturnposition' + retailsalesreturn: 'salesreturnposition' supply: 'supplyposition' } diff --git a/src/model/RetailSalesReturn.ts b/src/model/RetailSalesReturn.ts new file mode 100644 index 0000000..4faae35 --- /dev/null +++ b/src/model/RetailSalesReturn.ts @@ -0,0 +1,26 @@ +import type { + AbstractReturn, + AbstractReturnPatch, + EntityRef, + TaxSystem +} from '.' +import type { PartialNullable } from '../tools' + +export type RetailSalesReturnFields = { + retailStore: EntityRef<'retailstore'> + + retailShift: EntityRef<'retailshift'> + + taxSystem: TaxSystem + + readonly cashSum: number + readonly noCashSum: number + readonly qrSum: number +} + +export type RetailSalesReturn = AbstractReturn<'retailsalesreturn'> + +export type RetailSalesReturnPatch = AbstractReturnPatch<'retailsalesreturn'> & + PartialNullable< + Pick + > diff --git a/src/model/SalesReturn.ts b/src/model/SalesReturn.ts new file mode 100644 index 0000000..439a4ac --- /dev/null +++ b/src/model/SalesReturn.ts @@ -0,0 +1,10 @@ +import type { AbstractReturn, AbstractReturnPatch, EntityRef } from '.' + +export type SalesReturnFields = { + readonly payedSum: number +} + +export type SalesReturn = AbstractReturn<'salesreturn'> + +export type SalesReturnPatch = AbstractReturnPatch<'salesreturn'> +// & PartialNullable> diff --git a/src/model/SalesReturnPosition.ts b/src/model/SalesReturnPosition.ts new file mode 100644 index 0000000..d591217 --- /dev/null +++ b/src/model/SalesReturnPosition.ts @@ -0,0 +1,28 @@ +import type { EntityRef, Position, PositionPatch } from '.' +import type { PartialNullable } from '../tools' + +export type SalesReturnPositionFields = { + /** + * НДС + */ + vat: number + + // TODO vatEnabled: разобраться с где и как отмечается в позициях + vatEnabled: boolean + + /** ГТД (только для salesreturn) */ + gtd?: { + name: string + } + + /** Страна (только для salesreturn) */ + country?: EntityRef<'country'> +} + +export type SalesReturnPosition = Position<'salesreturnposition'> & + SalesReturnPositionFields + +export type SalesReturnPositionPatch = PositionPatch<'demandposition'> & + PartialNullable< + Pick + > diff --git a/src/model/index.ts b/src/model/index.ts index 4b2faaf..4f4116d 100644 --- a/src/model/index.ts +++ b/src/model/index.ts @@ -4,6 +4,7 @@ export * from './AbstractDemand' export * from './AbstractFile' export * from './AbstractGood' +export * from './AbstractReturn' export * from './Account' export * from './Address' export * from './Agent' @@ -67,6 +68,9 @@ export * from './ProductFolder' export * from './Rate' export * from './RetailDemand' export * from './State' +export * from './SalesReturn' +export * from './RetailSalesReturn' +export * from './SalesReturnPosition' export * from './TaxSystem' // Utility types diff --git a/src/model/utils/Patch.ts b/src/model/utils/Patch.ts index 3c4370e..2749f3b 100644 --- a/src/model/utils/Patch.ts +++ b/src/model/utils/Patch.ts @@ -15,7 +15,9 @@ import type { MetaType, ProductFolderPatch, ProductPatch, - RetailDemand + RetailDemand, + SalesReturnPatch, + SalesReturnPositionPatch } from '..' export type PatchByMetaType = { @@ -34,6 +36,8 @@ export type PatchByMetaType = { productfolder: ProductFolderPatch retaildemand: RetailDemand customentity: CustomEntityPatch + salesreturn: SalesReturnPatch + salesreturnposition: SalesReturnPositionPatch } export type Patch = T extends keyof PatchByMetaType