-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
154 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import type { Entity } from '.' | ||
import type { Attribute, AttributePatch } from './Attribute' | ||
import type { EntityRef } from './EntityRef' | ||
import type { Owned, OwnedPatch } from './Owned' | ||
import type { Rate } from './Rate' | ||
|
||
type ContractTypeFileds = | ||
| { | ||
/** | ||
* Тип Договора. | ||
* | ||
* Возможные значения: | ||
* - Договор комиссии | ||
* - Договор купли-продажи | ||
*/ | ||
contractType: 'Sales' | ||
} | ||
| { | ||
contractType: 'Commission' | ||
|
||
/** | ||
* Тип Вознаграждения. | ||
* | ||
* Указывается когда `contractType` = `Commission` | ||
* | ||
* Возможные значения: | ||
* - Процент от суммы продажи | ||
* - Не рассчитывать | ||
* */ | ||
rewardType: 'None' | ||
} | ||
| { | ||
contractType: 'Commission' | ||
|
||
/** | ||
* Тип Вознаграждения. | ||
* | ||
* Указывается когда `contractType` = `Commission` | ||
* | ||
* Возможные значения: | ||
* - Процент от суммы продажи | ||
* - Не рассчитывать | ||
* */ | ||
rewardType: 'PercentOfSales' | ||
|
||
/** Вознаграждение в процентах (от 0 до 100) */ | ||
rewardPercent: number | ||
} | ||
|
||
type ContractFields = ContractTypeFileds & { | ||
readonly updated: string | ||
|
||
name: string | ||
|
||
description?: string | ||
|
||
code?: string | ||
|
||
externalCode?: string | ||
|
||
archived: boolean | ||
|
||
moment: string | ||
|
||
/** Сумма Договора */ | ||
sum: number | ||
|
||
ownAgent: EntityRef<'organization'> | ||
|
||
agent: EntityRef<'counterparty' | 'organization'> | ||
|
||
state?: EntityRef<'state'> | ||
|
||
organizationAccount: EntityRef<'account'> | ||
|
||
agentAccount?: EntityRef<'account'> | ||
|
||
rate: Rate | ||
|
||
attributes: Attribute[] | ||
} | ||
|
||
export type Contract = Entity<'contract'> & Owned & ContractFields | ||
|
||
export type ContractPatch = Partial< | ||
Pick< | ||
ContractFields, | ||
| 'name' | ||
| 'description' | ||
| 'code' | ||
| 'externalCode' | ||
| 'archived' | ||
| 'ownAgent' | ||
| 'agent' | ||
| 'state' | ||
| 'organizationAccount' | ||
| 'agentAccount' | ||
| 'rate' | ||
> & | ||
ContractTypeFileds | ||
> & { | ||
attributes?: AttributePatch[] | ||
} & OwnedPatch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { Contract, Patch } from '../../src' | ||
|
||
const t10 = {} as Contract | ||
|
||
// @ts-expect-error | ||
t10.contractType.rewardType | ||
|
||
if (t10.contractType === 'Commission') { | ||
t10.rewardType = 'PercentOfSales' | ||
|
||
// @ts-expect-error | ||
t10.rewardPercent | ||
|
||
if (t10.rewardType === 'PercentOfSales') { | ||
t10.rewardPercent = 50 | ||
} | ||
} | ||
|
||
const t20 = {} as Patch<'contract'> | ||
|
||
// @ts-expect-error | ||
t20.contractType.rewardType | ||
|
||
if (t20.contractType === 'Commission') { | ||
t20.rewardType = 'PercentOfSales' | ||
|
||
// @ts-expect-error | ||
t20.rewardPercent | ||
|
||
if (t20.rewardType === 'PercentOfSales') { | ||
t20.rewardPercent = 50 | ||
} | ||
} |