refs #5768 trad choose address #1762
|
@ -0,0 +1,6 @@
|
|||
UPDATE `vn`.`supplier`
|
||||
SET account = LPAD(id,10,'0')
|
||||
WHERE account IS NULL;
|
||||
|
||||
ALTER TABLE `vn`.`supplier` ADD CONSTRAINT supplierAccountTooShort CHECK (LENGTH(account) = 10);
|
||||
ALTER TABLE `vn`.`supplier` MODIFY COLUMN account varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT 4100000000 NOT NULL COMMENT 'Default accounting code for suppliers.';
|
|
@ -216,6 +216,7 @@
|
|||
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
|
||||
"The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día",
|
||||
"You can not modify is pay method checked": "No se puede modificar el campo método de pago validado",
|
||||
"The account size must be exactly 10 characters": "El tamaño de la cuenta debe ser exactamente de 10 caracteres",
|
||||
"Can't transfer claimed sales": "No puedes transferir lineas reclamadas",
|
||||
"You don't have privileges to create refund": "No tienes permisos para crear un abono",
|
||||
"The item is required": "El artículo es requerido",
|
||||
|
|
|
@ -32,6 +32,7 @@ describe('Supplier newSupplier()', () => {
|
|||
const result = await models.Supplier.newSupplier(ctx, options);
|
||||
|
||||
expect(result.name).toEqual('newSupplier');
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
|
|
|
@ -123,5 +123,21 @@ describe('loopback model Supplier', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should update the account attribute when a new supplier is created', async() => {
|
||||
const tx = await models.Supplier.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const newSupplier = await models.Supplier.create({name: 'Alfred Pennyworth'}, options);
|
||||
const fetchedSupplier = await models.Supplier.findById(newSupplier.id, null, options);
|
||||
|
||||
expect(Number(fetchedSupplier.account)).toEqual(4100000000 + newSupplier.id);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -117,6 +117,16 @@ module.exports = Self => {
|
|||
throw new UserError('You can not modify is pay method checked');
|
||||
});
|
||||
|
||||
Self.observe('after save', async function(ctx) {
|
||||
if (ctx.instance && ctx.isNewInstance) {
|
||||
const {id} = ctx.instance;
|
||||
const {Supplier} = Self.app.models;
|
||||
|
||||
const supplier = await Supplier.findById(id, null, ctx.options);
|
||||
await supplier?.updateAttribute('account', Number(supplier.account) + id, ctx.options);
|
||||
}
|
||||
});
|
||||
|
||||
Self.validateAsync('name', 'countryFk', hasSupplierSameName, {
|
||||
message: 'A supplier with the same name already exists. Change the country.'
|
||||
});
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Create">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||
|
||||
const path = require('path');
|
||||
const vnPrintPath = path.resolve('print');
|
||||
|
||||
module.exports = new Stylesheet([
|
||||
`${vnPrintPath}/common/css/spacing.css`,
|
||||
`${vnPrintPath}/common/css/misc.css`,
|
||||
`${vnPrintPath}/common/css/layout.css`,
|
||||
`${vnPrintPath}/common/css/email.css`,
|
||||
`${__dirname}/style.css`])
|
||||
.mergeStyles();
|
|
@ -0,0 +1,8 @@
|
|||
.jsonSection {
|
||||
text-align: left;
|
||||
background-color: #e4e4e4;
|
||||
padding: 25px;
|
||||
margin-left: 60px;
|
||||
margin-right: 60px;
|
||||
border-radius: 25px;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
subject: Modified collection volumetry
|
||||
title: Modified collection volumetry
|
||||
description: Action performed
|
|
@ -0,0 +1,3 @@
|
|||
subject: Volumetría de colección modificada
|
||||
title: Volumetría de colección modificada
|
||||
description: Acción realizada
|
|
@ -0,0 +1,15 @@
|
|||
<email-body v-bind="$props">
|
||||
<div class="grid-row">
|
||||
<div class="grid-block vn-pa-ml">
|
||||
<div class="centered">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<h3>{{ $t('description') }}: <u>{{ data.action }}</u> <i> {{ `(${this.username})` }} </i></h3>
|
||||
<div class="jsonSection">
|
||||
<span v-for="(value, key) in data" v-if="key !== 'action' && key !== 'userFk'">
|
||||
<b> {{ `${key}:` }} </b> {{ value }} <br>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</email-body>
|
|
@ -0,0 +1,25 @@
|
|||
const Component = require(`vn-print/core/component`);
|
||||
const emailBody = new Component('email-body');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
module.exports = {
|
||||
name: 'modified-collection-volumetry',
|
||||
components: {
|
||||
'email-body': emailBody.build(),
|
||||
},
|
||||
async serverPrefetch() {
|
||||
this.username = (this.data.userFk) ? await this.getUsername(this.data.userFk) : 'system';
|
||||
},
|
||||
methods: {
|
||||
async getUsername(id) {
|
||||
const account = await models.VnUser.findById(id);
|
||||
return account.name;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue