hotfix negativeBases
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
6f35eb0ce3
commit
b3a10698af
|
@ -0,0 +1,3 @@
|
||||||
|
UPDATE `salix`.`ACL`
|
||||||
|
SET model = 'InvoiceOut'
|
||||||
|
WHERE property IN ('negativeBases', 'negativeBasesCsv');
|
|
@ -155,5 +155,17 @@
|
||||||
"Warehouse inventory not set": "Almacén inventario no está establecido",
|
"Warehouse inventory not set": "Almacén inventario no está establecido",
|
||||||
"Component cost not set": "Componente coste no está estabecido",
|
"Component cost not set": "Componente coste no está estabecido",
|
||||||
"Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2",
|
"Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2",
|
||||||
"Description cannot be blank": "Description cannot be blank"
|
"Description cannot be blank": "Description cannot be blank",
|
||||||
|
"company": "Company",
|
||||||
|
"country": "Country",
|
||||||
|
"clientId": "Id client",
|
||||||
|
"clientSocialName": "Client",
|
||||||
|
"amount": "Amount",
|
||||||
|
"taxableBase": "Taxable base",
|
||||||
|
"ticketFk": "Id ticket",
|
||||||
|
"isActive": "Active",
|
||||||
|
"hasToInvoice": "Invoice",
|
||||||
|
"isTaxDataChecked": "Data checked",
|
||||||
|
"comercialId": "Id Comercial",
|
||||||
|
"comercialName": "Comercial"
|
||||||
}
|
}
|
|
@ -277,5 +277,17 @@
|
||||||
"Insert a date range": "Inserte un rango de fechas",
|
"Insert a date range": "Inserte un rango de fechas",
|
||||||
"Added observation": "{{user}} añadió esta observacion: {{text}}",
|
"Added observation": "{{user}} añadió esta observacion: {{text}}",
|
||||||
"Comment added to client": "Observación añadida al cliente {{clientFk}}",
|
"Comment added to client": "Observación añadida al cliente {{clientFk}}",
|
||||||
"Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen"
|
"Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen",
|
||||||
|
"company": "Compañía",
|
||||||
|
"country": "País",
|
||||||
|
"clientId": "Id cliente",
|
||||||
|
"clientSocialName": "Cliente",
|
||||||
|
"amount": "Importe",
|
||||||
|
"taxableBase": "Base",
|
||||||
|
"ticketFk": "Id ticket",
|
||||||
|
"isActive": "Activo",
|
||||||
|
"hasToInvoice": "Facturar",
|
||||||
|
"isTaxDataChecked": "Datos comprobados",
|
||||||
|
"comercialId": "Id comercial",
|
||||||
|
"comercialName": "Comercial"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
const {toCSV} = require('vn-loopback/util/csv');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethodCtx('negativeBasesCsv', {
|
|
||||||
description: 'Returns the negative bases as .csv',
|
|
||||||
accessType: 'READ',
|
|
||||||
accepts: [{
|
|
||||||
arg: 'negativeBases',
|
|
||||||
type: ['object'],
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'from',
|
|
||||||
type: 'date',
|
|
||||||
description: 'From date'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'to',
|
|
||||||
type: 'date',
|
|
||||||
description: 'To date'
|
|
||||||
}],
|
|
||||||
returns: [
|
|
||||||
{
|
|
||||||
arg: 'body',
|
|
||||||
type: 'file',
|
|
||||||
root: true
|
|
||||||
}, {
|
|
||||||
arg: 'Content-Type',
|
|
||||||
type: 'String',
|
|
||||||
http: {target: 'header'}
|
|
||||||
}, {
|
|
||||||
arg: 'Content-Disposition',
|
|
||||||
type: 'String',
|
|
||||||
http: {target: 'header'}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
http: {
|
|
||||||
path: '/negativeBasesCsv',
|
|
||||||
verb: 'GET'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.negativeBasesCsv = async ctx => {
|
|
||||||
const args = ctx.args;
|
|
||||||
const content = toCSV(args.negativeBases);
|
|
||||||
|
|
||||||
return [
|
|
||||||
content,
|
|
||||||
'text/csv',
|
|
||||||
`attachment; filename="negative-bases-${new Date(args.from).toLocaleDateString()}-${new Date(args.to).toLocaleDateString()}.csv"`
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -7,6 +7,4 @@ module.exports = Self => {
|
||||||
require('../methods/invoice-in/invoiceInPdf')(Self);
|
require('../methods/invoice-in/invoiceInPdf')(Self);
|
||||||
require('../methods/invoice-in/invoiceInEmail')(Self);
|
require('../methods/invoice-in/invoiceInEmail')(Self);
|
||||||
require('../methods/invoice-in/getSerial')(Self);
|
require('../methods/invoice-in/getSerial')(Self);
|
||||||
require('../methods/invoice-in/negativeBases')(Self);
|
|
||||||
require('../methods/invoice-in/negativeBasesCsv')(Self);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,4 +15,3 @@ import './create';
|
||||||
import './log';
|
import './log';
|
||||||
import './serial';
|
import './serial';
|
||||||
import './serial-search-panel';
|
import './serial-search-panel';
|
||||||
import './negative-bases';
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
Has To Invoice: Facturar
|
|
||||||
Download as CSV: Descargar como CSV
|
|
||||||
company: Compañía
|
|
||||||
country: País
|
|
||||||
clientId: Id Cliente
|
|
||||||
clientSocialName: Cliente
|
|
||||||
amount: Importe
|
|
||||||
taxableBase: Base
|
|
||||||
ticketFk: Id Ticket
|
|
||||||
isActive: Activo
|
|
||||||
hasToInvoice: Facturar
|
|
||||||
isTaxDataChecked: Datos comprobados
|
|
||||||
comercialId: Id Comercial
|
|
||||||
comercialName: Comercial
|
|
|
@ -10,8 +10,7 @@
|
||||||
"menus": {
|
"menus": {
|
||||||
"main": [
|
"main": [
|
||||||
{ "state": "invoiceIn.index", "icon": "icon-invoice-in"},
|
{ "state": "invoiceIn.index", "icon": "icon-invoice-in"},
|
||||||
{ "state": "invoiceIn.serial", "icon": "icon-invoice-in"},
|
{ "state": "invoiceIn.serial", "icon": "icon-invoice-in"}
|
||||||
{ "state": "invoiceIn.negative-bases", "icon": "icon-ticket"}
|
|
||||||
],
|
],
|
||||||
"card": [
|
"card": [
|
||||||
{
|
{
|
||||||
|
@ -53,15 +52,6 @@
|
||||||
"administrative"
|
"administrative"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"url": "/negative-bases",
|
|
||||||
"state": "invoiceIn.negative-bases",
|
|
||||||
"component": "vn-negative-bases",
|
|
||||||
"description": "Negative bases",
|
|
||||||
"acl": [
|
|
||||||
"administrative"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"url": "/serial",
|
"url": "/serial",
|
||||||
"state": "invoiceIn.serial",
|
"state": "invoiceIn.serial",
|
||||||
|
|
|
@ -96,16 +96,18 @@ module.exports = Self => {
|
||||||
SELECT f.*
|
SELECT f.*
|
||||||
FROM tmp.filter f`);
|
FROM tmp.filter f`);
|
||||||
|
|
||||||
|
if (args.filter) {
|
||||||
stmt.merge(conn.makeWhere(args.filter.where));
|
stmt.merge(conn.makeWhere(args.filter.where));
|
||||||
stmt.merge(conn.makeOrderBy(args.filter.order));
|
stmt.merge(conn.makeOrderBy(args.filter.order));
|
||||||
stmt.merge(conn.makeLimit(args.filter));
|
stmt.merge(conn.makeLimit(args.filter));
|
||||||
|
}
|
||||||
|
|
||||||
const negativeBasesIndex = stmts.push(stmt) - 1;
|
const negativeBasesIndex = stmts.push(stmt) - 1;
|
||||||
|
|
||||||
stmts.push(`DROP TEMPORARY TABLE tmp.filter, tmp.ticket, tmp.ticketTax, tmp.ticketAmount`);
|
stmts.push(`DROP TEMPORARY TABLE tmp.filter, tmp.ticket, tmp.ticketTax, tmp.ticketAmount`);
|
||||||
|
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
const result = await conn.executeStmt(sql, myOptions);
|
const result = await conn.executeStmt(sql);
|
||||||
|
|
||||||
return negativeBasesIndex === 0 ? result : result[negativeBasesIndex];
|
return negativeBasesIndex === 0 ? result : result[negativeBasesIndex];
|
||||||
};
|
};
|
|
@ -0,0 +1,68 @@
|
||||||
|
const {toCSV} = require('vn-loopback/util/csv');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('negativeBasesCsv', {
|
||||||
|
description: 'Returns the negative bases as .csv',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'from',
|
||||||
|
type: 'date',
|
||||||
|
description: 'From date',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'to',
|
||||||
|
type: 'date',
|
||||||
|
description: 'To date',
|
||||||
|
required: true
|
||||||
|
}],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
|
root: true
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: '/negativeBasesCsv',
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.negativeBasesCsv = async(ctx, options) => {
|
||||||
|
const $t = ctx.req.__; // $translate
|
||||||
|
const args = ctx.args;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const negativeBases = await Self.app.models.InvoiceOut.negativeBases(ctx, myOptions);
|
||||||
|
const locatedFields = [];
|
||||||
|
negativeBases.forEach(element => {
|
||||||
|
locatedFields.push(Object.keys(element).map(key => {
|
||||||
|
return {newName: $t(key), value: element[key]};
|
||||||
|
}).filter(item => item !== null)
|
||||||
|
.reduce((result, item) => {
|
||||||
|
result[item.newName] = item.value;
|
||||||
|
return result;
|
||||||
|
}, {}));
|
||||||
|
});
|
||||||
|
const content = toCSV(locatedFields);
|
||||||
|
|
||||||
|
return [
|
||||||
|
content,
|
||||||
|
'text/csv',
|
||||||
|
`attachment; filename="negative-bases-${new Date(args.from).toLocaleDateString()}-${new Date(args.to).toLocaleDateString()}.csv"`
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,19 +1,18 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('invoiceIn negativeBases()', () => {
|
describe('invoiceOut negativeBases()', () => {
|
||||||
it('should return all negative bases in a date range', async() => {
|
it('should return all negative bases in a date range', async() => {
|
||||||
const tx = await models.InvoiceIn.beginTransaction({});
|
const tx = await models.InvoiceOut.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
from: new Date().setMonth(new Date().getMonth() - 12),
|
from: new Date().setMonth(new Date().getMonth() - 12),
|
||||||
to: new Date(),
|
to: new Date()
|
||||||
filter: {}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await models.InvoiceIn.negativeBases(ctx, options);
|
const result = await models.InvoiceOut.negativeBases(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ describe('invoiceIn negativeBases()', () => {
|
||||||
|
|
||||||
it('should throw an error if a date range is not in args', async() => {
|
it('should throw an error if a date range is not in args', async() => {
|
||||||
let error;
|
let error;
|
||||||
const tx = await models.InvoiceIn.beginTransaction({});
|
const tx = await models.InvoiceOut.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
|
@ -35,7 +34,7 @@ describe('invoiceIn negativeBases()', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await models.InvoiceIn.negativeBases(ctx, options);
|
await models.InvoiceOut.negativeBases(ctx, options);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
|
@ -17,4 +17,6 @@ module.exports = Self => {
|
||||||
require('../methods/invoiceOut/invoiceCsvEmail')(Self);
|
require('../methods/invoiceOut/invoiceCsvEmail')(Self);
|
||||||
require('../methods/invoiceOut/invoiceOutPdf')(Self);
|
require('../methods/invoiceOut/invoiceOutPdf')(Self);
|
||||||
require('../methods/invoiceOut/getInvoiceDate')(Self);
|
require('../methods/invoiceOut/getInvoiceDate')(Self);
|
||||||
|
require('../methods/invoiceOut/negativeBases')(Self);
|
||||||
|
require('../methods/invoiceOut/negativeBasesCsv')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,3 +10,4 @@ import './descriptor-popover';
|
||||||
import './descriptor-menu';
|
import './descriptor-menu';
|
||||||
import './index/manual';
|
import './index/manual';
|
||||||
import './global-invoicing';
|
import './global-invoicing';
|
||||||
|
import './negative-bases';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="InvoiceIns/negativeBases"
|
url="InvoiceOuts/negativeBases"
|
||||||
auto-load="true"
|
auto-load="true"
|
||||||
params="$ctrl.params"
|
params="$ctrl.params"
|
||||||
limit="20">
|
limit="20">
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
<span translate>Country</span>
|
<span translate>Country</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="clientId">
|
<th field="clientId">
|
||||||
<span translate>Id Client</span>
|
<span translate>Client id</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="clientSocialName">
|
<th field="clientSocialName">
|
||||||
<span translate>Client</span>
|
<span translate>Client</span>
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<span translate>Base</span>
|
<span translate>Base</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="ticketFk">
|
<th field="ticketFk">
|
||||||
<span translate>Id Ticket</span>
|
<span translate>Ticket id</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="isActive">
|
<th field="isActive">
|
||||||
<span translate>Active</span>
|
<span translate>Active</span>
|
|
@ -58,18 +58,7 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadCSV() {
|
downloadCSV() {
|
||||||
const data = [];
|
this.vnReport.show('InvoiceOuts/negativeBasesCsv', {
|
||||||
this.$.model._orgData.forEach(element => {
|
|
||||||
data.push(Object.keys(element).map(key => {
|
|
||||||
return {newName: this.$t(key), value: element[key]};
|
|
||||||
}).filter(item => item !== null)
|
|
||||||
.reduce((result, item) => {
|
|
||||||
result[item.newName] = item.value;
|
|
||||||
return result;
|
|
||||||
}, {}));
|
|
||||||
});
|
|
||||||
this.vnReport.show('InvoiceIns/negativeBasesCsv', {
|
|
||||||
negativeBases: data,
|
|
||||||
from: this.params.from,
|
from: this.params.from,
|
||||||
to: this.params.to
|
to: this.params.to
|
||||||
});
|
});
|
|
@ -0,0 +1,2 @@
|
||||||
|
Has To Invoice: Facturar
|
||||||
|
Download as CSV: Descargar como CSV
|
|
@ -7,8 +7,8 @@
|
||||||
"menus": {
|
"menus": {
|
||||||
"main": [
|
"main": [
|
||||||
{"state": "invoiceOut.index", "icon": "icon-invoice-out"},
|
{"state": "invoiceOut.index", "icon": "icon-invoice-out"},
|
||||||
{"state": "invoiceOut.global-invoicing", "icon": "contact_support"}
|
{"state": "invoiceOut.global-invoicing", "icon": "contact_support"},
|
||||||
|
{ "state": "invoiceOut.negative-bases", "icon": "icon-ticket"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"routes": [
|
"routes": [
|
||||||
|
@ -46,6 +46,15 @@
|
||||||
"state": "invoiceOut.card",
|
"state": "invoiceOut.card",
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"component": "vn-invoice-out-card"
|
"component": "vn-invoice-out-card"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"url": "/negative-bases",
|
||||||
|
"state": "invoiceOut.negative-bases",
|
||||||
|
"component": "vn-negative-bases",
|
||||||
|
"description": "Negative bases",
|
||||||
|
"acl": [
|
||||||
|
"administrative"
|
||||||
|
]
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue