Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javi Gallego 2023-09-14 10:27:03 +02:00
commit eff0975eb2
12 changed files with 135 additions and 71 deletions

View File

@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2338.01] - 2023-09-21
### Added
- (Ticket -> Servicios) Se pueden abonar servicios
### Changed
- (Trabajadores -> Calendario) Icono de check arreglado cuando pulsas un tipo de dia

View File

@ -1,4 +1,4 @@
INSERT INTO `account`.`role` (`id`, `name`, `description`, `hasLogin`)
INSERT INTO `account`.`role` (`name`, `description`, `hasLogin`)
VALUES ('claimViewer','Trabajadores que consulta las reclamaciones ',1);
INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`)
@ -10,7 +10,7 @@ INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`)
'buyer',
'deliveryBoss',
'handmadeBoss'
)
);
DELETE FROM `salix`.`ACL`
WHERE `model`= 'claim'
@ -29,4 +29,3 @@ INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`princip
VALUES ('Claim','findById','READ','ALLOW','ROLE','claimViewer');
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`)
VALUES ('Claim','getSummary','READ','ALLOW','ROLE','claimViewer');

View File

@ -671,8 +671,8 @@ export default {
firstAddServiceTypeButton: 'vn-ticket-service vn-icon-button[vn-tooltip="New service type"]',
firstServiceType: 'vn-ticket-service vn-autocomplete[ng-model="service.ticketServiceTypeFk"]',
firstQuantity: 'vn-ticket-service vn-input-number[ng-model="service.quantity"]',
firstPrice: 'vn-ticket-service vn-horizontal:nth-child(1) vn-input-number[ng-model="service.price"]',
fistDeleteServiceButton: 'vn-ticket-service form vn-horizontal:nth-child(1) vn-icon-button[icon="delete"]',
firstPrice: 'vn-ticket-service vn-horizontal:nth-child(2) vn-input-number[ng-model="service.price"]',
fistDeleteServiceButton: 'vn-ticket-service form vn-horizontal:nth-child(2) vn-icon-button[icon="delete"]',
newServiceTypeName: '.vn-dialog.shown vn-textfield[ng-model="newServiceType.name"]',
serviceLine: 'vn-ticket-service > form > vn-card > vn-one:nth-child(2) > vn-horizontal',
saveServiceButton: 'button[type=submit]',

View File

@ -5,6 +5,10 @@ export const validators = {
if (validator.isEmpty(value ? String(value) : ''))
throw new Error(_($translate, `Value can't be empty`));
},
negative: $translate => {
if (validator < 0)
throw new Error(_($translate, `Negative numbers are not allowed. Please enter a valid number.`));
},
absence: ($translate, value) => {
if (!validator.isEmpty(value))
throw new Error(_($translate, `Value should be empty`));
@ -104,9 +108,8 @@ export function checkNull($translate, value, conf) {
export function _($translate, text, params = []) {
text = $translate.instant(text);
for (let i = 0; i < params.length; i++) {
for (let i = 0; i < params.length; i++)
text = text.replace('%s', params[i]);
}
return text;
}

View File

@ -16,6 +16,7 @@ Value can't be empty: El valor no puede estar vacío
Value should be empty: El valor debe estar vacío
Value should be integer: El valor debe ser entero
Value should be a number: El valor debe ser numérico
Negative numbers are not allowed. Please enter a valid number: No se permiten números negativos. Por favor, ingrese un número válido
Invalid value: Valor incorrecto
Value can't be blank: El valor no puede estar en blanco
Value can't be null: El valor no puede ser nulo

View File

@ -5,8 +5,7 @@ module.exports = Self => {
accepts: [
{
arg: 'salesIds',
type: ['number'],
required: true
type: ['number']
},
{
arg: 'servicesIds',
@ -41,6 +40,7 @@ module.exports = Self => {
myOptions.transaction = tx;
}
let refundTicket = null;
try {
const refundAgencyMode = await models.AgencyMode.findOne({
include: {
@ -55,6 +55,7 @@ module.exports = Self => {
const refoundZoneId = refundAgencyMode.zones()[0].id;
if (salesIds) {
const salesFilter = {
where: {id: {inq: salesIds}},
include: {
@ -67,14 +68,11 @@ module.exports = Self => {
const sales = await models.Sale.find(salesFilter, myOptions);
const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))];
let [firstTicketId] = ticketsIds;
if (!firstTicketId) {
[ticketServices] = await models.TicketService.find({where: {id: {inq: servicesIds}}}, myOptions);
firstTicketId = ticketServices.ticketFk;
}
const now = Date.vnNew();
const [firstTicketId] = ticketsIds;
const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions);
// eslint-disable-next-line max-len
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions);
for (const sale of sales) {
const createdSale = await models.Sale.create({
@ -92,6 +90,21 @@ module.exports = Self => {
await models.SaleComponent.create(components, myOptions);
}
}
if (!refundTicket) {
const servicesFilter = {
where: {id: {inq: servicesIds}}
};
const services = await models.TicketService.find(servicesFilter, myOptions);
const ticketsIds = [...new Set(services.map(service => service.ticketFk))];
const now = Date.vnNew();
const [firstTicketId] = ticketsIds;
// eslint-disable-next-line max-len
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions);
}
if (servicesIds && servicesIds.length > 0) {
const servicesFilter = {
@ -101,8 +114,8 @@ module.exports = Self => {
for (const service of services) {
await models.TicketService.create({
description: service.description,
quantity: - service.quantity,
price: service.price,
quantity: service.quantity,
price: - service.price,
taxClassFk: service.taxClassFk,
ticketFk: refundTicket.id,
ticketServiceTypeFk: service.ticketServiceTypeFk,

View File

@ -24,7 +24,21 @@
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-horizontal ng-repeat="service in $ctrl.services track by $index">
<vn-button-bar>
<vn-button
disabled="watcher.dataChanged() || !$ctrl.checkeds.length"
label="Pay"
ng-click="$ctrl.createRefund()"
vn-acl="invoicing, claimManager, salesAssistant"
vn-acl-action="remove">
</vn-button>
</vn-button-bar>
<vn-horizontal ng-repeat="service in $ctrl.services">
<vn-check
tabindex="1"
on-change="$ctrl.addChecked(service.id)"
disabled="!service.id">
</vn-check>
<vn-autocomplete vn-two vn-focus
data="ticketServiceTypes"
label="Description"
@ -45,8 +59,10 @@
vn-one
step="1"
label="Quantity"
info="To create services with negative amounts mark the service on the source ticket and press the pay button."
ng-model="service.quantity"
rule="TicketService">
rule="TicketService"
min="0">
</vn-input-number>
<vn-input-number
vn-one
@ -76,13 +92,6 @@
disabled="!watcher.dataChanged()"
label="Save">
</vn-submit>
<!-- # #2680 Undo changes button bugs -->
<!-- <vn-button
class="cancel"
label="Undo changes"
disabled="!watcher.dataChanged()"
ng-click="watcher.loadOriginalData()">
</vn-button> -->
</vn-button-bar>
</form>

View File

@ -6,6 +6,8 @@ class Controller extends Section {
$onInit() {
this.services = [];
this.getDefaultTaxClass();
this.isDataSaved = false;
this.checkeds = [];
}
getDefaultTaxClass() {
@ -49,6 +51,26 @@ class Controller extends Section {
.then(() => this.$.model.refresh())
.then(() => this.$.watcher.notifySaved());
}
createRefund() {
if (!this.checkeds.length) return;
const params = {servicesIds: this.checkeds, withWarehouse: false};
const query = 'Sales/refund';
this.$http.post(query, params).then(res => {
const refundTicket = res.data;
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
ticketId: refundTicket.id
}));
this.$state.go('ticket.card.sale', {id: refundTicket.id});
});
}
addChecked(id) {
if (this.checkeds.includes(id))
return this.checkeds = this.checkeds.filter(check => check != id);
this.checkeds.push(id);
}
}
ngModule.vnComponent('vnTicketService', {

View File

@ -19,11 +19,10 @@ describe('Ticket component vnTicketService', () => {
describe('getDefaultTaxClass', () => {
it('should set the default tax class in the controller', () => {
$httpBackend.whenRoute('GET', `TaxClasses/findOne`)
.respond({
$httpBackend.whenRoute('GET', `TaxClasses/findOne`).respond({
id: 4000,
name: 'Whatever',
code: 'GG'
code: 'GG',
});
controller.getDefaultTaxClass();
$httpBackend.flush();
@ -49,15 +48,15 @@ describe('Ticket component vnTicketService', () => {
it('should set the description of the selected service upon service type creation', () => {
const service = {
id: 1,
quantity: 10
quantity: 10,
};
$scope.newServiceType = {
name: 'Totally new stuff'
name: 'Totally new stuff',
};
$httpBackend.when('POST', 'TicketServiceTypes').respond({
id: 4001,
name: 'Totally new stuff'
name: 'Totally new stuff',
});
controller.onNewServiceTypeAccept(service);
$httpBackend.flush();
@ -65,4 +64,20 @@ describe('Ticket component vnTicketService', () => {
expect(service.ticketServiceTypeFk).toEqual(4001);
});
});
describe('addChecked', () => {
it('should add an item to the checkeds array', () => {
controller.checkeds = [];
controller.addChecked(1);
expect(controller.checkeds).toEqual([1]);
});
it('should remove an item if it is already in the checkeds array', () => {
controller.checkeds = [1, 2, 3];
controller.addChecked(2);
expect(controller.checkeds).toEqual([1, 3]);
});
});
});

View File

@ -3,3 +3,5 @@ Tax class: Tipo IVA
Add service: Añadir servicio
Remove service: Quitar servicio
New service type: Nuevo tipo de servicio
Pay: Abonar
To create services with negative amounts mark the service on the source ticket and press the pay button.: Para crear sevicios con cantidades negativas marcar servicio en el ticket origen y apretar el boton abonar.

View File

@ -8,8 +8,8 @@ description:
<a href='https://www.youtube.com/watch?v=qhb0kgQF3o8' title='Youtube' target='_blank'
style='color:#8dba25'>https://www.youtube.com/watch?v=qhb0kgQF3o8</a>. También
necesitarás el GoLabel, el programa para imprimir las cintas.
downloadFrom: Puedes descargarlo desde este enlace <a href='https://godex.s3-accelerate.amazonaws.com/_6f5glRrVhQAEBGhdUsqJA.file?v01'
title='Descargar GoLabel' target='_blank' style='color:#8dba25'>https://godex.s3-accelerate.amazonaws.com/_6f5glRrVhQAEBGhdUsqJA.file?v01</a>
downloadFrom: Puedes descargarlo desde este enlace <a href='https://cdn.verdnatura.es/public/GoLabel.zip'
title='Descargar GoLabel' target='_blank' style='color:#8dba25'>https://cdn.verdnatura.es/public/GoLabel.zip</a>
downloadDriver: En este enlace puedes descargar el driver de la impresora <a href='https://es.seagullscientific.com/support/downloads/drivers/godex/download/'
title='Descargar driver' target='_blank' style='color:#8dba25'>https://es.seagullscientific.com/support/downloads/drivers/godex/download/</a>
sections: