Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 3628-item-historical-absoluto
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
74ba21b1b7
|
@ -39,10 +39,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
- (Usuarios -> Histórico) Nueva sección
|
||||
- (Roles -> Histórico) Nueva sección
|
||||
- (General -> Traducciones) Correo de bienvenida a clientes al portugués y al francés
|
||||
- (Trabajadores -> Dar de alta) Permite elegir el método de pago
|
||||
|
||||
### Changed
|
||||
- (Artículo -> Precio fijado) Modificado el buscador superior por uno lateral
|
||||
- (Trabajadores -> Dar de alta) Quitada obligatoriedad del iban
|
||||
|
||||
### Fixed
|
||||
- (Ticket -> Boxing) Arreglado selección de horas
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
ALTER TABLE `vn`.`workerConfig` ADD payMethodFk tinyint(3) unsigned NULL;
|
||||
ALTER TABLE `vn`.`workerConfig` ADD CONSTRAINT workerConfig_FK FOREIGN KEY (roleFk) REFERENCES account.`role`(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`workerConfig` ADD CONSTRAINT workerConfig_FK_1 FOREIGN KEY (payMethodFk) REFERENCES `vn`.`payMethod`(id) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
-- Cuando se apruebe el PR quitar y poner en redmine para hacerse manualmente
|
||||
UPDATE `vn`.`workerConfig`
|
||||
SET payMethodFk = 4
|
||||
WHERE id=1;
|
|
@ -2824,9 +2824,9 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
|
|||
VALUES
|
||||
(1, 1);
|
||||
|
||||
INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `businessTypeFk`)
|
||||
INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk`, `businessTypeFk`)
|
||||
VALUES
|
||||
(1, NULL, 1, 'worker');
|
||||
(1, NULL, 1, 4, 'worker');
|
||||
|
||||
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
|
||||
VALUES
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
const $ = {
|
||||
saveButton: 'vn-supplier-fiscal-data button[type="submit"]',
|
||||
};
|
||||
const $inputs = {
|
||||
province: 'vn-supplier-fiscal-data [name="province"]',
|
||||
country: 'vn-supplier-fiscal-data [name="country"]',
|
||||
postcode: 'vn-supplier-fiscal-data [name="postcode"]',
|
||||
city: 'vn-supplier-fiscal-data [name="city"]',
|
||||
socialName: 'vn-supplier-fiscal-data [name="socialName"]',
|
||||
taxNumber: 'vn-supplier-fiscal-data [name="taxNumber"]',
|
||||
account: 'vn-supplier-fiscal-data [name="account"]',
|
||||
sageWithholding: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageWithholdingFk"]',
|
||||
sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]'
|
||||
};
|
||||
|
||||
describe('Supplier fiscal data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
|
|
@ -290,5 +290,7 @@
|
|||
"isTaxDataChecked": "Datos comprobados",
|
||||
"comercialId": "Id comercial",
|
||||
"comercialName": "Comercial",
|
||||
"Invalid NIF for VIES": "Invalid NIF for VIES"
|
||||
}
|
||||
"Invalid NIF for VIES": "Invalid NIF for VIES",
|
||||
"Ticket does not exist": "Este ticket no existe",
|
||||
"Ticket is already signed": "Este ticket ya ha sido firmado"
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.saveSign = async(ctx, options) => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
Self.saveSign = async(ctx, tickets, location, signedTime, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
@ -48,9 +47,9 @@ module.exports = Self => {
|
|||
async function setLocation(ticketId) {
|
||||
await models.Delivery.create({
|
||||
ticketFk: ticketId,
|
||||
longitude: args.location.Longitude,
|
||||
latitude: args.location.Latitude,
|
||||
dated: args.signedTime || new Date()
|
||||
longitude: location.Longitude,
|
||||
latitude: location.Latitude,
|
||||
dated: signedTime || new Date()
|
||||
}, myOptions);
|
||||
}
|
||||
|
||||
|
@ -107,9 +106,9 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
for (let i = 0; i < args.tickets.length; i++) {
|
||||
for (const ticketId of tickets) {
|
||||
const ticketState = await models.TicketState.findOne(
|
||||
{where: {ticketFk: args.tickets[i]},
|
||||
{where: {ticketFk: ticketId},
|
||||
fields: ['alertLevel']
|
||||
}, myOptions);
|
||||
|
||||
|
@ -117,16 +116,19 @@ module.exports = Self => {
|
|||
fields: ['id']
|
||||
}, myOptions);
|
||||
|
||||
if (!ticketState)
|
||||
throw new UserError('Ticket does not exist');
|
||||
if (ticketState.alertLevel < packedAlertLevel.id)
|
||||
throw new UserError('This ticket cannot be signed because it has not been boxed');
|
||||
else if (!await gestDocExists(args.tickets[i])) {
|
||||
if (args.location) setLocation(args.tickets[i]);
|
||||
if (!gestDocCreated) await createGestDoc(args.tickets[i]);
|
||||
await models.TicketDms.create({ticketFk: args.tickets[i], dmsFk: dms[0].id}, myOptions);
|
||||
const ticket = await models.Ticket.findById(args.tickets[i], null, myOptions);
|
||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [args.tickets[i], 'DELIVERED'], myOptions);
|
||||
}
|
||||
if (await gestDocExists(ticketId))
|
||||
throw new UserError('Ticket is already signed');
|
||||
|
||||
if (location) setLocation(ticketId);
|
||||
if (!gestDocCreated) await createGestDoc(ticketId);
|
||||
await models.TicketDms.create({ticketFk: ticketId, dmsFk: dms[0].id}, myOptions);
|
||||
const ticket = await models.Ticket.findById(ticketId, null, myOptions);
|
||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, 'DELIVERED'], myOptions);
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -54,18 +54,6 @@ module.exports = Self => {
|
|||
description: `The worker province`,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'iban',
|
||||
type: 'string',
|
||||
description: `The worker iban`,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'bankEntityFk',
|
||||
type: 'number',
|
||||
description: `The worker bank entity`,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'companyFk',
|
||||
type: 'number',
|
||||
|
@ -101,6 +89,22 @@ module.exports = Self => {
|
|||
type: 'date',
|
||||
description: `The worker birth`,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'payMethodFk',
|
||||
type: 'number',
|
||||
description: `The client payMethod`,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'iban',
|
||||
type: 'string',
|
||||
description: `The client iban`,
|
||||
},
|
||||
{
|
||||
arg: 'bankEntityFk',
|
||||
type: 'number',
|
||||
description: `The client bank entity`,
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -162,6 +166,10 @@ module.exports = Self => {
|
|||
myOptions
|
||||
);
|
||||
|
||||
const payMethod = await models.PayMethod.findById(args.payMethodFk, {fields: ['isIbanRequiredForClients']});
|
||||
if (payMethod.isIbanRequiredForClients && !args.iban)
|
||||
throw new UserError(`That payment method requires an IBAN`);
|
||||
|
||||
await models.Worker.rawSql(
|
||||
'CALL vn.clientCreate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
[
|
||||
|
@ -202,6 +210,7 @@ module.exports = Self => {
|
|||
|
||||
await client.updateAttributes(
|
||||
{
|
||||
payMethod: args.payMethod,
|
||||
iban: args.iban,
|
||||
bankEntityFk: args.bankEntityFk,
|
||||
defaultAddressFk: address.id,
|
||||
|
|
|
@ -27,14 +27,14 @@ describe('Worker new', () => {
|
|||
street: 'S/ defaultWorkerStreet',
|
||||
city: 'defaultWorkerCity',
|
||||
provinceFk: 1,
|
||||
iban: 'ES8304879798578129532677',
|
||||
bankEntityFk: 128,
|
||||
companyFk: 442,
|
||||
postcode: '46680',
|
||||
phone: '123456789',
|
||||
code: 'DWW',
|
||||
bossFk: 9,
|
||||
birth: '2022-12-11T23:00:00.000Z'
|
||||
birth: '2022-12-11T23:00:00.000Z',
|
||||
payMethodFk: 1,
|
||||
roleFk: 1
|
||||
};
|
||||
|
||||
it('should return error if personal mail already exists', async() => {
|
||||
|
@ -105,6 +105,33 @@ describe('Worker new', () => {
|
|||
expect(error.message).toEqual('This worker already exists');
|
||||
});
|
||||
|
||||
it('should return error if payMethod require iban', async() => {
|
||||
const payMethodIbanRequired = await models.PayMethod.findOne({
|
||||
where: {
|
||||
isIbanRequiredForClients: true
|
||||
},
|
||||
fields: ['id']
|
||||
});
|
||||
|
||||
const tx = await models.Worker.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ctx = {
|
||||
args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id})
|
||||
};
|
||||
await models.Worker.new(ctx, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toEqual('That payment method requires an IBAN');
|
||||
});
|
||||
|
||||
it('should create a new worker', async() => {
|
||||
const newWorker = await models.Worker.new({args: defaultWorker});
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
"roleFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"payMethodFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"businessTypeFk": {
|
||||
"type": "string"
|
||||
}
|
||||
|
|
|
@ -142,12 +142,19 @@
|
|||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Pay method"
|
||||
url="Paymethods"
|
||||
ng-model="$ctrl.worker.payMethodFk"
|
||||
initial-data="$ctrl.workerConfig.payMethodFk">
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="IBAN"
|
||||
ng-model="$ctrl.worker.iban"
|
||||
rule
|
||||
on-change="$ctrl.autofillBic()">
|
||||
on-change="$ctrl.autofillBic()"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
|
|
|
@ -5,9 +5,17 @@ export default class Controller extends Section {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.worker = {companyFk: this.vnConfig.user.companyFk};
|
||||
this.$http.get(`WorkerConfigs/findOne`, {field: ['payMethodFk']}).then(res => {
|
||||
if (res.data) this.worker.payMethodFk = res.data.payMethodFk;
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
if (!this.worker.iban && !this.worker.bankEntityFk) {
|
||||
delete this.worker.iban;
|
||||
delete this.worker.bankEntityFk;
|
||||
}
|
||||
|
||||
return this.$.watcher.submit().then(json => {
|
||||
this.$state.go('worker.card.basicData', {id: json.data.id});
|
||||
});
|
||||
|
|
|
@ -10,3 +10,4 @@ Street: Dirección
|
|||
Postcode: Código postal
|
||||
Web user: Usuario Web
|
||||
Access permission: Permiso de acceso
|
||||
Pay method: Método de pago
|
||||
|
|
Loading…
Reference in New Issue