Skip to content

Commit

Permalink
feat(PatchByMetaType)
Browse files Browse the repository at this point in the history
- InvoiceInPatch
- InvoiceOutPatch
- CashInPatch
- CashOutPatch
  • Loading branch information
wmakeev committed Jul 17, 2021
1 parent f934867 commit 4e11ff3
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 5 deletions.
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
```

- [ ] Нужен еще один слой Create как и для Patch?

- [ ] Нужно ли типизировать template литералами href в meta?
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.2.0",
"version": "0.2.1",
"description": "Объектная модель API МойСклад для TypeScript проектов",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion src/model/Counterparty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { CollectionRef } from './CollectionRef'
import type { Company, CompanyType } from './Company'
import type { EntityRef } from './EntityRef'
import type { Legal } from './Legal'
import type { MetaType } from './MetaType'
import type { Person } from './Person'
import type { PriceType } from './PriceType'

Expand Down
10 changes: 10 additions & 0 deletions src/model/HasVat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ export type HasVat =
vatIncluded: boolean
vatSum: number
}

export type HasVatPatch =
| {
vatEnabled?: false
}
| {
vatEnabled: true
vatIncluded?: boolean
vatSum?: number
}
10 changes: 9 additions & 1 deletion src/model/InvoiceIn.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import type { DocumentWithPositions, HasVat, MetaType } from '.'
import type {
DocumentWithPositions,
DocumentWithPositionsPatch,
HasVat,
HasVatPatch
} from '.'

export type InvoiceIn = DocumentWithPositions<'invoicein'> & HasVat

export type InvoiceInPatch = DocumentWithPositionsPatch<'invoicein'> &
HasVatPatch
10 changes: 9 additions & 1 deletion src/model/InvoiceOut.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import type { DocumentWithPositions, HasVat, MetaType } from '.'
import type {
DocumentWithPositions,
DocumentWithPositionsPatch,
HasVat,
HasVatPatch
} from '.'

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

export type InvoiceOutPatch = DocumentWithPositionsPatch<'invoiceout'> &
HasVatPatch
10 changes: 9 additions & 1 deletion src/model/utils/Patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ import type {
CustomerOrderPatch,
EntityPatchRef,
MetaType,
CustomerOrderPositionPatch
CustomerOrderPositionPatch,
InvoiceInPatch,
InvoiceOutPatch
} from '..'
import type { CashInPatch } from '../CashIn'
import type { CashOutPatch } from '../CashOut'

export type PatchByMetaType = {
customerorder: CustomerOrderPatch
customerorderposition: CustomerOrderPositionPatch
attributemetadata: AttributePatch
invoicein: InvoiceInPatch
invoiceout: InvoiceOutPatch
cashin: CashInPatch
cashout: CashOutPatch
}

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

0 comments on commit 4e11ff3

Please sign in to comment.