-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * manage debit notes utility back end * client * register facade service * domain service, tests, etc * add closedBy * refresh list on updates * reinstate auth check * rename item type, fix route etc
- Loading branch information
1 parent
6ad64f4
commit 4e2bb2f
Showing
29 changed files
with
1,090 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Domain.LinnApps/PurchaseOrders/IPlCreditDebitNoteService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Linn.Purchasing.Domain.LinnApps.PurchaseOrders | ||
{ | ||
using System.Collections.Generic; | ||
|
||
public interface IPlCreditDebitNoteService | ||
{ | ||
public PlCreditDebitNote CloseDebitNote( | ||
PlCreditDebitNote toClose, | ||
string reason, | ||
int closedBy, | ||
IEnumerable<string> privileges); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Linn.Purchasing.Domain.LinnApps.PurchaseOrders | ||
{ | ||
using System; | ||
|
||
using Linn.Purchasing.Domain.LinnApps.Suppliers; | ||
|
||
public class PlCreditDebitNote | ||
{ | ||
public int NoteNumber { get; set; } | ||
|
||
public string NoteType { get; set; } | ||
|
||
public string PartNumber { get; set; } | ||
|
||
public int OrderQty { get; set; } | ||
|
||
public int? OriginalOrderNumber { get; set; } | ||
|
||
public int? ReturnsOrderNumber { get; set; } | ||
|
||
public decimal NetTotal { get; set; } | ||
|
||
public string Notes { get; set; } | ||
|
||
public DateTime? DateClosed { get; set; } | ||
|
||
public DateTime DateCreated { get; set; } | ||
|
||
public int? ClosedBy { get; set; } | ||
|
||
public string ReasonClosed { get; set; } | ||
|
||
public int? SupplierId { get; set; } | ||
|
||
public Supplier Supplier { get; set; } | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Domain.LinnApps/PurchaseOrders/PlCreditDebitNoteService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace Linn.Purchasing.Domain.LinnApps.PurchaseOrders | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Linn.Common.Authorisation; | ||
using Linn.Purchasing.Domain.LinnApps.Exceptions; | ||
|
||
public class PlCreditDebitNoteService : IPlCreditDebitNoteService | ||
{ | ||
private readonly IAuthorisationService authService; | ||
|
||
public PlCreditDebitNoteService(IAuthorisationService authService) | ||
{ | ||
this.authService = authService; | ||
} | ||
|
||
public PlCreditDebitNote CloseDebitNote( | ||
PlCreditDebitNote toClose, | ||
string reason, | ||
int closedBy, | ||
IEnumerable<string> privileges) | ||
{ | ||
if (!this.authService.HasPermissionFor(AuthorisedAction.PlCreditDebitNoteClose, privileges)) | ||
{ | ||
throw new UnauthorisedActionException("You are not authorised to close debit notes"); | ||
} | ||
|
||
toClose.DateClosed = DateTime.Today; | ||
toClose.ReasonClosed = reason; | ||
toClose.ClosedBy = closedBy; | ||
return toClose; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Facade/ResourceBuilders/PlCreditDebitNoteResourceBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace Linn.Purchasing.Facade.ResourceBuilders | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Linn.Common.Facade; | ||
using Linn.Purchasing.Domain.LinnApps.PurchaseOrders; | ||
using Linn.Purchasing.Resources; | ||
|
||
public class PlCreditDebitNoteResourceBuilder : IBuilder<PlCreditDebitNote> | ||
{ | ||
public PlCreditDebitNoteResource Build(PlCreditDebitNote note, IEnumerable<string> claims) | ||
{ | ||
return new PlCreditDebitNoteResource | ||
{ | ||
OrderQty = note.OrderQty, | ||
PartNumber = note.PartNumber, | ||
DateClosed = note.DateClosed?.ToString("o"), | ||
SupplierId = note.SupplierId, | ||
ClosedBy = note.ClosedBy, | ||
NetTotal = note.NetTotal, | ||
NoteNumber = note.NoteNumber, | ||
OriginalOrderNumber = note.OriginalOrderNumber, | ||
ReturnsOrderNumber = note.ReturnsOrderNumber, | ||
Notes = note.Notes, | ||
SupplierName = note.Supplier?.Name, | ||
DateCreated = note.DateCreated.ToShortDateString() | ||
}; | ||
} | ||
|
||
public string GetLocation(PlCreditDebitNote p) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
object IBuilder<PlCreditDebitNote>.Build(PlCreditDebitNote entity, IEnumerable<string> claims) => this.Build(entity, claims); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
namespace Linn.Purchasing.Facade.Services | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
|
||
using Linn.Common.Facade; | ||
using Linn.Common.Persistence; | ||
using Linn.Purchasing.Domain.LinnApps.PurchaseOrders; | ||
using Linn.Purchasing.Resources; | ||
|
||
public class PlCreditDebitNoteFacadeService | ||
: FacadeFilterResourceService<PlCreditDebitNote, int, PlCreditDebitNoteResource, PlCreditDebitNoteResource, PlCreditDebitNoteResource> | ||
{ | ||
private readonly IPlCreditDebitNoteService domainService; | ||
|
||
public PlCreditDebitNoteFacadeService( | ||
IRepository<PlCreditDebitNote, int> repository, | ||
ITransactionManager transactionManager, | ||
IBuilder<PlCreditDebitNote> builder, | ||
IPlCreditDebitNoteService domainService) | ||
: base(repository, transactionManager, builder) | ||
{ | ||
this.domainService = domainService; | ||
} | ||
|
||
protected override PlCreditDebitNote CreateFromResource( | ||
PlCreditDebitNoteResource resource, | ||
IEnumerable<string> privileges = null) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override void UpdateFromResource( | ||
PlCreditDebitNote entity, | ||
PlCreditDebitNoteResource updateResource, | ||
IEnumerable<string> privileges = null) | ||
{ | ||
if (updateResource.ClosedBy.HasValue && updateResource.Close.HasValue && (bool)updateResource.Close) | ||
{ | ||
this.domainService.CloseDebitNote( | ||
entity, | ||
updateResource.ReasonClosed, | ||
(int)updateResource.ClosedBy, | ||
privileges); | ||
} | ||
|
||
entity.Notes = updateResource.Notes; | ||
} | ||
|
||
protected override Expression<Func<PlCreditDebitNote, bool>> SearchExpression( | ||
string searchTerm) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override void SaveToLogTable( | ||
string actionType, | ||
int userNumber, | ||
PlCreditDebitNote entity, | ||
PlCreditDebitNoteResource resource, | ||
PlCreditDebitNoteResource updateResource) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override void DeleteOrObsoleteResource( | ||
PlCreditDebitNote entity, IEnumerable<string> privileges = null) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override Expression<Func<PlCreditDebitNote, bool>> FilterExpression( | ||
PlCreditDebitNoteResource searchResource) | ||
{ | ||
var date = string.IsNullOrEmpty(searchResource.DateClosed) | ||
? (DateTime?)null | ||
: DateTime.Parse(searchResource.DateClosed); | ||
return x => x.DateClosed == date && x.NoteType == searchResource.NoteType; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/Persistence.LinnApps/Repositories/PlCreditDebitNoteRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Linn.Purchasing.Persistence.LinnApps.Repositories | ||
{ | ||
using System; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
|
||
using Linn.Common.Persistence.EntityFramework; | ||
using Linn.Purchasing.Domain.LinnApps.PurchaseOrders; | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
|
||
public class PlCreditDebitNoteRepository : EntityFrameworkRepository<PlCreditDebitNote, int> | ||
{ | ||
public PlCreditDebitNoteRepository(ServiceDbContext serviceDbContext) | ||
: base(serviceDbContext.PlCreditDebitNotes) | ||
{ | ||
} | ||
|
||
public override IQueryable<PlCreditDebitNote> FilterBy(Expression<Func<PlCreditDebitNote, bool>> expression) | ||
{ | ||
return base.FilterBy(expression).Include(n => n.Supplier); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace Linn.Purchasing.Resources | ||
{ | ||
using System.Collections.Generic; | ||
|
||
public class PlCreditDebitNoteResource | ||
{ | ||
public int NoteNumber { get; set; } | ||
|
||
public string NoteType { get; set; } | ||
|
||
public string PartNumber { get; set; } | ||
|
||
public int OrderQty { get; set; } | ||
|
||
public int? OriginalOrderNumber { get; set; } | ||
|
||
public int? ReturnsOrderNumber { get; set; } | ||
|
||
public decimal NetTotal { get; set; } | ||
|
||
public string Notes { get; set; } | ||
|
||
public string DateClosed { get; set; } | ||
|
||
public int? ClosedBy { get; set; } | ||
|
||
public string ReasonClosed { get; set; } | ||
|
||
public int? SupplierId { get; set; } | ||
|
||
public string SupplierName { get; set; } | ||
|
||
public IEnumerable<string> UserPrivileges { get; set; } | ||
|
||
public string DateCreated { get; set; } | ||
|
||
public bool? Close { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Service.Host/client/src/actions/openDebitNotesActions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { FetchApiActions } from '@linn-it/linn-form-components-library'; | ||
import { openDebitNotesActionTypes as actionTypes } from './index'; | ||
import * as itemTypes from '../itemTypes'; | ||
import config from '../config'; | ||
|
||
export default new FetchApiActions( | ||
itemTypes.openDebitNotes.item, | ||
itemTypes.openDebitNotes.actionType, | ||
itemTypes.openDebitNotes.uri, | ||
actionTypes, | ||
config.appRoot | ||
); |
Oops, something went wrong.