Merge pull request 'done' (#542) from 2725-ticket-create-crear-shimpent into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #542 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
40a7ac1e5c
|
@ -35,3 +35,4 @@ rules:
|
|||
space-in-parens: ["error", "never"]
|
||||
jasmine/no-focused-tests: 0
|
||||
jasmine/prefer-toHaveBeenCalledWith: 0
|
||||
arrow-spacing: ["error", { "before": true, "after": true }]
|
|
@ -151,19 +151,19 @@ 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'),
|
||||
(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', 'Compensations');
|
||||
(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
|
||||
|
|
|
@ -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 está vacia"
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue