|
|
@ -8,6 +8,7 @@ import {
|
|
|
|
createOfferProfileResponseMapper,
|
|
|
|
createOfferProfileResponseMapper,
|
|
|
|
profileDtoMapper,
|
|
|
|
profileDtoMapper,
|
|
|
|
} from '~/mappers/offers-mappers';
|
|
|
|
} from '~/mappers/offers-mappers';
|
|
|
|
|
|
|
|
import { analysisInclusion } from '~/utils/offers/analysis/analysisInclusion';
|
|
|
|
import { baseCurrencyString } from '~/utils/offers/currency';
|
|
|
|
import { baseCurrencyString } from '~/utils/offers/currency';
|
|
|
|
import { convert } from '~/utils/offers/currency/currencyExchange';
|
|
|
|
import { convert } from '~/utils/offers/currency/currencyExchange';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
@ -165,139 +166,7 @@ export const offersProfileRouter = createRouter()
|
|
|
|
const result = await ctx.prisma.offersProfile.findFirst({
|
|
|
|
const result = await ctx.prisma.offersProfile.findFirst({
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
analysis: {
|
|
|
|
analysis: {
|
|
|
|
include: {
|
|
|
|
include: analysisInclusion,
|
|
|
|
companyAnalysis: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
company: true,
|
|
|
|
|
|
|
|
topSimilarOffers: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
company: true,
|
|
|
|
|
|
|
|
location: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
state: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
country: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
offersFullTime: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
totalCompensation: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
offersIntern: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
monthlySalary: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
profile: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
background: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
experiences: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
company: true,
|
|
|
|
|
|
|
|
location: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
state: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
country: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
overallAnalysis: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
company: true,
|
|
|
|
|
|
|
|
topSimilarOffers: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
company: true,
|
|
|
|
|
|
|
|
location: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
state: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
country: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
offersFullTime: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
totalCompensation: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
offersIntern: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
monthlySalary: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
profile: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
background: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
experiences: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
company: true,
|
|
|
|
|
|
|
|
location: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
state: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
country: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
overallHighestOffer: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
company: true,
|
|
|
|
|
|
|
|
location: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
state: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
country: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
offersFullTime: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
totalCompensation: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
offersIntern: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
monthlySalary: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
profile: {
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
background: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
background: {
|
|
|
|
background: {
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
@ -972,7 +841,19 @@ export const offersProfileRouter = createRouter()
|
|
|
|
|
|
|
|
|
|
|
|
for (const exp of input.background.experiences) {
|
|
|
|
for (const exp of input.background.experiences) {
|
|
|
|
if (exp.id) {
|
|
|
|
if (exp.id) {
|
|
|
|
// Update existing experience
|
|
|
|
const currentExp = await ctx.prisma.offersExperience.findFirst({
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: exp.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!currentExp) {
|
|
|
|
|
|
|
|
throw new trpc.TRPCError({
|
|
|
|
|
|
|
|
code: 'NOT_FOUND',
|
|
|
|
|
|
|
|
message: 'Experience does not exist',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
companyId: exp.companyId, // TODO: check if can change with connect or whether there is a difference
|
|
|
|
companyId: exp.companyId, // TODO: check if can change with connect or whether there is a difference
|
|
|
@ -984,7 +865,77 @@ export const offersProfileRouter = createRouter()
|
|
|
|
id: exp.id,
|
|
|
|
id: exp.id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (currentExp.jobType === exp.jobType) {
|
|
|
|
|
|
|
|
// Update existing experience
|
|
|
|
|
|
|
|
if (exp.monthlySalary) {
|
|
|
|
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
monthlySalary: {
|
|
|
|
|
|
|
|
upsert: {
|
|
|
|
|
|
|
|
create: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
exp.monthlySalary.value,
|
|
|
|
|
|
|
|
exp.monthlySalary.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency: exp.monthlySalary.currency,
|
|
|
|
|
|
|
|
value: exp.monthlySalary.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
update: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
exp.monthlySalary.value,
|
|
|
|
|
|
|
|
exp.monthlySalary.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency: exp.monthlySalary.currency,
|
|
|
|
|
|
|
|
value: exp.monthlySalary.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: exp.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exp.totalCompensation) {
|
|
|
|
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
totalCompensation: {
|
|
|
|
|
|
|
|
upsert: {
|
|
|
|
|
|
|
|
create: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
exp.totalCompensation.value,
|
|
|
|
|
|
|
|
exp.totalCompensation.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency: exp.totalCompensation.currency,
|
|
|
|
|
|
|
|
value: exp.totalCompensation.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
update: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
exp.totalCompensation.value,
|
|
|
|
|
|
|
|
exp.totalCompensation.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency: exp.totalCompensation.currency,
|
|
|
|
|
|
|
|
value: exp.totalCompensation.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: exp.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (exp.jobType === JobType.INTERN) {
|
|
|
|
|
|
|
|
// Add 1 remove the other
|
|
|
|
if (exp.monthlySalary) {
|
|
|
|
if (exp.monthlySalary) {
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
@ -1019,6 +970,16 @@ export const offersProfileRouter = createRouter()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
totalCompensation: undefined,
|
|
|
|
|
|
|
|
totalCompensationId: null,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: exp.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (exp.jobType === JobType.FULLTIME) {
|
|
|
|
if (exp.totalCompensation) {
|
|
|
|
if (exp.totalCompensation) {
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
@ -1052,6 +1013,17 @@ export const offersProfileRouter = createRouter()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.prisma.offersExperience.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
monthlySalary: undefined,
|
|
|
|
|
|
|
|
monthlySalaryId: null,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: exp.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (!exp.id) {
|
|
|
|
} else if (!exp.id) {
|
|
|
|
// Create new experience
|
|
|
|
// Create new experience
|
|
|
|
if (exp.jobType === JobType.FULLTIME) {
|
|
|
|
if (exp.jobType === JobType.FULLTIME) {
|
|
|
@ -1581,6 +1553,18 @@ export const offersProfileRouter = createRouter()
|
|
|
|
for (const offerToUpdate of input.offers) {
|
|
|
|
for (const offerToUpdate of input.offers) {
|
|
|
|
if (offerToUpdate.id) {
|
|
|
|
if (offerToUpdate.id) {
|
|
|
|
// Update existing offer
|
|
|
|
// Update existing offer
|
|
|
|
|
|
|
|
const currentOffer = await ctx.prisma.offersOffer.findFirst({
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!currentOffer) {
|
|
|
|
|
|
|
|
throw new trpc.TRPCError({
|
|
|
|
|
|
|
|
code: 'NOT_FOUND',
|
|
|
|
|
|
|
|
message: 'Offer to update does not exist',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
await ctx.prisma.offersOffer.update({
|
|
|
|
await ctx.prisma.offersOffer.update({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
comments: offerToUpdate.comments,
|
|
|
|
comments: offerToUpdate.comments,
|
|
|
@ -1606,6 +1590,7 @@ export const offersProfileRouter = createRouter()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentOffer.jobType === offerToUpdate.jobType) {
|
|
|
|
if (offerToUpdate.offersIntern?.monthlySalary != null) {
|
|
|
|
if (offerToUpdate.offersIntern?.monthlySalary != null) {
|
|
|
|
await ctx.prisma.offersIntern.update({
|
|
|
|
await ctx.prisma.offersIntern.update({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
@ -1637,7 +1622,8 @@ export const offersProfileRouter = createRouter()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
startYear: offerToUpdate.offersIntern.startYear ?? undefined,
|
|
|
|
startYear:
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.startYear ?? undefined,
|
|
|
|
title: offerToUpdate.offersIntern.title,
|
|
|
|
title: offerToUpdate.offersIntern.title,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
@ -1670,7 +1656,170 @@ export const offersProfileRouter = createRouter()
|
|
|
|
),
|
|
|
|
),
|
|
|
|
currency:
|
|
|
|
currency:
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.currency,
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.currency,
|
|
|
|
value: offerToUpdate.offersFullTime.baseSalary.value,
|
|
|
|
value:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
update: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.currency,
|
|
|
|
|
|
|
|
value:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.offersFullTime.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offerToUpdate.offersFullTime.bonus != null) {
|
|
|
|
|
|
|
|
await ctx.prisma.offersFullTime.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
bonus: {
|
|
|
|
|
|
|
|
upsert: {
|
|
|
|
|
|
|
|
create: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.bonus.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
|
|
|
|
value: offerToUpdate.offersFullTime.bonus.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
update: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.bonus.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
|
|
|
|
value: offerToUpdate.offersFullTime.bonus.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.offersFullTime.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offerToUpdate.offersFullTime.stocks != null) {
|
|
|
|
|
|
|
|
await ctx.prisma.offersFullTime.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
stocks: {
|
|
|
|
|
|
|
|
upsert: {
|
|
|
|
|
|
|
|
create: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.stocks.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.stocks.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.stocks.currency,
|
|
|
|
|
|
|
|
value: offerToUpdate.offersFullTime.stocks.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
update: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.stocks.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.stocks.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.stocks.currency,
|
|
|
|
|
|
|
|
value: offerToUpdate.offersFullTime.stocks.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.offersFullTime.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await ctx.prisma.offersFullTime.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
totalCompensation: {
|
|
|
|
|
|
|
|
upsert: {
|
|
|
|
|
|
|
|
create: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.currency,
|
|
|
|
|
|
|
|
value:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
update: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.currency,
|
|
|
|
|
|
|
|
value:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.offersFullTime.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (currentOffer.jobType === JobType.FULLTIME) {
|
|
|
|
|
|
|
|
if (offerToUpdate.offersFullTime?.totalCompensation != null) {
|
|
|
|
|
|
|
|
await ctx.prisma.offersFullTime.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
level: offerToUpdate.offersFullTime.level ?? undefined,
|
|
|
|
|
|
|
|
title: offerToUpdate.offersFullTime.title,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.offersFullTime.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (offerToUpdate.offersFullTime.baseSalary != null) {
|
|
|
|
|
|
|
|
await ctx.prisma.offersFullTime.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
baseSalary: {
|
|
|
|
|
|
|
|
upsert: {
|
|
|
|
|
|
|
|
create: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.currency,
|
|
|
|
|
|
|
|
value:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
update: {
|
|
|
|
update: {
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
@ -1681,7 +1830,8 @@ export const offersProfileRouter = createRouter()
|
|
|
|
),
|
|
|
|
),
|
|
|
|
currency:
|
|
|
|
currency:
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.currency,
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.currency,
|
|
|
|
value: offerToUpdate.offersFullTime.baseSalary.value,
|
|
|
|
value:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.baseSalary.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -1703,7 +1853,8 @@ export const offersProfileRouter = createRouter()
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
baseCurrencyString,
|
|
|
|
baseCurrencyString,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
currency: offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
value: offerToUpdate.offersFullTime.bonus.value,
|
|
|
|
value: offerToUpdate.offersFullTime.bonus.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
update: {
|
|
|
|
update: {
|
|
|
@ -1713,7 +1864,8 @@ export const offersProfileRouter = createRouter()
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
baseCurrencyString,
|
|
|
|
baseCurrencyString,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
currency: offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersFullTime.bonus.currency,
|
|
|
|
value: offerToUpdate.offersFullTime.bonus.value,
|
|
|
|
value: offerToUpdate.offersFullTime.bonus.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -1766,7 +1918,8 @@ export const offersProfileRouter = createRouter()
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
baseValue: await convert(
|
|
|
|
baseValue: await convert(
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation.value,
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.value,
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
.currency,
|
|
|
|
.currency,
|
|
|
|
baseCurrencyString,
|
|
|
|
baseCurrencyString,
|
|
|
@ -1775,12 +1928,14 @@ export const offersProfileRouter = createRouter()
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
.currency,
|
|
|
|
.currency,
|
|
|
|
value:
|
|
|
|
value:
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation.value,
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
update: {
|
|
|
|
update: {
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
baseValue: await convert(
|
|
|
|
baseValue: await convert(
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation.value,
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.value,
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
.currency,
|
|
|
|
.currency,
|
|
|
|
baseCurrencyString,
|
|
|
|
baseCurrencyString,
|
|
|
@ -1789,7 +1944,8 @@ export const offersProfileRouter = createRouter()
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
.currency,
|
|
|
|
.currency,
|
|
|
|
value:
|
|
|
|
value:
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation.value,
|
|
|
|
offerToUpdate.offersFullTime.totalCompensation
|
|
|
|
|
|
|
|
.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -1799,6 +1955,68 @@ export const offersProfileRouter = createRouter()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.prisma.offersOffer.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
offersIntern: undefined,
|
|
|
|
|
|
|
|
offersInternId: null,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (currentOffer.jobType === JobType.INTERN) {
|
|
|
|
|
|
|
|
if (offerToUpdate.offersIntern?.monthlySalary != null) {
|
|
|
|
|
|
|
|
await ctx.prisma.offersIntern.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
internshipCycle:
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.internshipCycle ?? undefined,
|
|
|
|
|
|
|
|
monthlySalary: {
|
|
|
|
|
|
|
|
upsert: {
|
|
|
|
|
|
|
|
create: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.monthlySalary.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.monthlySalary.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.monthlySalary.currency,
|
|
|
|
|
|
|
|
value: offerToUpdate.offersIntern.monthlySalary.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
update: {
|
|
|
|
|
|
|
|
baseCurrency: baseCurrencyString,
|
|
|
|
|
|
|
|
baseValue: await convert(
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.monthlySalary.value,
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.monthlySalary.currency,
|
|
|
|
|
|
|
|
baseCurrencyString,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
currency:
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.monthlySalary.currency,
|
|
|
|
|
|
|
|
value: offerToUpdate.offersIntern.monthlySalary.value,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
startYear:
|
|
|
|
|
|
|
|
offerToUpdate.offersIntern.startYear ?? undefined,
|
|
|
|
|
|
|
|
title: offerToUpdate.offersIntern.title,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.offersIntern.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await ctx.prisma.offersOffer.update({
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
offersFullTime: undefined,
|
|
|
|
|
|
|
|
offersFullTimeId: null,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: offerToUpdate.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Create new offer
|
|
|
|
// Create new offer
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|