merge
gitea/salix/test This commit looks good
Details
gitea/salix/test This commit looks good
Details
This commit is contained in:
commit
7f394ed671
|
@ -41,21 +41,10 @@ describe('Ticket Create packages path', () => {
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should attempt create a new package but receive an error if the quantity is invalid`, async() => {
|
|
||||||
const result = await nightmare
|
|
||||||
.write(selectors.ticketPackages.firstQuantityInput, -99)
|
|
||||||
.waitToClick(selectors.ticketPackages.savePackagesButton)
|
|
||||||
.evaluate(selector => {
|
|
||||||
return document.querySelector(selector).checkValidity();
|
|
||||||
}, selectors.ticketPackages.firstQuantityInput);
|
|
||||||
|
|
||||||
expect(result).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should create a new package with correct data`, async() => {
|
it(`should create a new package with correct data`, async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.clearInput(selectors.ticketPackages.firstQuantityInput)
|
.clearInput(selectors.ticketPackages.firstQuantityInput)
|
||||||
.write(selectors.ticketPackages.firstQuantityInput, 99)
|
.write(selectors.ticketPackages.firstQuantityInput, -99)
|
||||||
.waitToClick(selectors.ticketPackages.savePackagesButton)
|
.waitToClick(selectors.ticketPackages.savePackagesButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
|
@ -73,9 +62,9 @@ describe('Ticket Create packages path', () => {
|
||||||
|
|
||||||
it(`should confirm the first quantity is just a number and the string part was ignored by the imput number`, async() => {
|
it(`should confirm the first quantity is just a number and the string part was ignored by the imput number`, async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99')
|
.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '-99')
|
||||||
.waitToGetProperty(selectors.ticketPackages.firstQuantityInput, 'value');
|
.waitToGetProperty(selectors.ticketPackages.firstQuantityInput, 'value');
|
||||||
|
|
||||||
expect(result).toEqual('99');
|
expect(result).toEqual('-99');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -67,7 +67,6 @@
|
||||||
"Tag value cannot be blank": "El valor del tag no puede quedar en blanco",
|
"Tag value cannot be blank": "El valor del tag no puede quedar en blanco",
|
||||||
"ORDER_EMPTY": "Cesta vacía",
|
"ORDER_EMPTY": "Cesta vacía",
|
||||||
"You don't have enough privileges to do that": "No tienes permisos para cambiar esto",
|
"You don't have enough privileges to do that": "No tienes permisos para cambiar esto",
|
||||||
"You can't create a ticket for a client that has a debt": "No puedes crear un ticket para un client con deuda",
|
|
||||||
"NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT",
|
"NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT",
|
||||||
"Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido",
|
"Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido",
|
||||||
"Street cannot be empty": "Dirección no puede estar en blanco",
|
"Street cannot be empty": "Dirección no puede estar en blanco",
|
||||||
|
|
|
@ -70,14 +70,16 @@ module.exports = Self => {
|
||||||
discount: 100
|
discount: 100
|
||||||
}, {transaction: transaction});
|
}, {transaction: transaction});
|
||||||
|
|
||||||
await sendMessage(ctx, {
|
if (sale.ticket().client().salesPerson()) {
|
||||||
itemFk: sale.itemFk,
|
await sendMessage(ctx, {
|
||||||
ticketFk: sale.ticketFk,
|
itemFk: sale.itemFk,
|
||||||
recipientFk: sale.item().itemType().worker().userFk,
|
ticketFk: sale.ticketFk,
|
||||||
quantity: sale.quantity,
|
recipientFk: sale.ticket().client().salesPerson().userFk,
|
||||||
concept: sale.concept,
|
quantity: sale.quantity,
|
||||||
nickname: address.nickname
|
concept: sale.concept,
|
||||||
}, transaction);
|
nickname: address.nickname
|
||||||
|
}, transaction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let claim = await Self.findById(params.claimFk);
|
let claim = await Self.findById(params.claimFk);
|
||||||
|
@ -99,23 +101,14 @@ module.exports = Self => {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
relation: 'ticket',
|
relation: 'ticket',
|
||||||
scope: {fields: ['warehouseFk', 'companyFk']}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'item',
|
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['typeFk'],
|
fields: ['clientFk', 'warehouseFk', 'companyFk'],
|
||||||
include: {
|
include: {
|
||||||
relation: 'itemType',
|
relation: 'client',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['workerFk'],
|
|
||||||
include: {
|
include: {
|
||||||
relation: 'worker',
|
relation: 'salesPerson'
|
||||||
scope: {
|
|
||||||
fields: ['id', 'userFk'],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
order="name"
|
order="name"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="field"
|
value-field="field"
|
||||||
label="Order by">
|
label="Order by"
|
||||||
|
disabled="!model.data">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
data="$ctrl.wayList"
|
data="$ctrl.wayList"
|
||||||
|
@ -32,7 +33,8 @@
|
||||||
translate-fields="['name']"
|
translate-fields="['name']"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="way"
|
value-field="way"
|
||||||
label="Order">
|
label="Order"
|
||||||
|
disabled="!model.data">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -74,8 +74,7 @@ class Controller {
|
||||||
set way(value) {
|
set way(value) {
|
||||||
this._way = value;
|
this._way = value;
|
||||||
|
|
||||||
if (value)
|
if (value) this.applyOrder();
|
||||||
this.applyOrder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,8 +87,7 @@ class Controller {
|
||||||
set field(value) {
|
set field(value) {
|
||||||
this._field = value;
|
this._field = value;
|
||||||
|
|
||||||
if (value)
|
if (value) this.applyOrder();
|
||||||
this.applyOrder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Controller {
|
||||||
if (this.tags.length > 0)
|
if (this.tags.length > 0)
|
||||||
this.applyFilters();
|
this.applyFilters();
|
||||||
|
|
||||||
if (value)
|
if (this._category)
|
||||||
this.updateItemTypes();
|
this.updateItemTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ class Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearchById(event) {
|
onSearchById(event) {
|
||||||
if (event.key !== 'Enter' || !this.itemFk) return;
|
if (event.key === 'Enter' && (this.tags.length > 0 || this.itemFk || this.type))
|
||||||
this.applyFilters();
|
this.applyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearchByTag(event) {
|
onSearchByTag(event) {
|
||||||
|
@ -113,7 +113,7 @@ class Controller {
|
||||||
remove(index) {
|
remove(index) {
|
||||||
this.tags.splice(index, 1);
|
this.tags.splice(index, 1);
|
||||||
|
|
||||||
if (this.tags.length == 0 && this.category && this.type)
|
if (this.tags.length >= 0 || this.itemFk || this.type)
|
||||||
this.applyFilters();
|
this.applyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,11 +137,13 @@ describe('Order', () => {
|
||||||
|
|
||||||
describe('remove()', () => {
|
describe('remove()', () => {
|
||||||
it(`should remove a tag from tags property`, () => {
|
it(`should remove a tag from tags property`, () => {
|
||||||
|
spyOn(controller, 'applyFilters');
|
||||||
controller.tags = [{tagFk: 1, value: 'Blue'}, {tagFk: 2, value: '70'}];
|
controller.tags = [{tagFk: 1, value: 'Blue'}, {tagFk: 2, value: '70'}];
|
||||||
controller.remove(0);
|
controller.remove(0);
|
||||||
|
|
||||||
expect(controller.tags.length).toEqual(1);
|
expect(controller.tags.length).toEqual(1);
|
||||||
expect(controller.tags[0].tagFk).toEqual(2);
|
expect(controller.tags[0].tagFk).toEqual(2);
|
||||||
|
expect(controller.applyFilters).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => {
|
it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => {
|
||||||
|
|
|
@ -26,7 +26,6 @@ module.exports = Self => {
|
||||||
throw new UserError(`The value should be a number`);
|
throw new UserError(`The value should be a number`);
|
||||||
|
|
||||||
let model = Self.app.models;
|
let model = Self.app.models;
|
||||||
let thisTicketIsEditable = await model.Ticket.isEditable(params.editLines[0].ticketFk);
|
|
||||||
let ticket = await model.Ticket.find({
|
let ticket = await model.Ticket.find({
|
||||||
where: {
|
where: {
|
||||||
id: params.editLines[0].ticketFk
|
id: params.editLines[0].ticketFk
|
||||||
|
@ -40,13 +39,9 @@ module.exports = Self => {
|
||||||
fields: ['id', 'clientFk', 'refFk']
|
fields: ['id', 'clientFk', 'refFk']
|
||||||
});
|
});
|
||||||
|
|
||||||
let userId = ctx.req.accessToken.userId;
|
if (ticket.refFk)
|
||||||
let isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant');
|
|
||||||
|
|
||||||
if ((!thisTicketIsEditable && !isSalesAssistant) || (ticket.refFk && isSalesAssistant))
|
|
||||||
throw new UserError(`The sales of this ticket can't be modified`);
|
throw new UserError(`The sales of this ticket can't be modified`);
|
||||||
|
|
||||||
|
|
||||||
let componentToUse;
|
let componentToUse;
|
||||||
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'});
|
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'});
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
if (!address.client().isActive)
|
if (!address.client().isActive)
|
||||||
throw new UserError(`You can't create a ticket for a inactive client`);
|
throw new UserError(`You can't create a ticket for a inactive client`);
|
||||||
|
|
||||||
let clientFk = address.clientFk;
|
|
||||||
let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
|
|
||||||
let clientDebt = await Self.rawSql(query, [clientFk]);
|
|
||||||
|
|
||||||
if (address.client().credit - clientDebt[0].debt <= 0)
|
|
||||||
throw new UserError(`You can't create a ticket for a client that has a debt`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!transaction || !transaction.commit)
|
if (!transaction || !transaction.commit)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
field="package.packagingFk">
|
field="package.packagingFk">
|
||||||
<tpl-item>{{itemFk}} : {{name}}</tpl-item>
|
<tpl-item>{{itemFk}} : {{name}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-input-number vn-one min="1" step="1"
|
<vn-input-number vn-one step="1"
|
||||||
label="Quantity"
|
label="Quantity"
|
||||||
model="package.quantity"
|
model="package.quantity"
|
||||||
rule="TicketPackaging.quantity">
|
rule="TicketPackaging.quantity">
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
</a>
|
</a>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
ng-show="sale.visible || sale.available"
|
ng-show="sale.visible < 0 || sale.available < 0"
|
||||||
color-main
|
color-main
|
||||||
icon="warning"
|
icon="warning"
|
||||||
vn-tooltip="Visible: {{::sale.visible || 0}} <br> {{::$ctrl.$translate.instant('Available')}}: {{::sale.available || 0}}">
|
vn-tooltip="Visible: {{::sale.visible || 0}} <br> {{::$ctrl.$translate.instant('Available')}}: {{::sale.available || 0}}">
|
||||||
|
|
|
@ -63,8 +63,8 @@
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
<vn-th number>Item</vn-th>
|
<vn-th number shrink>Item</vn-th>
|
||||||
<vn-th number>Quantity</vn-th>
|
<vn-th number shrink>Quantity</vn-th>
|
||||||
<vn-th>Description</vn-th>
|
<vn-th>Description</vn-th>
|
||||||
<vn-th number>Price</vn-th>
|
<vn-th number>Price</vn-th>
|
||||||
<vn-th number>Discount</vn-th>
|
<vn-th number>Discount</vn-th>
|
||||||
|
@ -89,14 +89,14 @@
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon ng-show="sale.reserved" icon="icon-reserva"></vn-icon>
|
<vn-icon ng-show="sale.reserved" icon="icon-reserva"></vn-icon>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>
|
<vn-td number shrink>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
|
||||||
class="link">
|
class="link">
|
||||||
{{sale.itemFk | zeroFill:6}}
|
{{sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
<vn-td number shrink>{{::sale.quantity}}</vn-td>
|
||||||
<vn-td expand>
|
<vn-td expand>
|
||||||
<vn-fetched-tags
|
<vn-fetched-tags
|
||||||
max-length="6"
|
max-length="6"
|
||||||
|
|
|
@ -40,10 +40,14 @@ class Controller {
|
||||||
const holidays = data.holidays;
|
const holidays = data.holidays;
|
||||||
const events = [];
|
const events = [];
|
||||||
holidays.forEach(holiday => {
|
holidays.forEach(holiday => {
|
||||||
|
const holidayDetail = holiday.detail && holiday.detail.description;
|
||||||
|
const holidayType = holiday.type && holiday.type.name;
|
||||||
|
const holidayName = holidayDetail || holidayType;
|
||||||
|
|
||||||
events.push({
|
events.push({
|
||||||
dated: holiday.dated,
|
dated: holiday.dated,
|
||||||
className: 'red',
|
className: 'red',
|
||||||
title: holiday.detail.description || holiday.type.name,
|
title: holidayName,
|
||||||
isRemovable: false
|
isRemovable: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue