-
Notifications
You must be signed in to change notification settings - Fork 9
#4107 BOM inline editing #4141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
#4107 BOM inline editing #4141
Changes from all commits
224b45a
3fa446c
6b3726b
acffb68
5152789
8ee4a71
1592ff5
daf94b3
c9b66a0
02c269c
59b8f79
c3949be
626f17b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,6 @@ export default class BillOfMaterialsService { | |
| * @param manufacturerPartNumber the manufacturer part number for the material (optional) | ||
| * @param quantity the quantity of material as a number (optional) | ||
| * @param price the price of the material in whole cents (optional) | ||
| * @param subtotal the subtotal of the price for the material in whole cents (optional) | ||
| * @param notes any notes about the material as a string (optional) | ||
| * @param assemblyId the id of the Assembly for the material (optional) | ||
| * @param pdmFileName the name of the pdm file for the material (optional) | ||
|
|
@@ -75,7 +74,6 @@ export default class BillOfMaterialsService { | |
| manufacturerPartNumber?: string, | ||
| quantity?: Decimal, | ||
| price?: number, | ||
| subtotal?: number, | ||
| notes?: string, | ||
| assemblyId?: string, | ||
| pdmFileName?: string, | ||
|
|
@@ -119,6 +117,9 @@ export default class BillOfMaterialsService { | |
|
|
||
| if (!perms) throw new AccessDeniedException('create materials'); | ||
|
|
||
| const computedSubtotal = | ||
| price !== undefined && quantity !== undefined ? Math.round(price * Number(quantity)) : undefined; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this not what Wave was talking about with removing from backend everywhere
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. she mentioned not passing it to the backend and just calculating it in the service function. it is also still in MaterialFormView in the frontend but thats bc the modal shows a preview of what the subtotal will be before submitting |
||
|
|
||
| const createdMaterial = await prisma.material.create({ | ||
| data: { | ||
| userCreatedId: creator.userId, | ||
|
|
@@ -132,7 +133,7 @@ export default class BillOfMaterialsService { | |
| quantity, | ||
| unitId: unit ? unit.id : null, | ||
| price, | ||
| subtotal, | ||
| subtotal: computedSubtotal, | ||
| linkUrl, | ||
| notes, | ||
| dateCreated: new Date(), | ||
|
|
@@ -611,7 +612,6 @@ export default class BillOfMaterialsService { | |
| * @param manufacturerPartNumber the manufacturerPartNumber of the edited material (optional) | ||
| * @param quantity the quantity of the edited material (optional) | ||
| * @param price the price of the edited material (optional) | ||
| * @param subtotal the subtotal of the edited material (optional) | ||
| * @param notes the notes of the edited material (optional) | ||
| * @param unitName the unit name of the edited material (optional) | ||
| * @param assemblyId the assembly id of the edited material (optional) | ||
|
|
@@ -631,7 +631,6 @@ export default class BillOfMaterialsService { | |
| manufacturerPartNumber?: string, | ||
| quantity?: Decimal, | ||
| price?: number, | ||
| subtotal?: number, | ||
| notes?: string, | ||
| unitName?: string, | ||
| assemblyId?: string, | ||
|
|
@@ -670,6 +669,12 @@ export default class BillOfMaterialsService { | |
| manufacturer = await BillOfMaterialsService.getSingleManufacturerWithQueryArgs(manufacturerName, organization); | ||
| } | ||
|
|
||
| // recalculate subtotal on edits | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we're going to take subtotal out of the endpoints in the backend, we should take it out of the frontend hooks too since now it's being passed and then dropped
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still relevant I think? |
||
| const finalPrice = price ?? material.price ?? undefined; | ||
| const finalQuantity = quantity ?? material.quantity ?? undefined; | ||
| const computedSubtotal = | ||
| finalPrice !== undefined && finalQuantity !== undefined ? Math.round(finalPrice * Number(finalQuantity)) : undefined; | ||
|
|
||
| const updatedMaterial = await prisma.material.update({ | ||
| where: { materialId }, | ||
| data: { | ||
|
|
@@ -681,12 +686,12 @@ export default class BillOfMaterialsService { | |
| quantity, | ||
| unitId: unit ? unit.id : null, | ||
| price, | ||
| subtotal, | ||
| subtotal: computedSubtotal, | ||
| linkUrl, | ||
| notes, | ||
| wbsElementId: project.wbsElementId, | ||
| assemblyId, | ||
| pdmFileName | ||
| pdmFileName: pdmFileName !== undefined ? pdmFileName || null : undefined | ||
| }, | ||
| ...getMaterialQueryArgs(organization.organizationId) | ||
| }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.