Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/backend/src/controllers/projects.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default class ProjectsController {
subtotal,
notes,
assemblyId,
pdmFileName === '' ? undefined : pdmFileName,
pdmFileName,
unitName,
reimbursementRequestId
);
Expand Down Expand Up @@ -379,8 +379,8 @@ export default class ProjectsController {
name,
status,
materialTypeName,
linkUrl,
req.organization,
linkUrl,
manufacturerName,
manufacturerPartNumber,
quantity,
Expand All @@ -389,7 +389,7 @@ export default class ProjectsController {
notes,
unitName,
assemblyId,
pdmFileName === '' ? undefined : pdmFileName,
pdmFileName,
reimbursementRequestId
);
res.status(200).json(updatedMaterial);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/src/services/boms.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@
name: string,
status: Material_Status,
materialTypeName: string,
linkUrl: string,
organization: Organization,
linkUrl?: string,
manufacturerName?: string,
manufacturerPartNumber?: string,
quantity?: Decimal,
Expand Down Expand Up @@ -819,7 +819,7 @@

if (!material) throw new NotFoundException('Material', materialId);
if (material.wbsElement.organizationId !== organization.organizationId)
throw new InvalidOrganizationException('Material');

Check failure on line 822 in src/backend/src/services/boms.services.ts

View workflow job for this annotation

GitHub Actions / run-tests

tests/unmocked/project.test.ts > Material Tests > Edit a material > Updates the reimbursement request when originally undefined

Error: Material does not exist in current organization! ❯ Function.getSingleMaterialWithQueryArgs src/services/boms.services.ts:822:13 ❯ Function.editMaterial src/services/boms.services.ts:582:22 ❯ tests/unmocked/project.test.ts:121:27 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { status: 400 }
if (material.dateDeleted) throw new DeletedException('Material', materialId);

return material;
Expand Down
6 changes: 3 additions & 3 deletions src/backend/src/utils/validation.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ export const materialValidators = [
nonEmptyString(body('assemblyId').optional()),
isMaterialStatus(body('status')),
nonEmptyString(body('materialTypeName')),
nonEmptyString(body('manufacturerName')).optional(),
nonEmptyString(body('manufacturerPartNumber')).optional(),
body('manufacturerName').optional().isString(),
body('manufacturerPartNumber').optional().isString(),
body('pdmFileName').optional().isString(),
decimalMinZero(body('quantity')).optional(),
nonEmptyString(body('unitName')).optional(),
intMinZero(body('price')).optional(), // in cents
intMinZero(body('subtotal')).optional(), // in cents
nonEmptyString(body('linkUrl')),
body('linkUrl').optional().isString(),
nonEmptyString(body('reimbursementRequestId')).optional(),
body('notes').isString().optional()
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const schema = yup.object().shape({
quantity: yup.number().optional(),
price: yup.number().optional(),
unitName: yup.string().optional(),
linkUrl: yup.string().required('URL is required!'),
linkUrl: yup.string().optional(),
notes: yup.string().optional(),
pdmFileName: yup.string().optional(),
assemblyId: yup.string().optional(),
Expand All @@ -43,7 +43,7 @@ export interface MaterialFormInput {
price?: number;
quantity?: number;
unitName?: string;
linkUrl: string;
linkUrl?: string;
notes?: string;
assemblyId?: string;
reimbursementRequestId?: string;
Expand All @@ -59,7 +59,7 @@ export interface MaterialDataSubmission {
price?: number;
quantity?: Decimal;
unitName?: string;
linkUrl: string;
linkUrl?: string;
notes?: string;
assemblyId?: string;
subtotal?: number;
Expand Down Expand Up @@ -139,8 +139,12 @@ const MaterialForm: React.FC<MaterialFormProps> = ({ submitText, assemblies, onS

const onSubmitWrapper = (data: MaterialFormInput): void => {
const price = data.price ? Math.round(data.price * 100) : undefined;
const subtotal = price ? (data.quantity ? parseFloat((data.quantity * price).toFixed(2)) : undefined) : undefined;
onSubmit({ ...data, subtotal, price, quantity: data.quantity ? new Decimal(data.quantity) : undefined });
const subtotal = price
? data.quantity != null
? parseFloat((data.quantity * price).toFixed(2))
: undefined
: undefined;
onSubmit({ ...data, subtotal, price, quantity: data.quantity != null ? new Decimal(data.quantity) : undefined });
};

const createManufacturerWrapper = async (manufacturerName: string): Promise<void> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
showCloseButton
>
<Grid container spacing={2}>
<Grid item xs={7}>
<Grid item xs={12}>
<FormControl fullWidth>
<Typography
sx={{
Expand All @@ -102,51 +102,6 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
/>
</FormControl>
</Grid>
<Grid item xs={5}>
<FormControl fullWidth>
<Typography
sx={{
fontWeight: 'bold',
fontSize: '1.75rem',
color: '#EF4345'
}}
variant="h5"
>
Reimbursement #:
</Typography>
<Controller
name="reimbursementRequestId"
control={control}
defaultValue={control._defaultValues.reimbursementRequestId}
render={({ field }) => (
<TextField
{...field}
select
variant="outlined"
error={!!errors.reimbursementRequestId}
helperText={errors.reimbursementRequestId?.message}
SelectProps={{
displayEmpty: true,
renderValue: (selected) =>
selected ? (
reimbursementRequests.find((rr) => rr.reimbursementRequestId === selected)?.identifier
) : (
<Typography sx={{ fontSize: '1rem', color: 'lightgray', opacity: 0.6 }}>
Select Corresponding RR
</Typography>
)
}}
>
{reimbursementRequests.map((rr: ReimbursementRequest) => (
<MenuItem key={rr.reimbursementRequestId} value={rr.reimbursementRequestId}>
{rr.identifier}
</MenuItem>
))}
</TextField>
)}
/>
</FormControl>
</Grid>
<Grid item xs={6}>
<FormControl fullWidth>
<Typography
Expand Down Expand Up @@ -206,7 +161,6 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
setValue('materialTypeName', '');
onChange('');
};

return (
<Box sx={{ alignItems: 'center' }}>
<NERAutocomplete
Expand Down Expand Up @@ -239,7 +193,7 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
}}
variant="h5"
>
Manufacturer:*
Manufacturer:
</Typography>
<Tooltip
title={'Make sure not to enter the distributor (e.g. Amazon)'}
Expand Down Expand Up @@ -319,17 +273,10 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
}}
variant="h5"
>
Part Details:*
Part Details:
</Typography>
<Tooltip title={"Enter 'N/A' if no Manufacturer Part Number"} placement="right">
<HelpIcon
sx={{
fontSize: 'medium',
ml: 1,
color: 'lightgray',
cursor: 'pointer'
}}
/>
<HelpIcon sx={{ marginBottom: '-1.2em', fontSize: 'medium', marginLeft: '5px', color: 'lightgray' }} />
</Tooltip>
</Box>
</Grid>
Expand Down Expand Up @@ -458,6 +405,41 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
</Grid>
</Grid>
<Grid item xs={12}>
<Grid item xs={12} mt={2}>
<FormControl fullWidth>
<Controller
name="reimbursementRequestId"
control={control}
defaultValue={control._defaultValues.reimbursementRequestId}
render={({ field }) => (
<TextField
{...field}
select
variant="outlined"
error={!!errors.reimbursementRequestId}
helperText={errors.reimbursementRequestId?.message}
SelectProps={{
displayEmpty: true,
renderValue: (selected) =>
selected ? (
reimbursementRequests.find((rr) => rr.reimbursementRequestId === selected)?.identifier
) : (
<Typography sx={{ fontSize: '1rem', color: 'lightgray', opacity: 0.6 }}>
Select Corresponding Reimbursement Request Number
</Typography>
)
}}
>
{reimbursementRequests.map((rr: ReimbursementRequest) => (
<MenuItem key={rr.reimbursementRequestId} value={rr.reimbursementRequestId}>
{rr.identifier}
</MenuItem>
))}
</TextField>
)}
/>
</FormControl>
</Grid>
<Box display={'flex'} justifyContent={'flex-end'} mt={2}>
<FormControl fullWidth>
<Controller
Expand Down
Loading