-
Notifications
You must be signed in to change notification settings - Fork 24
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
PSP-7618 : Re-add project/product to Disposition Files (Create, Update and View File Summary) #3777
Changes from 6 commits
9b25b0a
d90df9a
aa809d7
bc10cb4
9fa2ae4
003ae8e
1209403
97530aa
453aeef
15a16d6
dcdda15
cda8a85
d9dab1d
43401a1
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using System; | ||
using System.Security.Claims; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
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. this looks unused to me (remove) 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. removed |
||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Pims.Dal.Repositories | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,8 @@ | |
|
||
return this.Context.PimsDispositionFiles.AsNoTracking() | ||
.Include(d => d.DispositionFileStatusTypeCodeNavigation) | ||
.Include(d => d.Project) | ||
.Include(d => d.Product) | ||
.Include(d => d.DispositionFundingTypeCodeNavigation) | ||
.Include(d => d.DispositionInitiatingDocTypeCodeNavigation) | ||
.Include(d => d.DispositionStatusTypeCodeNavigation) | ||
|
@@ -344,12 +346,46 @@ | |
public PimsDispositionSale UpdateDispositionFileSale(PimsDispositionSale dispositionSale) | ||
{ | ||
var existingSale = Context.PimsDispositionSales | ||
.Include(x => x.DspPurchAgent) | ||
.Include(x => x.DspPurchSolicitor) | ||
.FirstOrDefault(x => x.DispositionSaleId.Equals(dispositionSale.DispositionSaleId)) ?? throw new KeyNotFoundException(); | ||
|
||
if (existingSale.DspPurchAgent != null && dispositionSale.DspPurchAgent == null) | ||
{ | ||
Context.Remove(existingSale.DspPurchAgent); | ||
dispositionSale.DspPurchAgentId = null; | ||
} | ||
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. Test coverage on these conditionals is a bit spotty, can you add some tests for this? 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. updated |
||
else if (existingSale.DspPurchAgent != null && dispositionSale.DspPurchAgentId.HasValue && dispositionSale.DspPurchAgent != null) | ||
{ | ||
Context.Entry(existingSale.DspPurchAgent).CurrentValues.SetValues(dispositionSale.DspPurchAgent); | ||
} | ||
else if (existingSale.DspPurchAgent == null && dispositionSale.DspPurchAgent != null) | ||
{ | ||
Context.PimsDspPurchAgents.Add(dispositionSale.DspPurchAgent); | ||
Context.SaveChanges(); | ||
|
||
dispositionSale.DspPurchAgentId = dispositionSale.DspPurchAgent.DspPurchAgentId; | ||
} | ||
|
||
if (existingSale.DspPurchSolicitor != null && dispositionSale.DspPurchSolicitor == null) | ||
{ | ||
Context.Remove(existingSale.DspPurchSolicitor); | ||
dispositionSale.DspPurchSolicitorId = null; | ||
} | ||
else if (existingSale.DspPurchSolicitor != null && dispositionSale.DspPurchSolicitorId.HasValue && dispositionSale.DspPurchSolicitor != null) | ||
{ | ||
Context.Entry(existingSale.DspPurchSolicitor).CurrentValues.SetValues(dispositionSale.DspPurchSolicitor); | ||
} | ||
else if (existingSale.DspPurchSolicitor == null && dispositionSale.DspPurchSolicitor != null) | ||
{ | ||
Context.PimsDspPurchSolicitors.Add(dispositionSale.DspPurchSolicitor); | ||
Context.SaveChanges(); | ||
|
||
dispositionSale.DspPurchSolicitorId = dispositionSale.DspPurchSolicitor.DspPurchSolicitorId; | ||
} | ||
|
||
Context.Entry(existingSale).CurrentValues.SetValues(dispositionSale); | ||
Context.UpdateChild<PimsDispositionSale, long, PimsDispositionPurchaser, long>(p => p.PimsDispositionPurchasers, dispositionSale.Internal_Id, dispositionSale.PimsDispositionPurchasers.ToArray()); | ||
// Context.UpdateChild<PimsDispositionSale, long, PimsDspPurchAgent, long>(p => p.PimsDspPurchAgents, dispositionSale.Internal_Id, dispositionSale.PimsDspPurchAgents.ToArray()); TODO: Fix agent update | ||
//Context.UpdateChild<PimsDispositionSale, long, PimsDspPurchSolicitor, long>(p => p.PimsDspPurchSolicitors, dispositionSale.Internal_Id, dispositionSale.PimsDspPurchSolicitors.ToArray()); | ||
|
||
return existingSale; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,9 @@ describe('Disposition List View', () => { | |
}); | ||
|
||
it('matches snapshot', async () => { | ||
const results = mockPagedResults([mockDispositionFileResponse()]); | ||
const results = mockPagedResults([ | ||
mockDispositionFileResponse() as unknown as Api_DispositionFile, | ||
]); | ||
getDispositionFilesPagedApiFn.mockResolvedValue(results); | ||
const { asFragment } = setup(); | ||
await waitForElementToBeRemoved(screen.getByTitle('table-loading')); | ||
|
@@ -88,7 +90,9 @@ describe('Disposition List View', () => { | |
await waitForElementToBeRemoved(screen.getByTitle('table-loading')); | ||
expect(await screen.queryByText(/test disposition/i)).toBeNull(); | ||
|
||
results = mockPagedResults([mockDispositionFileResponse(1, 'test disposition')]); | ||
results = mockPagedResults([ | ||
mockDispositionFileResponse(1, 'test disposition') as unknown as Api_DispositionFile, | ||
]); | ||
getDispositionFilesPagedApiFn.mockResolvedValue(results); | ||
|
||
const input = getByName('fileNameOrNumberOrReference'); | ||
|
@@ -108,7 +112,7 @@ describe('Disposition List View', () => { | |
it('searches by pid', async () => { | ||
let results = mockPagedResults([ | ||
{ | ||
...mockDispositionFileResponse(), | ||
...(mockDispositionFileResponse() as unknown as Api_DispositionFile), | ||
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. I'm having trouble understanding the need for this, if the entire point of this mock is to create a disposition file, why are you needing to cast this to an Api_DispositionFile via an unknown? 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. I am casting from the new generated models ApiGen_Concepts_XXX I am limiting the use of the new models scoped to what I am currently working and not trying to spill over everywhere. The story to do the removal of old models would just need to remove the casting. 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. ah ok. I see. That is fine for now then. 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. Actually, can you log a follow-up task for is74 that would cover correcting this once we merge 5.1 That way we don't forget. 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. Task created. |
||
fileProperties: [ | ||
{ | ||
id: 12, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
acquisition -> disposition