Skip to content

Commit

Permalink
feat(model)
Browse files Browse the repository at this point in the history
- add CompanySettings
- add Currency
  • Loading branch information
wmakeev committed Aug 24, 2022
1 parent ca7ac21 commit dfc39c0
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 6 deletions.
17 changes: 17 additions & 0 deletions src/model/CompanySettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Currency } from './Currency'
import type { Entity } from './Entity'
import type { PriceType } from './PriceType'

export type CompanySettingsDiscountStrategy = 'bySum' | 'byPriority'

export interface CompanySettings extends Entity<'companysettings'> {
currency: Currency & { archived: false; default: true }
priceTypes: PriceType[]
discountStrategy: CompanySettingsDiscountStrategy
globalOperationNumbering: boolean
checkShippingStock: boolean
checkMinPrice: boolean
useRecycleBin: boolean
useCompanyAddress: boolean
companyAddress: string
}
44 changes: 44 additions & 0 deletions src/model/Currency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { OptionalNullablePartial } from '../tools'
import type { Entity } from './Entity'

export type CurrencyRateUpdateType = 'manual' | 'auto'

export type CurrencyUnitGender = 'masculine' | 'feminine'

export type CurrencyFields = {
readonly system: boolean
name: string
fullName: string
rate: number
multiplicity: number
indirect: boolean
readonly rateUpdateType: CurrencyRateUpdateType
code: string
isoCode: string
majorUnit: {
gender: CurrencyUnitGender
s1: string
s2: string
s5: string
}
minorUnit: {
gender: CurrencyUnitGender
s1: string
s2: string
s5: string
}
archived: boolean
readonly default: boolean
}

export type Currency = Entity<'currency'> & CurrencyFields

// https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-valuta-izmenit-valutu

/**
* - Нельзя указать курс валюты `rate` равным нулю, а также пустые поля `name`, `code`, `isoCode`.
* - Нельзя изменять значения полей `name`, `fullName`, `code`, `isoCode`, `majorUnit`, `minorUnit` для валют, основанных на системном справочнике валют.
* - Нельзя изменять курс валюты учета.
* - Нельзя изменить курс валюты с автоматическим обновлением.
*/
export type CurrencyPatch = OptionalNullablePartial<CurrencyFields>
1 change: 0 additions & 1 deletion src/model/Employee.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Agent } from './Agent'
import type { MetaType } from './MetaType'

export interface Employee extends Agent<'employee'> {
/** Логин Сотрудника */
Expand Down
6 changes: 4 additions & 2 deletions src/model/MetaType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import type {
Attribute,
CashIn,
CashOut,
CompanySettings,
ContactPerson,
Contract,
Counterparty,
Currency,
CustomEntity,
CustomerOrder,
CustomerOrderPosition,
Expand Down Expand Up @@ -143,13 +145,13 @@ export type EntityByMetaType = {
commissionreportinposition: Position<'commissionreportinposition'>
commissionreportout: DocumentWithPositions<'commissionreportout'>
commissionreportoutposition: Position<'commissionreportoutposition'>
companysettings: Entity<'companysettings'>
companysettings: CompanySettings
consignment: Entity<'consignment'>
contactperson: ContactPerson
contract: Contract
counterparty: Counterparty
country: Entity<'country'>
currency: Entity<'currency'>
currency: Currency
customentity: CustomEntity
customentitymetadata: Entity<'customentitymetadata'>
customerorder: CustomerOrder
Expand Down
2 changes: 2 additions & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ export * from './CashOut'
export * from './Collection'
export * from './CollectionRef'
export * from './Company'
export * from './CompanySettings'
export * from './ContactPerson'
export * from './Contract'
export * from './Counterparty'
export * from './Currency'
export * from './CustomEntity'
export * from './CustomerOrder'
export * from './CustomerOrderPosition'
Expand Down
8 changes: 5 additions & 3 deletions src/model/utils/Patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
CashInPatch,
CashOutPatch,
ContractPatch,
CurrencyPatch,
CustomEntityPatch,
CustomerOrderPatch,
CustomerOrderPositionPatch,
Expand All @@ -27,19 +28,20 @@ export type PatchByMetaType = {
cashin: CashInPatch
cashout: CashOutPatch
contract: ContractPatch
currency: CurrencyPatch
customentity: CustomEntityPatch
customerorder: CustomerOrderPatch
customerorderposition: CustomerOrderPositionPatch
demand: DemandPatch
demandposition: DemandPosition
inventory: InventoryPatch
inventoryposition: InventoryPositionPatch
invoicein: InvoiceInPatch
invoiceout: InvoiceOutPatch
invoiceposition: InvoicePositionPatch
inventory: InventoryPatch
inventoryposition: InventoryPositionPatch
product: ProductPatch
productfolder: ProductFolderPatch
retaildemand: RetailDemand
customentity: CustomEntityPatch
salesreturn: SalesReturnPatch
salesreturnposition: SalesReturnPositionPatch
}
Expand Down

0 comments on commit dfc39c0

Please sign in to comment.