Skip to content

Commit

Permalink
fix: applications.issueVerifications - was issuing to employee for as…
Browse files Browse the repository at this point in the history
…signrm on approval
  • Loading branch information
mvayngrib committed May 26, 2018
1 parent e2b3de4 commit b643a74
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/in-house-bot/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
IPBApp,
ITradleObject,
IPBUser,
Models
Models,
ApplicationSubmission
} from './types'

import { Resource } from '../resource'
Expand All @@ -37,6 +38,10 @@ interface IPropertyInfo {

const APPLICATION_SUBMISSION = 'tradle.ApplicationSubmission'
const APPLICATION = 'tradle.Application'
const PRUNABLE_FORMS = [
'tradle.AssignRelationshipManager',
'tradle.ProductRequest'
]

export class Applications {
private bot: Bot
Expand Down Expand Up @@ -114,7 +119,12 @@ export class Applications {
application: IPBApp
send?: boolean
}) => {
return await this.productsAPI.issueVerifications({ req, user, application, send })
return await this.productsAPI.issueVerifications({
req,
user,
application: getApplicationWithCustomerSubmittedForms(application),
send
})
}

public requestEdit = async (opts) => {
Expand All @@ -128,7 +138,9 @@ export class Applications {
public haveAllFormsBeenVerified = async ({ application }: {
application: IPBApp
}) => {
return await this.productsAPI.haveAllSubmittedFormsBeenVerified({ application })
return await this.productsAPI.haveAllSubmittedFormsBeenVerified({
application: getApplicationWithCustomerSubmittedForms(application)
})
}

public getLatestChecks = async ({ application }: {
Expand Down Expand Up @@ -255,6 +267,8 @@ export class Applications {
await this.bot.users.save(user)
}

public getCustomerSubmittedForms = getCustomerSubmittedForms

// public requestEdit = async (opts: {
// req?: IPBReq
// user?: IPBUser
Expand Down Expand Up @@ -287,3 +301,16 @@ export class Applications {

// }
}

const getCustomerSubmittedForms = ({ forms }: {
forms: ApplicationSubmission[]
}) => {
return forms.filter(f => !PRUNABLE_FORMS.includes(f.submission[TYPE]))
}

const getApplicationWithCustomerSubmittedForms = (application: IPBApp):IPBApp => ({
...application,
forms: getCustomerSubmittedForms({
forms: application.forms || []
})
})

0 comments on commit b643a74

Please sign in to comment.