From dfc39c07e73a44f737e89a060b8889ea89fd78c5 Mon Sep 17 00:00:00 2001 From: "Vitaliy V. Makeev" Date: Wed, 24 Aug 2022 16:36:29 +0500 Subject: [PATCH] feat(model) - add CompanySettings - add Currency --- src/model/CompanySettings.ts | 17 ++++++++++++++ src/model/Currency.ts | 44 ++++++++++++++++++++++++++++++++++++ src/model/Employee.ts | 1 - src/model/MetaType.ts | 6 +++-- src/model/index.ts | 2 ++ src/model/utils/Patch.ts | 8 ++++--- 6 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/model/CompanySettings.ts create mode 100644 src/model/Currency.ts diff --git a/src/model/CompanySettings.ts b/src/model/CompanySettings.ts new file mode 100644 index 0000000..0fdbfaa --- /dev/null +++ b/src/model/CompanySettings.ts @@ -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 +} diff --git a/src/model/Currency.ts b/src/model/Currency.ts new file mode 100644 index 0000000..21614c7 --- /dev/null +++ b/src/model/Currency.ts @@ -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 diff --git a/src/model/Employee.ts b/src/model/Employee.ts index 800f120..b12b9a1 100644 --- a/src/model/Employee.ts +++ b/src/model/Employee.ts @@ -1,5 +1,4 @@ import type { Agent } from './Agent' -import type { MetaType } from './MetaType' export interface Employee extends Agent<'employee'> { /** Логин Сотрудника */ diff --git a/src/model/MetaType.ts b/src/model/MetaType.ts index b11ad3b..de87f5b 100644 --- a/src/model/MetaType.ts +++ b/src/model/MetaType.ts @@ -4,9 +4,11 @@ import type { Attribute, CashIn, CashOut, + CompanySettings, ContactPerson, Contract, Counterparty, + Currency, CustomEntity, CustomerOrder, CustomerOrderPosition, @@ -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 diff --git a/src/model/index.ts b/src/model/index.ts index c27bec2..76115a3 100644 --- a/src/model/index.ts +++ b/src/model/index.ts @@ -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' diff --git a/src/model/utils/Patch.ts b/src/model/utils/Patch.ts index d6f35c0..51b7d75 100644 --- a/src/model/utils/Patch.ts +++ b/src/model/utils/Patch.ts @@ -3,6 +3,7 @@ import type { CashInPatch, CashOutPatch, ContractPatch, + CurrencyPatch, CustomEntityPatch, CustomerOrderPatch, CustomerOrderPositionPatch, @@ -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 }