Skip to content

Commit

Permalink
feat(model): add SalesReturn and SalesReturnPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
wmakeev committed Aug 15, 2021
1 parent 39671fc commit 900b540
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 5 deletions.
21 changes: 21 additions & 0 deletions src/model/AbstractReturn.ts
Original file line number Diff line number Diff line change
@@ -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<T extends ReturnMetaType> =
DocumentWithPositions<T> & HasVat

export type AbstractReturnPatch<T extends ReturnMetaType> =
DocumentWithPositionsPatch<T> &
PartialNullable<Pick<AbstractReturnFields, 'demand'>> &
Partial<HasVat>
11 changes: 7 additions & 4 deletions src/model/MetaType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import type {
ProductFolder,
RetailDemand,
SelectKeysByType,
State
State,
SalesReturn,
RetailSalesReturn,
SalesReturnPosition
} from '.'

export type MetaType =
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/model/Position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type DocumentPositionType = {
purchasereturn: 'purchasereturnposition'
retaildemand: 'demandposition'
salesreturn: 'salesreturnposition'
retailsalesreturn: 'salesreturnposition'
supply: 'supplyposition'
}

Expand Down
26 changes: 26 additions & 0 deletions src/model/RetailSalesReturn.ts
Original file line number Diff line number Diff line change
@@ -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<RetailSalesReturnFields, 'retailStore' | 'retailShift' | 'taxSystem'>
>
10 changes: 10 additions & 0 deletions src/model/SalesReturn.ts
Original file line number Diff line number Diff line change
@@ -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<Pick<SalesReturnFields, 'demand'>>
28 changes: 28 additions & 0 deletions src/model/SalesReturnPosition.ts
Original file line number Diff line number Diff line change
@@ -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<SalesReturnPositionFields, 'vat' | 'vatEnabled' | 'gtd' | 'country'>
>
4 changes: 4 additions & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/model/utils/Patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import type {
MetaType,
ProductFolderPatch,
ProductPatch,
RetailDemand
RetailDemand,
SalesReturnPatch,
SalesReturnPositionPatch
} from '..'

export type PatchByMetaType = {
Expand All @@ -34,6 +36,8 @@ export type PatchByMetaType = {
productfolder: ProductFolderPatch
retaildemand: RetailDemand
customentity: CustomEntityPatch
salesreturn: SalesReturnPatch
salesreturnposition: SalesReturnPositionPatch
}

export type Patch<T extends MetaType> = T extends keyof PatchByMetaType
Expand Down

0 comments on commit 900b540

Please sign in to comment.