Merge pull request 'refs #5753 db export and fix fixtures' (!1643) from 5753_232401_db_dump into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1643 Reviewed-by: Carlos Satorres Adam <carlossa@verdnatura.es> Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
3b346d673b
|
@ -0,0 +1,13 @@
|
||||||
|
UPDATE `salix`.`ACL`
|
||||||
|
SET principalId='financialBoss'
|
||||||
|
WHERE
|
||||||
|
model = 'Client'
|
||||||
|
AND property = 'editCredit';
|
||||||
|
|
||||||
|
UPDATE `salix`.`ACL`
|
||||||
|
SET property='zeroCreditEditor'
|
||||||
|
WHERE
|
||||||
|
model = 'Client'
|
||||||
|
AND property = 'isNotEditableCredit';
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -144,17 +144,17 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
|
||||||
(3, 'GBP', 'Libra', 1),
|
(3, 'GBP', 'Libra', 1),
|
||||||
(4, 'JPY', 'Yen Japones', 1);
|
(4, 'JPY', 'Yen Japones', 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`, `politicalCountryFk`)
|
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'España', 1, 'ES', 1, 24, 4, 0, 1, 1),
|
(1, 'España', 1, 'ES', 1, 24, 4, 0, 1),
|
||||||
(2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1, 2),
|
(2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1),
|
||||||
(3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1, 3),
|
(3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1),
|
||||||
(4, 'Rumania', 1, 'RO', 1, 24, 4, 0, 1, 4),
|
(4, 'Rumania', 1, 'RO', 1, 24, 4, 0, 1),
|
||||||
(5, 'Holanda', 1, 'NL', 1, 18, 4, 0, 1, 5),
|
(5, 'Holanda', 1, 'NL', 1, 18, 4, 0, 1),
|
||||||
(8, 'Portugal', 1, 'PT', 1, 27, 4, 0, 1, 8),
|
(8, 'Portugal', 1, 'PT', 1, 27, 4, 0, 1),
|
||||||
(13,'Ecuador', 0, 'EC', 1, 24, 2, 1, 2, 13),
|
(13,'Ecuador', 0, 'EC', 1, 24, 2, 1, 2),
|
||||||
(19,'Francia', 1, 'FR', 1, 27, 4, 0, 1, 19),
|
(19,'Francia', 1, 'FR', 1, 27, 4, 0, 1),
|
||||||
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2, 30);
|
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
|
||||||
|
|
||||||
INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
|
INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -550,10 +550,13 @@ INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `pr
|
||||||
|
|
||||||
INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`)
|
INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
(1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
||||||
(2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
(2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||||
(442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
|
(69, 'Packaging', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
||||||
(1381, 'Ornamentales', 'Ornamentales', 7185000440, 1, '03815934E', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
|
(442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
|
||||||
|
(567, 'Holland', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||||
|
(791, 'Bros SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE(), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
|
||||||
|
(1381, 'Ornamentales', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
|
||||||
|
|
||||||
INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
|
INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2599,7 +2602,7 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
|
||||||
(3, 6, 5),
|
(3, 6, 5),
|
||||||
(4, 7, 1);
|
(4, 7, 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`expeditionTruck` (`id`, `ETD`, `description`)
|
INSERT INTO `vn`.`expeditionTruck` (`id`, `eta`, `description`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet');
|
(1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet');
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,7 +19,6 @@ describe('Item edit tax path', () => {
|
||||||
it(`should add the item tax to all countries`, async() => {
|
it(`should add the item tax to all countries`, async() => {
|
||||||
await page.autocompleteSearch(selectors.itemTax.firstClass, 'General VAT');
|
await page.autocompleteSearch(selectors.itemTax.firstClass, 'General VAT');
|
||||||
await page.autocompleteSearch(selectors.itemTax.secondClass, 'General VAT');
|
await page.autocompleteSearch(selectors.itemTax.secondClass, 'General VAT');
|
||||||
await page.autocompleteSearch(selectors.itemTax.thirdClass, 'General VAT');
|
|
||||||
await page.waitToClick(selectors.itemTax.submitTaxButton);
|
await page.waitToClick(selectors.itemTax.submitTaxButton);
|
||||||
const message = await page.waitForSnackbar();
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
@ -40,13 +39,6 @@ describe('Item edit tax path', () => {
|
||||||
expect(secondVatType).toEqual('General VAT');
|
expect(secondVatType).toEqual('General VAT');
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should confirm the third item tax class was edited`, async() => {
|
|
||||||
const thirdVatType = await page
|
|
||||||
.waitToGetProperty(selectors.itemTax.thirdClass, 'value');
|
|
||||||
|
|
||||||
expect(thirdVatType).toEqual('General VAT');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should edit the first class without saving the form`, async() => {
|
it(`should edit the first class without saving the form`, async() => {
|
||||||
await page.autocompleteSearch(selectors.itemTax.firstClass, 'Reduced VAT');
|
await page.autocompleteSearch(selectors.itemTax.firstClass, 'Reduced VAT');
|
||||||
const firstVatType = await page.waitToGetProperty(selectors.itemTax.firstClass, 'value');
|
const firstVatType = await page.waitToGetProperty(selectors.itemTax.firstClass, 'value');
|
||||||
|
|
|
@ -81,6 +81,6 @@ describe('Account Role create and basic data path', () => {
|
||||||
await page.accessToSection('account.role.card.inherited');
|
await page.accessToSection('account.role.card.inherited');
|
||||||
const rolesCount = await page.countElement(selectors.accountRoleInheritance.anyResult);
|
const rolesCount = await page.countElement(selectors.accountRoleInheritance.anyResult);
|
||||||
|
|
||||||
expect(rolesCount).toEqual(6);
|
expect(rolesCount).toEqual(7);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -178,4 +178,4 @@
|
||||||
"Failed to upload delivery note": "Error to upload delivery note {{id}}",
|
"Failed to upload delivery note": "Error to upload delivery note {{id}}",
|
||||||
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address",
|
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address",
|
||||||
"The renew period has not been exceeded": "The renew period has not been exceeded"
|
"The renew period has not been exceeded": "The renew period has not been exceeded"
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,22 +401,32 @@ module.exports = Self => {
|
||||||
Self.changeCredit = async function changeCredit(ctx, finalState, changes) {
|
Self.changeCredit = async function changeCredit(ctx, finalState, changes) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const userId = ctx.options.accessToken.userId;
|
const userId = ctx.options.accessToken.userId;
|
||||||
const accessToken = {req: {accessToken: ctx.options.accessToken} };
|
const accessToken = {req: {accessToken: ctx.options.accessToken}};
|
||||||
|
|
||||||
const canEditCredit = await models.ACL.checkAccessAcl(accessToken, 'Client', 'editCredit', 'WRITE');
|
const canEditCredit = await models.ACL.checkAccessAcl(accessToken, 'Client', 'editCredit', 'WRITE');
|
||||||
if (!canEditCredit) {
|
if (!canEditCredit) {
|
||||||
const lastCredit = await models.ClientCredit.findOne({
|
const lastCredit = await models.ClientCredit.findOne({
|
||||||
|
field: ['workerFk', 'amount'],
|
||||||
where: {
|
where: {
|
||||||
clientFk: finalState.id
|
clientFk: finalState.id
|
||||||
},
|
},
|
||||||
order: 'id DESC'
|
order: 'id DESC'
|
||||||
}, ctx.options);
|
}, ctx.options);
|
||||||
|
|
||||||
const lastAmount = lastCredit && lastCredit.amount;
|
if (lastCredit && lastCredit.amount == 0) {
|
||||||
const lastCreditIsNotEditable = !await models.ACL.checkAccessAcl(accessToken, 'Client', 'isNotEditableCredit', 'WRITE');
|
const zeroCreditEditor =
|
||||||
|
await models.ACL.checkAccessAcl(accessToken, 'Client', 'zeroCreditEditor', 'WRITE');
|
||||||
|
const lastCreditIsNotEditable =
|
||||||
|
await models.ACL.checkAccessAcl(
|
||||||
|
{req: {accessToken: {userId: lastCredit.workerFk}}},
|
||||||
|
'Client',
|
||||||
|
'zeroCreditEditor',
|
||||||
|
'WRITE'
|
||||||
|
);
|
||||||
|
|
||||||
if (lastAmount == 0 && lastCreditIsNotEditable)
|
if (lastCreditIsNotEditable && !zeroCreditEditor)
|
||||||
throw new UserError(`You can't change the credit set to zero from a financialBoss`);
|
throw new UserError(`You can't change the credit set to zero from a financialBoss`);
|
||||||
|
}
|
||||||
|
|
||||||
const creditLimits = await models.ClientCreditLimit.find({
|
const creditLimits = await models.ClientCreditLimit.find({
|
||||||
fields: ['roleFk'],
|
fields: ['roleFk'],
|
||||||
|
|
|
@ -60,22 +60,22 @@ describe('Client Model', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const context = {options};
|
const ctx = {options};
|
||||||
|
|
||||||
// Set credit to zero by a financialBoss
|
// Set credit to zero by a financialBoss
|
||||||
const financialBoss = await models.VnUser.findOne({
|
const financialBoss = await models.VnUser.findOne({
|
||||||
where: {name: 'financialBoss'}
|
where: {name: 'financialBoss'}
|
||||||
}, options);
|
}, options);
|
||||||
context.options.accessToken = {userId: financialBoss.id};
|
ctx.options.accessToken = {userId: financialBoss.id};
|
||||||
|
|
||||||
await models.Client.changeCredit(context, instance, {credit: 0});
|
await models.Client.changeCredit(ctx, instance, {credit: 0});
|
||||||
|
|
||||||
const salesAssistant = await models.VnUser.findOne({
|
const salesAssistant = await models.VnUser.findOne({
|
||||||
where: {name: 'salesAssistant'}
|
where: {name: 'salesAssistant'}
|
||||||
}, options);
|
}, options);
|
||||||
context.options.accessToken = {userId: salesAssistant.id};
|
ctx.options.accessToken = {userId: salesAssistant.id};
|
||||||
|
|
||||||
await models.Client.changeCredit(context, instance, {credit: 300});
|
await models.Client.changeCredit(ctx, instance, {credit: 300});
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -93,14 +93,14 @@ describe('Client Model', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const context = {options};
|
const ctx = {options};
|
||||||
|
|
||||||
const salesAssistant = await models.VnUser.findOne({
|
const salesAssistant = await models.VnUser.findOne({
|
||||||
where: {name: 'salesAssistant'}
|
where: {name: 'salesAssistant'}
|
||||||
}, options);
|
}, options);
|
||||||
context.options.accessToken = {userId: salesAssistant.id};
|
ctx.options.accessToken = {userId: salesAssistant.id};
|
||||||
|
|
||||||
await models.Client.changeCredit(context, instance, {credit: 99999});
|
await models.Client.changeCredit(ctx, instance, {credit: 99999});
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ describe('InvoiceOut refund()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
await models.TicketRefund.destroyAll(null, options);
|
||||||
const result = await models.InvoiceOut.refund(ctx, 'T1111111', withWarehouse, options);
|
const result = await models.InvoiceOut.refund(ctx, 'T1111111', withWarehouse, options);
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
|
|
|
@ -64,7 +64,7 @@ describe('item getBalance()', () => {
|
||||||
const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options);
|
const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options);
|
||||||
|
|
||||||
expect(firstItemBalance[9].claimFk).toEqual(null);
|
expect(firstItemBalance[9].claimFk).toEqual(null);
|
||||||
expect(secondItemBalance[5].claimFk).toEqual(2);
|
expect(secondItemBalance[4].claimFk).toEqual(2);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -42,8 +42,9 @@ module.exports = Self => {
|
||||||
|
|
||||||
promises.push(Self.app.models.ItemTaxCountry.updateAll(
|
promises.push(Self.app.models.ItemTaxCountry.updateAll(
|
||||||
{id: tax.id},
|
{id: tax.id},
|
||||||
{taxClassFk: tax.taxClassFk}
|
{taxClassFk: tax.taxClassFk},
|
||||||
), myOptions);
|
myOptions
|
||||||
|
));
|
||||||
}
|
}
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue