done
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javi Gallego 2021-02-10 07:58:11 +01:00
parent 3f4e102860
commit 3a3dae179c
9 changed files with 80 additions and 28 deletions

View File

@ -34,4 +34,5 @@ rules:
no-multiple-empty-lines: ["error", { "max": 1, "maxEOF": 1 }]
space-in-parens: ["error", "never"]
jasmine/no-focused-tests: 0
jasmine/prefer-toHaveBeenCalledWith: 0
jasmine/prefer-toHaveBeenCalledWith: 0
arrow-spacing: { "before": true, "after": true }

View File

@ -150,20 +150,20 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park
INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`)
VALUES
(1, 'CC y Polizas de crédito', NULL, NULL),
(2, 'Cash', NULL, 'cash'),
(3, 'Credit card', NULL, 'creditCard'),
(4, 'Finalcial lines', NULL, NULL),
(5, 'Other products', NULL, NULL),
(6, 'Loans', NULL, NULL),
(7, 'Leasing', NULL, NULL),
(8, 'Compensations', 'Compensations', 'Compensations');
(1, 'CC y Polizas de crédito', NULL, NULL),
(2, 'Cash', 'Cash', 'cash'),
(3, 'Credit card', 'Credit Card', 'creditCard'),
(4, 'Finalcial lines', NULL, NULL),
(5, 'Other products', NULL, NULL),
(6, 'Loans', NULL, NULL),
(7, 'Leasing', NULL, NULL),
(8, 'Compensations', 'Compensations', 'compensation');
INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`)
VALUES
(1, 'Pay on receipt', '0000000000', 3, 0, 1, 1),
(2, 'Cash', '1111111111', 2, 0, 1, 1),
(3, 'Compensation', '0000000000', 8, 0, 1, 1);
(1, 'Pay on receipt', '5720000001', 3, 0, 1, 1),
(2, 'Cash', '5700000001', 2, 0, 1, 1),
(3, 'Compensation', '4000000000', 8, 0, 1, 1);
INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
VALUES

View File

@ -171,5 +171,6 @@
"New ticket request has been created with price": "Se ha creado una nueva petición de compra *'{{description}}'* para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*",
"New ticket request has been created": "Se ha creado una nueva petición de compra *'{{description}}'* para el día *{{shipped}}*, con una cantidad de *{{quantity}}*",
"That item doesn't exists": "Ese artículo no existe",
"There's a new urgent ticket": "Hay un nuevo ticket urgente: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})"
"There's a new urgent ticket": "Hay un nuevo ticket urgente: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})",
"Compensation account is empty": "La cuenta para compensar esta vacia"
}

View File

@ -62,7 +62,10 @@ module.exports = function(Self) {
const bank = await models.Bank.findById(args.bankFk);
const accountingType = await models.AccountingType.findById(bank.accountingTypeFk);
if (args.compensationAccount) {
if (accountingType.code == 'compensation') {
if (!args.compensationAccount)
throw new UserError('Compensation account is empty');
const supplierCompensation = await models.Supplier.findOne({
where: {
account: args.compensationAccount
@ -92,12 +95,11 @@ module.exports = function(Self) {
],
options);
} else {
const description = `${clientOriginal.id} : ${clientOriginal.nickname} - ${accountingType.receiptDescription}`;
const description = `${clientOriginal.id} : ${clientOriginal.socialName} - ${accountingType.receiptDescription}`;
const [xdiarioNew] = await Self.rawSql(
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`,
`SELECT xdiario_new(?, CURDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`,
[
null,
Date(),
bank.account,
clientOriginal.accountingAccount,
description,
@ -114,10 +116,9 @@ module.exports = function(Self) {
options);
await Self.rawSql(
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`,
`SELECT xdiario_new(?, CURDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`,
[
xdiarioNew.ledger,
Date(),
clientOriginal.accountingAccount,
bank.account,
description,

View File

@ -38,6 +38,29 @@ describe('Client createReceipt', () => {
await till.destroy();
});
it('should throw Compensation account is empty', async() => {
const bankFk = 3;
let ctx = {
args: {
clientFk: clientFk,
payed: payed,
companyFk: companyFk,
bankFk: bankFk,
amountPaid: amountPaid,
description: description
}
};
try {
await app.models.Client.createReceipt(ctx);
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error.message).toEqual('Compensation account is empty');
});
it('should throw Invalid account if compensationAccount does not belongs to a client nor a supplier', async() => {
let error;
const bankFk = 3;

View File

@ -101,7 +101,7 @@ module.exports = Self => {
if (!shipped && landed) {
const shippedResult = await models.Agency.getShipped(landed,
address.id, agencyModeId, warehouseId);
shipped = shippedResult && shippedResult.shipped;
shipped = (shippedResult && shippedResult.shipped) || landed;
}
if (shipped && !landed) {

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server');
let UserError = require('vn-loopback/util/user-error');
describe('ticket new()', () => {
fdescribe('ticket new()', () => {
let ticket;
let today = new Date();
let ctx = {req: {accessToken: {userId: 1}}};
@ -28,7 +28,7 @@ describe('ticket new()', () => {
params.shipped,
params.landed,
params.warehouseId,
params.companyFk,
params.companyId,
params.addressId
).catch(e => {
error = e;
@ -53,7 +53,7 @@ describe('ticket new()', () => {
params.shipped,
params.landed,
params.warehouseId,
params.companyFk,
params.companyId,
params.addressId
).catch(response => {
expect(response.message).toEqual(`This address doesn't exist`);
@ -79,7 +79,7 @@ describe('ticket new()', () => {
params.shipped,
params.landed,
params.warehouseId,
params.companyFk,
params.companyId,
params.addressId,
params.agencyModeId);
@ -87,4 +87,27 @@ describe('ticket new()', () => {
expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures);
});
it('should return the set a shipped when the agency is not especified', async() => {
let params = {
clientId: 104,
landed: today,
shipped: null,
warehouseId: 2,
companyId: 442,
addressId: 4,
agencyModeId: null
};
ticket = await app.models.Ticket.new(ctx,
params.clientId,
params.shipped,
params.landed,
params.warehouseId,
params.companyId,
params.addressId,
params.agencyModeId);
expect(ticket.shipped).toEqual(jasmine.any(Date));
});
});

View File

@ -39,7 +39,7 @@
</vn-autocomplete>
<vn-autocomplete
disabled="!$ctrl.clientId || !$ctrl.landed || !$ctrl.warehouseId"
data="$ctrl._availableAgencies"
data="$ctrl.agencies"
label="Agency"
show-field="agencyMode"
value-field="agencyModeFk"

View File

@ -100,9 +100,12 @@ class Controller extends Component {
ticket.agencyModeFk = null;
this.$http.get(`Agencies/getAgenciesWithWarehouse`, {params}).then(res => {
this._availableAgencies = res.data;
this.agencyModeId = this.defaultAddress.agencyModeFk;
this.agencies = res.data;
const defaultAgency = this.agencies.find(agency=> {
return agency.agencyModeFk == this.defaultAddress.agencyModeFk;
});
if (defaultAgency)
this.agencyModeId = defaultAgency.agencyModeFk;
});
}
}