-
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-5718 : Add view update remove form 8 expropriation #3402
Changes from all commits
3718222
aada822
e44317f
4432bef
edcc8e6
0604c43
8887029
3b4753d
ede5cfb
d2cb718
079b8e9
40fe000
a135a01
1efc31f
77606ea
dd1c9e3
c5008ec
3e3b49b
fd3d656
444f722
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 |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using System; | ||
using MapsterMapper; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using Pims.Api.Helpers.Exceptions; | ||
using Pims.Api.Models.Concepts; | ||
using Pims.Api.Policies; | ||
using Pims.Api.Services; | ||
using Pims.Core.Extensions; | ||
using Pims.Core.Json; | ||
using Pims.Dal.Security; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
|
||
namespace Pims.Api.Areas.ExpropriationPayment | ||
{ | ||
/// <summary> | ||
/// ExpropriationPaymentController class, provides endpoints to handle expropriation payments. | ||
/// </summary> | ||
[Authorize] | ||
[ApiController] | ||
[ApiVersion("1.0")] | ||
[Area("expropriation-payments")] | ||
[Route("v{version:apiVersion}/[area]")] | ||
[Route("[area]")] | ||
public class ExpropriationPaymentController : ControllerBase | ||
{ | ||
private readonly IMapper _mapper; | ||
private readonly ILogger _logger; | ||
private readonly IExpropriationPaymentService _expropriationPaymentService; | ||
|
||
public ExpropriationPaymentController(IMapper mapper, ILogger<ExpropriationPaymentController> logger, IExpropriationPaymentService expropriationPaymentService) | ||
{ | ||
_mapper = mapper; | ||
_logger = logger; | ||
_expropriationPaymentService = expropriationPaymentService; | ||
} | ||
Check warning on line 37 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L32-L37
|
||
|
||
/// <summary> | ||
/// Get The Expropriation Payment (Form8) by Id. | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <returns></returns> | ||
[HttpGet("{id:long}")] | ||
[HasPermission(Permissions.AcquisitionFileView)] | ||
[Produces("application/json")] | ||
[ProducesResponseType(typeof(ExpropriationPaymentModel), 200)] | ||
[SwaggerOperation(Tags = new[] { "expropriation-payments" })] | ||
public IActionResult GetExpropriationPaymentById([FromRoute] long id) | ||
{ | ||
_logger.LogInformation( | ||
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}", | ||
nameof(ExpropriationPaymentController), | ||
nameof(GetExpropriationPaymentById), | ||
User.GetUsername(), | ||
DateTime.Now); | ||
_logger.LogInformation("Dispatching to service: {Service}", _expropriationPaymentService.GetType()); | ||
Check warning on line 57 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L50-L57
|
||
|
||
var expropriationPayment = _expropriationPaymentService.GetById(id); | ||
|
||
return new JsonResult(_mapper.Map<ExpropriationPaymentModel>(expropriationPayment)); | ||
} | ||
Check warning on line 62 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L61-L62
|
||
|
||
/// <summary> | ||
/// Update the Expropriation Payment instance. | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <param name="expropriationPayment"></param> | ||
/// <returns></returns> | ||
/// <exception cref="BadRequestException">Validate id matching</exception> | ||
[HttpPut("{id:long}")] | ||
[HasPermission(Permissions.AcquisitionFileEdit)] | ||
[Produces("application/json")] | ||
[ProducesResponseType(typeof(ExpropriationPaymentModel), 200)] | ||
[SwaggerOperation(Tags = new[] { "expropriation-payments" })] | ||
public IActionResult UpdateExpropriationPayment([FromRoute] long id, [FromBody] ExpropriationPaymentModel expropriationPayment) | ||
{ | ||
_logger.LogInformation( | ||
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}", | ||
nameof(ExpropriationPaymentController), | ||
nameof(UpdateExpropriationPayment), | ||
User.GetUsername(), | ||
DateTime.Now); | ||
_logger.LogInformation("Dispatching to service: {Service}", _expropriationPaymentService.GetType()); | ||
Check warning on line 84 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L77-L84
|
||
|
||
if (id != expropriationPayment.Id) | ||
{ | ||
throw new BadRequestException("Invalid expropriationPaymentId."); | ||
Check warning on line 88 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L87-L88
|
||
} | ||
|
||
var expPaymentEntity = _mapper.Map<Dal.Entities.PimsExpropriationPayment>(expropriationPayment); | ||
var compensation = _expropriationPaymentService.Update(expPaymentEntity); | ||
Check warning on line 92 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L91-L92
|
||
|
||
return new JsonResult(_mapper.Map<ExpropriationPaymentModel>(compensation)); | ||
} | ||
Check warning on line 95 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L94-L95
|
||
|
||
/// <summary> | ||
/// Deletes the Expropriation Payment with the matching id. | ||
/// </summary> | ||
/// <param name="id">Used to identify the entity to delete.</param> | ||
/// <returns></returns> | ||
[HttpDelete("{id:long}")] | ||
[Produces("application/json")] | ||
[HasPermission(Permissions.AcquisitionFileEdit)] | ||
[ProducesResponseType(typeof(bool), 200)] | ||
[SwaggerOperation(Tags = new[] { "expropriation-payments" })] | ||
[TypeFilter(typeof(NullJsonResultFilter))] | ||
public IActionResult DeleteExpropriationPayment([FromRoute] long id) | ||
{ | ||
_logger.LogInformation( | ||
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}", | ||
nameof(ExpropriationPaymentController), | ||
nameof(DeleteExpropriationPayment), | ||
User.GetUsername(), | ||
DateTime.Now); | ||
_logger.LogInformation($"Dispatching to service: {_expropriationPaymentService.GetType()}"); | ||
Check warning on line 116 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L109-L116
|
||
|
||
var result = _expropriationPaymentService.Delete(id); | ||
return new JsonResult(result); | ||
} | ||
Check warning on line 120 in source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs Codecov / codecov/patchsource/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs#L118-L120
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Mapster; | ||
using Pims.Api.Models.Concepts.ExpropriationPayment; | ||
using Pims.Dal.Entities; | ||
using Entity = Pims.Dal.Entities; | ||
|
||
namespace Pims.Api.Models.Concepts | ||
{ | ||
public class ExpropriationPaymentItemMap : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) | ||
{ | ||
config.NewConfig<PimsExpropPmtPmtItem, ExpropriationPaymentItemModel>() | ||
.Map(dest => dest.Id, src => src.Internal_Id) | ||
.Map(dest => dest.ExpropriationPaymentId, src => src.ExpropriationPaymentId) | ||
.Map(dest => dest.PaymentItemTypeCode, src => src.PaymentItemTypeCode) | ||
.Map(dest => dest.PaymentItemType, src => src.PaymentItemTypeCodeNavigation) | ||
.Map(dest => dest.IsGstRequired, src => src.IsGstRequired) | ||
.Map(dest => dest.PretaxAmount, src => src.PretaxAmt) | ||
.Map(dest => dest.TaxAmount, src => src.TaxAmt) | ||
.Map(dest => dest.TotalAmount, src => src.TotalAmt) | ||
.Map(dest => dest.IsDisabled, src => src.IsDisabled) | ||
.Map(dest => dest.RowVersion, src => src.ConcurrencyControlNumber) | ||
.Inherits<Entity.IBaseEntity, BaseModel>(); | ||
|
||
config.NewConfig<ExpropriationPaymentItemModel, PimsExpropPmtPmtItem>() | ||
.Map(dest => dest.Internal_Id, src => src.Id) | ||
.Map(dest => dest.ExpropriationPaymentId, src => src.ExpropriationPaymentId) | ||
.Map(dest => dest.PaymentItemTypeCode, src => src.PaymentItemTypeCode) | ||
.Map(dest => dest.IsGstRequired, src => src.IsGstRequired) | ||
.Map(dest => dest.PretaxAmt, src => src.PretaxAmount) | ||
.Map(dest => dest.TaxAmt, src => src.TaxAmount) | ||
.Map(dest => dest.TotalAmt, src => src.TotalAmount) | ||
.Map(dest => dest.IsDisabled, src => src.IsDisabled) | ||
.Map(dest => dest.ConcurrencyControlNumber, src => src.RowVersion) | ||
.Inherits<BaseModel, IBaseEntity>(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Pims.Api.Models.Concepts.ExpropriationPayment | ||
{ | ||
public class ExpropriationPaymentItemModel : BaseAppModel | ||
{ | ||
public long? Id { get; set; } | ||
|
||
public long? ExpropriationPaymentId { get; set; } | ||
|
||
public string PaymentItemTypeCode { get; set; } | ||
|
||
public TypeModel<string> PaymentItemType { get; set; } | ||
|
||
public bool? IsGstRequired { get; set; } | ||
|
||
public decimal? PretaxAmount { get; set; } | ||
|
||
public decimal? TaxAmount { get; set; } | ||
|
||
public decimal? TotalAmount { get; set; } | ||
|
||
public bool? IsDisabled { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Mapster; | ||
using Pims.Dal.Entities; | ||
|
||
namespace Pims.Api.Models.Concepts | ||
{ | ||
public class ExpropriationPaymentMap : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) | ||
{ | ||
config.NewConfig<PimsExpropriationPayment, ExpropriationPaymentModel>() | ||
.Map(dest => dest.Id, src => src.Internal_Id) | ||
.Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId) | ||
.Map(dest => dest.AcquisitionOwnerId, src => src.AcquisitionOwnerId) | ||
.Map(dest => dest.AcquisitionOwner, src => src.AcquisitionOwner) | ||
.Map(dest => dest.InterestHolderId, src => src.InterestHolderId) | ||
.Map(dest => dest.InterestHolder, src => src.InterestHolder) | ||
.Map(dest => dest.ExpropriatingAuthorityId, src => src.ExpropriatingAuthority) | ||
.Map(dest => dest.ExpropriatingAuthority, src => src.ExpropriatingAuthorityNavigation) | ||
.Map(dest => dest.Description, src => src.Description) | ||
.Map(dest => dest.IsDisabled, src => src.IsDisabled) | ||
.Map(dest => dest.RowVersion, src => src.ConcurrencyControlNumber) | ||
.Map(dest => dest.PaymentItems, src => src.PimsExpropPmtPmtItems) | ||
.Inherits<IBaseEntity, BaseModel>(); | ||
|
||
config.NewConfig<ExpropriationPaymentModel, PimsExpropriationPayment>() | ||
.Map(dest => dest.Internal_Id, src => src.Id) | ||
.Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId) | ||
.Map(dest => dest.AcquisitionOwnerId, src => src.AcquisitionOwnerId) | ||
.Map(dest => dest.InterestHolderId, src => src.InterestHolderId) | ||
.Map(dest => dest.ExpropriatingAuthority, src => src.ExpropriatingAuthorityId) | ||
.Map(dest => dest.Description, src => src.Description) | ||
.Map(dest => dest.IsDisabled, src => src.IsDisabled) | ||
.Map(dest => dest.ConcurrencyControlNumber, src => src.RowVersion) | ||
.Map(dest => dest.PimsExpropPmtPmtItems, src => src.PaymentItems) | ||
.Inherits<BaseModel, IBaseEntity>(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
using Pims.Api.Models.Concepts.ExpropriationPayment; | ||
|
||
namespace Pims.Api.Models.Concepts | ||
{ | ||
public class ExpropriationPaymentModel : BaseAppModel | ||
{ | ||
public long? Id { get; set; } | ||
|
||
public long AcquisitionFileId { get; set; } | ||
|
||
public long? AcquisitionOwnerId { get; set; } | ||
|
||
public AcquisitionFileOwnerModel AcquisitionOwner { get; set; } | ||
|
||
public long? InterestHolderId { get; set; } | ||
|
||
public InterestHolderModel InterestHolder { get; set; } | ||
|
||
public long? ExpropriatingAuthorityId { get; set; } | ||
|
||
public OrganizationModel ExpropriatingAuthority { get; set; } | ||
|
||
public string Description { get; set; } | ||
|
||
public bool? IsDisabled { get; set; } | ||
|
||
public List<ExpropriationPaymentItemModel> PaymentItems { get; set; } | ||
|
||
} | ||
} |
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.
This controller has the exact some name as the one above. Its a bit confusing, maybe the above one could be plural? or reference the acquisition file?
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.
removed one controller