3520_wareshouse_back #2218

Merged
alexm merged 11 commits from 3520_wareshouse_back into dev 2024-03-28 07:16:57 +00:00
12 changed files with 51 additions and 209 deletions
Showing only changes of commit 4ca3e8f650 - Show all commits

View File

@ -23,15 +23,16 @@ export default class Controller extends Section {
}
openPdf() {
const access_token = this.vnToken.tokenMultimedia;
if (this.checked.length <= 1) {
const [invoiceOutId] = this.checked;
const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${this.vnToken.tokenMultimedia}`;
const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${access_token}`;
window.open(url, '_blank');
} else {
const invoiceOutIds = this.checked;
const invoicesIds = invoiceOutIds.join(',');
const serializedParams = this.$httpParamSerializer({
access_token: this.vnToken.token,
access_token,
ids: invoicesIds
});
const url = `api/InvoiceOuts/downloadZip?${serializedParams}`;

View File

@ -20,7 +20,6 @@ import './botanical';
import './barcode';
import './summary';
import './waste/index/';
import './waste/detail';
import './fixed-price';
import './fixed-price-search-panel';
import './item-type';

View File

@ -1,43 +0,0 @@
<vn-crud-model auto-load="true"
vn-id="model"
url="Items/getWasteByItem"
params="$ctrl.$params"
data="details">
</vn-crud-model>
<vn-data-viewer model="model">
<vn-card class="vn-w-md">
<section ng-repeat="detail in details" class="vn-pa-md">
<vn-horizontal class="header">
<h5>{{detail.family}} ({{detail.buyer}})</h5>
</vn-horizontal>
<vn-table>
<vn-thead>
<vn-tr>
<vn-th shrink>Item</vn-th>
<vn-th number>Percentage</vn-th>
<vn-th number>Dwindle</vn-th>
<vn-th number>Total</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="waste in detail.lines">
<vn-td shrink>
<span
ng-click="itemDescriptor.show($event, waste.itemFk)"
class="link">
{{::waste.itemFk}}
</span>
</vn-td>
<vn-td number>{{::(waste.percentage / 100) | percentage: 2}}</vn-td>
<vn-td number>{{::waste.dwindle | currency: 'EUR'}}</vn-td>
<vn-td number>{{::waste.total | currency: 'EUR'}}</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</section>
</vn-card>
</vn-data-viewer>
<vn-item-descriptor-popover
vn-id="item-descriptor"
warehouse-fk="$ctrl.vnConfig.warehouseFk">
</vn-item-descriptor-popover>

View File

@ -1,7 +0,0 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
ngModule.vnComponent('vnItemWasteDetail', {
template: require('./index.html'),
controller: Section
});

View File

@ -1,25 +0,0 @@
@import "variables";
vn-item-waste {
.header {
margin-bottom: 16px;
text-transform: uppercase;
font-size: 1.25rem;
line-height: 1;
padding: 7px;
padding-bottom: 7px;
padding-bottom: 4px;
font-weight: lighter;
background-color: #fde6ca;
border-bottom: 1px solid #f7931e;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
vn-table vn-th.waste-family,
vn-table vn-td.waste-family {
max-width: 64px;
width: 64px
}
}

View File

@ -1,49 +1,2 @@
<vn-crud-model auto-load="true"
vn-id="model"
url="Items/getWasteByWorker"
data="details">
</vn-crud-model>
<vn-data-viewer model="model">
<vn-card>
<vn-table>
<vn-thead>
<vn-tr class="header">
<vn-th class="waste-family">Buyer</vn-th>
<vn-th class="waste-family">Family</vn-th>
<vn-th number>Percentage</vn-th>
<vn-th number>Dwindle</vn-th>
<vn-th number>Total</vn-th>
<vn-th shrink></vn-th>
</vn-tr>
</vn-thead>
<vn-tbody ng-repeat="detail in details" class="vn-mb-md">
<vn-tr class="header">
<vn-td>{{::detail.buyer}}</vn-td>
<vn-td>{{::detail.family}}</vn-td>
<vn-td number>{{::(detail.percentage / 100) | percentage: 2}}</vn-td>
<vn-td number>{{::detail.dwindle | currency: 'EUR'}}</vn-td>
<vn-td number>{{::detail.total | currency: 'EUR'}}</vn-td>
<vn-td shrink>
<vn-icon-button
ng-class="{'hidden': !$ctrl.wasteConfig[detail.buyer].hidden}"
class="arrow pointer"
icon="keyboard_arrow_up"
vn-tooltip="Minimize/Maximize"
ng-click="$ctrl.toggleHidePanel(detail)">
</vn-icon-button>
</vn-td>
</vn-tr>
<a ng-repeat="waste in detail.lines" class="clickable vn-tr"
ui-sref="item.waste.detail({buyer: waste.buyer, family: waste.family})"
ng-show="$ctrl.wasteConfig[detail.buyer].hidden">
<vn-td></vn-td>
<vn-td>{{::waste.family}}</vn-td>
<vn-td number>{{::(waste.percentage / 100) | percentage: 2}}</vn-td>
<vn-td number>{{::waste.dwindle | currency: 'EUR'}}</vn-td>
<vn-td number>{{::waste.total | currency: 'EUR'}}</vn-td>
<vn-td shrink></vn-td>
</a>
</vn-tbody>
</vn-table>
</vn-card>
</vn-data-viewer>

View File

@ -5,27 +5,11 @@ import './style.scss';
export default class Controller extends Section {
constructor($element, $) {
super($element, $);
this.getWasteConfig();
}
getWasteConfig() {
return this.wasteConfig = JSON.parse(localStorage.getItem('wasteConfig')) || {};
}
setWasteConfig() {
localStorage.setItem('wasteConfig', JSON.stringify(this.wasteConfig));
}
toggleHidePanel(detail) {
if (!this.wasteConfig[detail.buyer]) {
this.wasteConfig[detail.buyer] = {
hidden: true
};
} else
this.wasteConfig[detail.buyer].hidden = !this.wasteConfig[detail.buyer].hidden;
this.setWasteConfig();
async $onInit() {
this.$state.go('item.index');
window.location.href = 'https://grafana.verdnatura.es/d/TTNXQAxVk';
}
}

View File

@ -1,53 +0,0 @@
import './index.js';
import crudModel from 'core/mocks/crud-model';
describe('Item', () => {
describe('Component vnItemWasteIndex', () => {
let $scope;
let controller;
beforeEach(ngModule('item'));
beforeEach(inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
$scope.model = crudModel;
const $element = angular.element('<vn-item-waste-index></vn-item-waste-index>');
controller = $componentController('vnItemWasteIndex', {$element, $scope});
}));
describe('getWasteConfig / setWasteConfig', () => {
it('should return the local storage wasteConfig', () => {
const result = controller.getWasteConfig();
expect(result).toEqual({});
});
it('should set and return the local storage wasteConfig', () => {
controller.wasteConfig = {salesPerson: {hidden: true}};
controller.setWasteConfig();
const result = controller.getWasteConfig();
expect(result).toEqual(controller.wasteConfig);
});
});
describe('toggleHidePanel()', () => {
it('should make details hidden by default', () => {
controller.wasteConfig = {};
controller.toggleHidePanel({buyer: 'salesPerson'});
expect(controller.wasteConfig.salesPerson.hidden).toEqual(true);
});
it('should toggle hidden false', () => {
controller.wasteConfig = {salesPerson: {hidden: true}};
controller.toggleHidePanel({buyer: 'salesPerson'});
expect(controller.wasteConfig.salesPerson.hidden).toEqual(false);
});
});
});
});

View File

@ -35,16 +35,18 @@ export default class Controller extends Section {
showRouteReport() {
const routesIds = [];
const access_token = this.vnToken.tokenMultimedia;
for (let route of this.checked)
routesIds.push(route.id);
const stringRoutesIds = routesIds.join(',');
if (this.checked.length <= 1) {
const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.tokenMultimedia}`;
const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${access_token}`;
window.open(url, '_blank');
} else {
const serializedParams = this.$httpParamSerializer({
access_token: this.vnToken.token,
access_token,
id: stringRoutesIds
});
const url = `api/Routes/downloadZip?${serializedParams}`;

View File

@ -71,6 +71,34 @@ describe('workerTimeControl clockIn()', () => {
}
});
it('should updates the time entry direction and remaining not be manual', async() => {
activeCtx.accessToken.userId = HHRRId;
const workerId = teamBossId;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
const entryTime = "2000-12-25T11:00:00.000Z";
ctx.args = {timed: entryTime, direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
const middleTime ="2000-12-25T16:00:00.000Z";
ctx.args = {timed: middleTime, direction: 'middle'};
const middleEntryTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
middleEntryTime.updateAttribute('manual', false);
const direction = 'out';
const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry(ctx, middleEntryTime.id, direction, options);
const outTimeEntry = await models.WorkerTimeControl.findById(outTimeEntryId, null, options);
expect(outTimeEntry.manual).toBeFalsy();
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
describe('as Role errors', () => {
it('should add if the current user is team boss and the target user is himself', async() => {
activeCtx.accessToken.userId = teamBossId;
@ -144,7 +172,7 @@ describe('workerTimeControl clockIn()', () => {
const middleTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
const direction = 'out';
const {id:outTimeEntryId} = await models.WorkerTimeControl.updateTimeEntry(
const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry(
ctx, middleTime.id, direction, options
);

View File

@ -29,7 +29,7 @@ module.exports = Self => {
Self.updateTimeEntry = async(ctx, timeEntryId, direction, options) => {
const currentUserId = ctx.req.accessToken.userId;
const models = Self.app.models;
const myOptions = {};
const myOptions = {userId: currentUserId};
let tx;
if (typeof options == 'object')
@ -41,7 +41,7 @@ module.exports = Self => {
}
try {
const {id, userFk, timed} = await Self.findById(timeEntryId, null, myOptions);
const {id, userFk, timed, manual} = await Self.findById(timeEntryId, null, myOptions);
const isSubordinate = await models.Worker.isSubordinate(ctx, userFk, myOptions);
const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE');
const isHimself = currentUserId == userFk;
@ -50,12 +50,15 @@ module.exports = Self => {
if (notAllowed) throw new UserError(`You don't have enough privileges`);
await models.WorkerTimeControl.deleteById(id, myOptions);
const timeEntryUpdatedId = await Self.clockIn(userFk, timed, direction, null, myOptions);
const {id: newTimeEntryId} = await Self.clockIn(
userFk, timed, direction, null, myOptions
);
if (!manual) await Self.updateAll({id: newTimeEntryId}, {manual: false}, myOptions);
await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, userFk, timed, myOptions);
if (tx) await tx.commit();
return timeEntryUpdatedId;
return newTimeEntryId;
} catch (e) {
if (tx) await tx.rollback();
throw e;

View File

@ -28,8 +28,8 @@
</table>
<p v-html="$t('wasteDetailLink')"></p>
<div class="external-link vn-pa-sm vn-m-md">
<a href="https://salix.verdnatura.es/#!/item/waste/index" target="_blank">
https://salix.verdnatura.es/#!/item/waste/index
<a href="https://grafana.verdnatura.es/d/TTNXQAxVk" target="_blank">
https://grafana.verdnatura.es/d/TTNXQAxVk
</a>
</div>
</div>