Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5475-email_2fa
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
c6bee8f2f9
|
@ -2844,7 +2844,8 @@ INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk
|
|||
|
||||
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
|
||||
VALUES
|
||||
(1, 12);
|
||||
(1, 12),
|
||||
(8, 10);
|
||||
|
||||
INSERT INTO `vn`.`deviceProductionModels` (`code`)
|
||||
VALUES
|
||||
|
|
|
@ -298,6 +298,7 @@
|
|||
"Ticket is already signed": "Este ticket ya ha sido firmado",
|
||||
"Authentication failed": "Autenticación fallida",
|
||||
"You can't use the same password": "No puedes usar la misma contraseña",
|
||||
"You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono",
|
||||
"Fecha fuera de rango": "Fecha fuera de rango",
|
||||
"Error while generating PDF": "Error al generar PDF",
|
||||
"Error when sending mail to client": "Error al enviar el correo al cliente",
|
||||
|
|
|
@ -282,7 +282,7 @@ module.exports = Self => {
|
|||
await Self.changeCredit(ctx, finalState, changes);
|
||||
|
||||
// Credit management changes
|
||||
if (orgData?.rating != changes.rating || orgData?.recommendedCredit != changes.recommendedCredit)
|
||||
if (changes?.rating || changes?.recommendedCredit)
|
||||
await Self.changeCreditManagement(ctx, finalState, changes);
|
||||
|
||||
const oldInstance = {};
|
||||
|
|
|
@ -110,4 +110,53 @@ describe('sale updateQuantity()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error if the quantity is negative and it is not a refund ticket', async() => {
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 1},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const saleId = 17;
|
||||
const newQuantity = -10;
|
||||
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toEqual(new Error('You can only add negative amounts in refund tickets'));
|
||||
});
|
||||
|
||||
it('should update a negative quantity when is a ticket refund', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
const saleId = 13;
|
||||
const newQuantity = -10;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
||||
|
||||
const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options);
|
||||
|
||||
expect(modifiedLine.quantity).toEqual(newQuantity);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -68,6 +68,13 @@ module.exports = Self => {
|
|||
if (newQuantity > sale.quantity && !isRoleAdvanced)
|
||||
throw new UserError('The new quantity should be smaller than the old one');
|
||||
|
||||
const ticketRefund = await models.TicketRefund.findOne({
|
||||
where: {refundTicketFk: sale.ticketFk},
|
||||
fields: ['id']}
|
||||
, myOptions);
|
||||
if (newQuantity < 0 && !ticketRefund)
|
||||
throw new UserError('You can only add negative amounts in refund tickets');
|
||||
|
||||
const oldQuantity = sale.quantity;
|
||||
const result = await sale.updateAttributes({quantity: newQuantity}, myOptions);
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
data="absenceTypes"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<div class="vn-w-lg">
|
||||
<div ng-if="$ctrl.worker.hasWorkCenter">
|
||||
<div class="vn-w-lg">
|
||||
<vn-card class="vn-pa-sm calendars">
|
||||
<vn-icon ng-if="::$ctrl.isSubordinate" icon="info" color-marginal
|
||||
vn-tooltip="To start adding absences, click an absence type from the right menu and then on the day you want to add an absence">
|
||||
|
@ -19,11 +20,18 @@
|
|||
on-selection="$ctrl.onSelection($event, $days)">
|
||||
</vn-calendar>
|
||||
</vn-card>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
ng-if="!$ctrl.worker.hasWorkCenter"
|
||||
class="bg-title"
|
||||
translate>
|
||||
Autonomous worker
|
||||
</div>
|
||||
<vn-side-menu side="right">
|
||||
<div class="vn-pa-md">
|
||||
<div class="totalBox vn-mb-sm" style="text-align: center;">
|
||||
<h6>{{'Contract' | translate}} #{{$ctrl.businessId}}</h6>
|
||||
<h6>{{'Contract' | translate}} #{{$ctrl.card.worker.hasWorkCenter}}</h6>
|
||||
<div>
|
||||
{{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}}
|
||||
{{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}}
|
||||
|
@ -63,7 +71,6 @@
|
|||
ng-model="$ctrl.businessId"
|
||||
search-function="{businessFk: $search}"
|
||||
value-field="businessFk"
|
||||
show-field="businessFk"
|
||||
order="businessFk DESC"
|
||||
limit="5">
|
||||
<tpl-item>
|
||||
|
@ -103,3 +110,4 @@
|
|||
message="This item will be deleted"
|
||||
question="Are you sure you want to continue?">
|
||||
</vn-confirm>
|
||||
|
||||
|
|
|
@ -64,8 +64,7 @@ class Controller extends Section {
|
|||
|
||||
set worker(value) {
|
||||
this._worker = value;
|
||||
|
||||
if (value) {
|
||||
if (value && value.hasWorkCenter) {
|
||||
this.getIsSubordinate();
|
||||
this.getActiveContract();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ describe('Worker', () => {
|
|||
let yesterday = new Date(today.getTime());
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
controller.worker = {id: 1107};
|
||||
controller.worker = {id: 1107, hasWorkCenter: true};
|
||||
|
||||
expect(controller.getIsSubordinate).toHaveBeenCalledWith();
|
||||
expect(controller.getActiveContract).toHaveBeenCalledWith();
|
||||
|
|
|
@ -12,3 +12,4 @@ To start adding absences, click an absence type from the right menu and then on
|
|||
You can just add absences within the current year: Solo puedes añadir ausencias dentro del año actual
|
||||
Current day: Día actual
|
||||
Paid holidays: Vacaciones pagadas
|
||||
Autonomous worker: Trabajador autónomo
|
||||
|
|
|
@ -34,6 +34,10 @@ class Controller extends ModuleCard {
|
|||
|
||||
this.$http.get(`Workers/${this.$params.id}`, {filter})
|
||||
.then(res => this.worker = res.data);
|
||||
this.$http.get(`Workers/${this.$params.id}/activeContract`)
|
||||
.then(res => {
|
||||
if (res.data) this.worker.hasWorkCenter = res.data.workCenterFk;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
filter="::$ctrl.filter"
|
||||
data="$ctrl.hours">
|
||||
</vn-crud-model>
|
||||
<vn-card class="vn-pa-lg vn-w-lg">
|
||||
<div ng-if="$ctrl.worker.hasWorkCenter">
|
||||
<vn-card class="vn-pa-lg vn-w-lg">
|
||||
<vn-table model="model" auto-load="false">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
|
@ -76,9 +77,9 @@
|
|||
</vn-tr>
|
||||
</vn-tfoot>
|
||||
</vn-table>
|
||||
</vn-card>
|
||||
</vn-card>
|
||||
|
||||
<vn-button-bar ng-show="$ctrl.state" class="vn-w-lg">
|
||||
<vn-button-bar ng-show="$ctrl.state" class="vn-w-lg">
|
||||
<vn-button
|
||||
label="Satisfied"
|
||||
disabled="$ctrl.state == 'CONFIRMED'"
|
||||
|
@ -103,7 +104,14 @@
|
|||
vn-tooltip="Resend email of this week to the user"
|
||||
ng-show="::$ctrl.isHr">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</vn-button-bar>
|
||||
</div>
|
||||
<div
|
||||
ng-if="!$ctrl.worker.hasWorkCenter"
|
||||
class="bg-title"
|
||||
translate>
|
||||
Autonomous worker
|
||||
</div>
|
||||
|
||||
<vn-side-menu side="right">
|
||||
<div class="vn-pa-md">
|
||||
|
|
|
@ -151,6 +151,7 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
getAbsences() {
|
||||
if (!this.worker.hasWorkerCenter) return;
|
||||
const fullYear = this.started.getFullYear();
|
||||
let params = {
|
||||
workerFk: this.$params.id,
|
||||
|
|
|
@ -16,6 +16,10 @@ describe('Component vnWorkerTimeControl', () => {
|
|||
$scope = $rootScope.$new();
|
||||
$element = angular.element('<vn-worker-time-control></vn-worker-time-control>');
|
||||
controller = $componentController('vnWorkerTimeControl', {$element, $scope});
|
||||
controller.worker = {
|
||||
hasWorkerCenter: true
|
||||
|
||||
};
|
||||
}));
|
||||
|
||||
describe('date() setter', () => {
|
||||
|
|
Loading…
Reference in New Issue