Skip to content

Commit

Permalink
feat(Invoice): add Invoice base type
Browse files Browse the repository at this point in the history
- add paymentPlannedMoment
- add todo notes
  • Loading branch information
wmakeev committed Jul 23, 2021
1 parent 7f86686 commit 9da5f3f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moysklad-api-model",
"version": "0.3.1",
"version": "0.3.2",
"description": "Объектная модель API МойСклад для TypeScript проектов",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
25 changes: 25 additions & 0 deletions src/model/Invoice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type {
DocumentWithPositions,
DocumentWithPositionsPatch,
HasVat,
HasVatPatch
} from '.'

export type InvoiceMetaType = 'invoicein' | 'invoiceout'

export type InvoiceFields = {
paymentPlannedMoment?: string

readonly payedSum: number

readonly shippedSum: number
}

export type Invoice<T extends InvoiceMetaType> = DocumentWithPositions<T> &
HasVat

export type InvoicePatch<
T extends InvoiceMetaType
> = DocumentWithPositionsPatch<T> &
Partial<Pick<InvoiceFields, 'paymentPlannedMoment'>> &
HasVatPatch
22 changes: 13 additions & 9 deletions src/model/InvoiceIn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import type {
DocumentWithPositions,
DocumentWithPositionsPatch,
HasVat,
HasVatPatch
} from '.'
import type { EntityRef, Invoice, InvoicePatch } from '.'

export type InvoiceIn = DocumentWithPositions<'invoicein'> & HasVat
export type InvoiceInFields = {
purchaseOrder?: EntityRef<'purchaseorder'>

export type InvoiceInPatch = DocumentWithPositionsPatch<'invoicein'> &
HasVatPatch
// TODO incomingDate: DateTime
// TODO financesOut: IDREF
// TODO incomingNumber: String
// TODO supplies: IDREF
}

export type InvoiceIn = Invoice<'invoicein'>

export type InvoiceInPatch = InvoicePatch<'invoicein'> &
Partial<Pick<InvoiceInFields, 'purchaseOrder'>>
20 changes: 6 additions & 14 deletions src/model/InvoiceOut.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import type {
DocumentWithPositions,
DocumentWithPositionsPatch,
HasVat,
HasVatPatch
} from '.'
import type { EntityRef } from './EntityRef'
import type { EntityRef, Invoice, InvoicePatch } from '.'

export type InvoiceOutFields = {
customerOrder?: EntityRef<'customerorder'>
readonly payedSum: number
readonly shippedSum: number

// TODO demands
// TODO payments
}

export type InvoiceOut = DocumentWithPositions<'invoiceout'> &
HasVat &
InvoiceOutFields
export type InvoiceOut = Invoice<'invoiceout'> & InvoiceOutFields

export type InvoiceOutPatch = DocumentWithPositionsPatch<'invoiceout'> &
HasVatPatch &
export type InvoiceOutPatch = InvoicePatch<'invoiceout'> &
Partial<Pick<InvoiceOutFields, 'customerOrder'>>
1 change: 1 addition & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export * from './HasState'
export * from './HasStore'
export * from './HasUpdated'
export * from './HasVat'
export * from './Invoice'
export * from './InvoiceIn'
export * from './InvoiceOut'
export * from './InvoicePosition'
Expand Down

0 comments on commit 9da5f3f

Please sign in to comment.