Skip to content

Commit

Permalink
feat(model)
Browse files Browse the repository at this point in the history
- add CollectionPageInfo
- add CounterpartyReport
  • Loading branch information
wmakeev committed Jul 2, 2021
1 parent df9ab8c commit 59e0f38
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 6 deletions.
7 changes: 7 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#TODO

- [ ] Расширить Expand для записи полей через запятую

```ts
Expand<CustomerOrder, 'agent.group,state'>
```
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.1.4",
"version": "0.1.5",
"description": "Объектная модель API МойСклад для TypeScript проектов",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
13 changes: 8 additions & 5 deletions src/model/CollectionRef.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { EntityRef } from './EntityRef'
import type { MetaType } from './MetaType'

export type CollectionPageInfo = {
size: number
limit: number
offset: number
hextHref?: string
}

export interface CollectionRef<T extends MetaType = MetaType>
extends EntityRef<T> {
meta: EntityRef<T>['meta'] & {
size: number
limit: number
offset: number
}
meta: EntityRef<T>['meta'] & CollectionPageInfo
}
4 changes: 4 additions & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Добавить новые сущности аналогично в MetaType.ts

// Model
export * from './Account'
export * from './Address'
export * from './Agent'
Expand Down Expand Up @@ -44,3 +45,6 @@ export * from './PriceType'
export * from './RetailDemand'
export * from './State'
export * from './TaxSystem'

// Reports
export * from './reports'
33 changes: 33 additions & 0 deletions src/model/reports/counterparty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { MetaType } from '..'
import type { CollectionRef } from '../CollectionRef'
import type { EntityRef } from '../EntityRef'

export interface CounterpartyReportItem
extends EntityRef<MetaType.Counterparty> {
counterparty: EntityRef<MetaType.Counterparty>
firstDemandDate: string | null
lastDemandDate: string | null
demandsCount: number
demandsSum: number
averageReceipt: number
returnsCount: number
returnsSum: number
discountsSum: number
balance: number
profit: number
lastEventDate: string | null
lastEventText: string | null
updated: string
}

/**
* `/report/counterparty`
*/
export interface CounterpartyReport
extends CollectionRef<MetaType.Counterparty> {
context: {
employee: EntityRef<MetaType.Employee>
}

rows: CounterpartyReportItem[]
}
1 change: 1 addition & 0 deletions src/model/reports/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './counterparty'

0 comments on commit 59e0f38

Please sign in to comment.