Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 1x 4x 4x 4x 4x 4x 4x 1x 1x 3x 4x 4x 4x 1x 4x 1x 1x 1x 1x 1x 3x 3x | import { PackagePipes } from '@/entities/pipe'
import { OperationType, SelectedAccountingObject } from '@/entities/accounting-object'
import { OPERATIONS_STATUSES } from '@/features/validator/lib'
import { Nullable } from '@/shared/@types'
import { validateAffiliation } from './validate-affiliation'
import { validateStates } from './validate-states'
import { validateStatuses } from './validate-statuses'
export const checkValidationByConditions = (
selectedObjects: SelectedAccountingObject[],
operationType: OperationType,
loadedPipes?: Nullable<PackagePipes>
): boolean => {
const operation = OPERATIONS_STATUSES[operationType]
if (!selectedObjects.length) {
return true
}
return selectedObjects.some(obj => {
const packageObjects = loadedPipes?.[obj?.packageId as string]
const isNotValidStatus = validateStatuses(operation, obj, packageObjects)
if (isNotValidStatus) return true
const isNotValidState = validateStates(operation, obj, packageObjects)
if (isNotValidState) return true
if (obj.affiliation) {
const isNotValidAffiliation = validateAffiliation(operation, obj, packageObjects)
if (isNotValidAffiliation) return true
}
return false
})
}
|