Skip to content
Merged

fix #556

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
22 changes: 18 additions & 4 deletions src/Domain.LinnApps/GoodsIn/GoodsInService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Linn.Stores.Domain.LinnApps.ExternalServices;
using Linn.Stores.Domain.LinnApps.Models;
using Linn.Stores.Domain.LinnApps.Requisitions;
using Linn.Stores.Domain.LinnApps.StockLocators;

public class GoodsInService : IGoodsInService
{
Expand Down Expand Up @@ -38,6 +39,8 @@ public class GoodsInService : IGoodsInService

private readonly IPrintRsnService printRsnService;

private readonly IRepository<StorageLocation, int> storageLocationRepository;

public GoodsInService(
IGoodsInPack goodsInPack,
IStoresPack storesPack,
Expand All @@ -51,7 +54,8 @@ public GoodsInService(
IRepository<PurchaseOrder, int> purchaseOrderRepository,
IQueryRepository<AuthUser> authUserRepository,
IPrintRsnService printRsnService,
IQueryRepository<StoragePlace> storagePlaceRepository)
IQueryRepository<StoragePlace> storagePlaceRepository,
IRepository<StorageLocation, int> storageLocationRepository)
{
this.storesPack = storesPack;
this.goodsInPack = goodsInPack;
Expand All @@ -66,6 +70,7 @@ public GoodsInService(
this.authUserRepository = authUserRepository;
this.storagePlaceRepository = storagePlaceRepository;
this.printRsnService = printRsnService;
this.storageLocationRepository = storageLocationRepository;
}

public BookInResult DoBookIn(
Expand Down Expand Up @@ -140,6 +145,18 @@ public BookInResult DoBookIn(
}
}

var part = this.partsRepository.FindBy(x => x.PartNumber.Equals(partNumber.ToUpper()));

var location = this.storageLocationRepository.FindBy(x => x.LocationCode.Equals(ontoLocation.ToUpper()));

if (part.StorageTypes != null && part.StorageTypes.Any())
{
if (!part.StorageTypes.Select(t => t.StorageType).Contains(location.StorageType))
{
return new BookInResult(false, $"Can't put {partNumber} on {location.StorageType}");
}
}

var bookinRef = this.goodsInPack.GetNextBookInRef();

if (!linesArray.Any())
Expand Down Expand Up @@ -173,7 +190,6 @@ public BookInResult DoBookIn(

if (transactionType.Equals("O"))
{
var part = this.partsRepository.FindBy(x => x.PartNumber.Equals(partNumber.ToUpper()));

if (!part.DateLive.HasValue)
{
Expand Down Expand Up @@ -227,8 +243,6 @@ public BookInResult DoBookIn(

if (transactionType == "O")
{
var part = this.partsRepository.FindBy(x => x.PartNumber.Equals(partNumber.ToUpper()));

result.QcInfo = part?.QcInformation;
this.goodsInPack.GetPurchaseOrderDetails(
orderNumber.Value,
Expand Down
2 changes: 2 additions & 0 deletions src/Domain.LinnApps/Parts/Part.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ public class Part

public decimal? ResistorTolerance { get; set; }

public IEnumerable<PartStorageType> StorageTypes { get; set; }

public DateTime? GetDateQcFlagLastChanged()
{
return this.GetRelevantQcControl()?.TransactionDate;
Expand Down
1 change: 1 addition & 0 deletions src/Persistence.LinnApps/Repositories/PartRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public Part FindBy(Expression<Func<Part, bool>> expression)
.Include(p => p.NominalAccount).ThenInclude(a => a.Nominal)
.Include(p => p.DataSheets)
.Include(p => p.MechPartSource)
.Include(p => p.StorageTypes)
.ToList().FirstOrDefault();
}

Expand Down
1 change: 1 addition & 0 deletions src/Persistence.LinnApps/ServiceDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ private void BuildParts(ModelBuilder builder)
e.HasOne(p => p.MechPartSource).WithOne(m => m.Part);
e.HasOne(p => p.SalesArticle).WithOne(a => a.Part).HasForeignKey<Part>(x => x.PartNumber);
e.HasMany(p => p.QcControls).WithOne().HasForeignKey(q => q.PartNumber);
e.HasMany(p => p.StorageTypes).WithOne().HasForeignKey(q => q.PartNumber);
e.Property(p => p.LibraryName).HasColumnName("LIBRARY_NAME").HasMaxLength(200);
e.Property(p => p.LibraryRef).HasColumnName("LIBRARY_REF").HasMaxLength(100);
e.Property(p => p.FootprintRef1).HasColumnName("FOOTPRINT_REF").HasMaxLength(100);
Expand Down
13 changes: 8 additions & 5 deletions src/Service.Host/client/src/components/common/SearchPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ const useStyles = makeStyles(() => ({
},
paper: {
backgroundColor: '#f5f5f5',
position: 'relative',
zIndex: -1
position: 'fixed',
zIndex: 1000,
paddingTop: '80px',
width: '100%',
overflow: 'auto',
height: '100vh'
},
menuItems: {
fontSize: '12px',
Expand All @@ -29,10 +33,9 @@ const useStyles = makeStyles(() => ({
closeButton: {
marginRight: '10px',
marginTop: '10px',
position: 'absolute',
float: 'right',
top: 0,
right: 0,
zIndex: 1
right: 0
},
searchInputField: {
float: 'right'
Expand Down
48 changes: 29 additions & 19 deletions src/Service.Host/client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AppContainer } from 'react-hot-loader';
import { SnackbarProvider } from 'notistack';
import { linnTheme } from '@linn-it/linn-form-components-library';
import { ThemeProvider } from '@material-ui/styles';
import { loadUser } from 'redux-oidc';
import configureStore from './configureStore';
import Root from './components/Root';
import userManager from './helpers/userManager';
Expand All @@ -14,7 +15,6 @@ const NextRoot = require('./components/Root').default;

const initialState = {};
const store = configureStore(initialState);
const { user } = store.getState().oidc;

const render = Component => {
ReactDOM.render(
Expand All @@ -29,22 +29,32 @@ const render = Component => {
);
};

if (
(!user || user.expired) &&
window.location.pathname !== '/inventory/auth/' &&
window.location.pathname !== '/inventory/auth/logged-out'
) {
userManager.signinRedirect({
data: { redirect: window.location.pathname + window.location.search }
});
} else {
render(Root);
loadUser(store, userManager);

userManager
.getUser()
.then(user => {
if (
(!user || user.expired) &&
window.location.pathname !== '/inventory/auth/' &&
window.location.pathname !== '/inventory/auth/logged-out'
) {
userManager.signinRedirect({
data: { redirect: window.location.pathname + window.location.search }
});
} else {
render(Root);

// Hot Module Replacement API
if (module.hot) {
//module.hot.accept('./reducers', () => store.replaceReducer(reducer));
module.hot.accept('./components/Root', () => {
render(NextRoot);
});
}
}
// Hot Module Replacement API
if (module.hot) {
//module.hot.accept('./reducers', () => store.replaceReducer(reducer));
module.hot.accept('./components/Root', () => {
render(NextRoot);
});
}
}
})
.catch(error => {
console.error('Error loading user:', error);
render(Root);
});
13 changes: 7 additions & 6 deletions src/Service.Host/client/src/middleware/authorization.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { RSAA } from 'redux-api-middleware';
import { getAccessToken } from '../selectors/getAccessToken';
import { addressesActionTypes as actionTypes } from '../actions/index';
import { addressesActionTypes } from '../actions';

export default ({ getState }) => next => action => {
console.log(action[RSAA]?.types);
console.log(addressesActionTypes.REQUEST_SEARCH_ADDRESSES);
if (action[RSAA]) {
if (action[RSAA].options
&& action[RSAA].options.requiresAuth
&& !action[RSAA]?.types?.some(t => t.type === addressesActionTypes.REQUEST_SEARCH_ADDRESSES)) {
if (
action[RSAA].options &&
action[RSAA].options.requiresAuth &&
!action[RSAA]?.types?.some(
t => t.type === addressesActionTypes.REQUEST_SEARCH_ADDRESSES
)
) {
// eslint-disable-next-line no-param-reassign
action[RSAA].headers = {
Authorization: `Bearer ${getAccessToken(getState())}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
namespace Linn.Stores.Domain.LinnApps.Tests.GoodsInServiceTests
{
using System;
using System.Linq.Expressions;

using Linn.Common.Domain.LinnApps.RemoteServices;
using Linn.Common.Persistence;
using Linn.Stores.Domain.LinnApps.ExternalServices;
using Linn.Stores.Domain.LinnApps.GoodsIn;
using Linn.Stores.Domain.LinnApps.Requisitions;

using Linn.Stores.Domain.LinnApps.StockLocators;
using NSubstitute;

using NUnit.Framework;
using System;
using System.Linq.Expressions;

public class ContextBase
{
Expand Down Expand Up @@ -43,6 +41,8 @@ public class ContextBase

protected IPrintRsnService PrintRsnService { get; private set; }

protected IRepository<StorageLocation, int> StorageLocationRepository { get; private set; }

[SetUp]
public void SetUpContext()
{
Expand All @@ -61,7 +61,8 @@ public void SetUpContext()
this.PrintRsnService = Substitute.For<IPrintRsnService>();
this.StoragePlaceRepository.FindBy(Arg.Any<Expression<Func<StoragePlace, bool>>>())
.Returns(new StoragePlace());

this.StorageLocationRepository = Substitute.For<IRepository<StorageLocation, int>>();

this.Sut = new GoodsInService(
this.GoodsInPack,
this.StoresPack,
Expand All @@ -75,7 +76,8 @@ public void SetUpContext()
this.PurchaseOrderRepository,
this.AuthUserRepository,
this.PrintRsnService,
this.StoragePlaceRepository);
this.StoragePlaceRepository,
this.StorageLocationRepository);
}
}
}
Loading