Merge branch 'dev' into 5036-regularizar-historicos
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2023-02-27 06:05:21 +00:00
commit 76cd2d160e
18 changed files with 69 additions and 34 deletions

View File

@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2308.01] - 2023-03-09 ## [2308.01] - 2023-03-09
### Added ### Added
- - (Client -> Descriptor) Nuevo icono $ con barrotes para los clientes con impago
### Changed ### Changed
- -

View File

@ -197,6 +197,7 @@ describe('Ticket Edit sale path', () => {
}); });
it('should check in the history that logs has been added', async() => { it('should check in the history that logs has been added', async() => {
await page.reload({waitUntil: ['networkidle0', 'domcontentloaded']});
await page.waitToClick(selectors.ticketSales.firstSaleHistoryButton); await page.waitToClick(selectors.ticketSales.firstSaleHistoryButton);
await page.waitForSelector(selectors.ticketSales.firstSaleHistory); await page.waitForSelector(selectors.ticketSales.firstSaleHistory);
const result = await page.countElement(selectors.ticketSales.firstSaleHistory); const result = await page.countElement(selectors.ticketSales.firstSaleHistory);

View File

@ -63,6 +63,6 @@ describe('Ticket index payout path', () => {
const reference = await page.waitToGetProperty(selectors.clientBalance.firstLineReference, 'innerText'); const reference = await page.waitToGetProperty(selectors.clientBalance.firstLineReference, 'innerText');
expect(count).toEqual(4); expect(count).toEqual(4);
expect(reference).toContain('Cash,Albaran: 7, 8Payment'); expect(reference).toContain('Cash, Albaran: 7, 8Payment');
}); });
}); });

View File

@ -12,6 +12,7 @@ module.exports = Self => {
}); });
Self.post = async ctx => { Self.post = async ctx => {
console.log(ctx.req.body);
return ctx.req.body; return ctx.req.body;
}; };
}; };

View File

@ -166,7 +166,8 @@ module.exports = Self => {
c.name AS clientName, c.name AS clientName,
cl.workerFk, cl.workerFk,
u.name AS workerName, u.name AS workerName,
cs.description, cs.code stateCode,
cs.description stateDescription,
cl.created cl.created
FROM claim cl FROM claim cl
LEFT JOIN client c ON c.id = cl.clientFk LEFT JOIN client c ON c.id = cl.clientFk

View File

@ -77,6 +77,11 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Ticket", "model": "Ticket",
"foreignKey": "ticketFk" "foreignKey": "ticketFk"
},
"claimDms": {
"type": "hasMany",
"model": "ClaimDms",
"foreignKey": "claimFk"
} }
} }
} }

View File

@ -52,8 +52,8 @@
</span> </span>
</td> </td>
<td> <td>
<span class="chip {{::$ctrl.stateColor(claim)}}"> <span class="chip {{::$ctrl.stateColor(claim.stateCode)}}">
{{::claim.description}} {{::claim.stateDescription}}
</span> </span>
</td> </td>
<td shrink> <td shrink>

View File

@ -55,13 +55,13 @@ class Controller extends Section {
} }
} }
stateColor(claim) { stateColor(code) {
switch (claim.description) { switch (code) {
case 'Pendiente': case 'pending':
return 'warning'; return 'warning';
case 'Gestionado': case 'managed':
return 'notice'; return 'notice';
case 'Resuelto': case 'resolved':
return 'success'; return 'success';
} }
} }

View File

@ -80,6 +80,7 @@ module.exports = function(Self) {
const data = await Self.rawSql(query, [id, date], myOptions); const data = await Self.rawSql(query, [id, date], myOptions);
client.debt = data[0].debt; client.debt = data[0].debt;
client.unpaid = await Self.app.models.ClientUnpaid.findOne({id}, myOptions);
return client; return client;
}; };

View File

@ -68,7 +68,7 @@ class Controller extends Dialog {
this.receipt.description.push(accountingType.receiptDescription); this.receipt.description.push(accountingType.receiptDescription);
if (this.originalDescription) if (this.originalDescription)
this.receipt.description.push(this.originalDescription); this.receipt.description.push(this.originalDescription);
this.receipt.description.join(', '); this.receipt.description = this.receipt.description.join(', ');
} }
this.maxAmount = accountingType && accountingType.maxAmount; this.maxAmount = accountingType && accountingType.maxAmount;

View File

@ -38,7 +38,7 @@ describe('Client', () => {
} }
}; };
expect(controller.receipt.description.join(',')).toEqual('Cash,Albaran: 1, 2'); expect(controller.receipt.description).toEqual('Cash, Albaran: 1, 2');
}); });
}); });

View File

@ -70,6 +70,11 @@
icon="icon-no036" icon="icon-no036"
ng-if="$ctrl.client.isTaxDataChecked == false"> ng-if="$ctrl.client.isTaxDataChecked == false">
</vn-icon> </vn-icon>
<vn-icon
vn-tooltip="{{$ctrl.clientUnpaid()}}"
icon="icon-clientUnpaid"
ng-if="$ctrl.client.unpaid">
</vn-icon>
</div> </div>
<div class="quicklinks"> <div class="quicklinks">
<div ng-transclude="btnOne"> <div ng-transclude="btnOne">

View File

@ -44,6 +44,11 @@ class Controller extends Descriptor {
return this.$http.post(`Clients/${this.id}/sendSms`, sms) return this.$http.post(`Clients/${this.id}/sendSms`, sms)
.then(() => this.vnApp.showSuccess(this.$t('SMS sent'))); .then(() => this.vnApp.showSuccess(this.$t('SMS sent')));
} }
clientUnpaid() {
return this.$t(`Unpaid Dated`, {dated: this.client.unpaid.dated}) +
'<br/>' + this.$t(`Unpaid Amount`, {amount: this.client.unpaid.amount});
}
} }
ngModule.vnComponent('vnClientDescriptor', { ngModule.vnComponent('vnClientDescriptor', {

View File

@ -6,3 +6,5 @@ Go to user: Ir al usuario
Go to supplier: Ir al proveedor Go to supplier: Ir al proveedor
Client invoices list: Listado de facturas del cliente Client invoices list: Listado de facturas del cliente
Pay method: Forma de pago Pay method: Forma de pago
Unpaid Dated: "Fecha: {{dated | date:'dd/MM/yyyy'}}"
Unpaid Amount: "Importe: {{amount | currency: 'EUR':2}}"

View File

@ -5,10 +5,6 @@ import './style.scss';
class Controller extends Section { class Controller extends Section {
constructor($element, $, vnEmail) { constructor($element, $, vnEmail) {
super($element, $); super($element, $);
this.clientSample = {
clientFk: this.$params.id,
companyId: this.vnConfig.companyFk
};
this.vnEmail = vnEmail; this.vnEmail = vnEmail;
} }
@ -19,10 +15,8 @@ class Controller extends Section {
set client(value) { set client(value) {
this._client = value; this._client = value;
if (value) { if (value)
this.clientSample.recipient = value.email; this.setClientSample(value);
this.getWorkerEmail();
}
} }
get companyId() { get companyId() {
@ -119,12 +113,17 @@ class Controller extends Section {
.then(() => this.$state.go('client.card.sample.index')); .then(() => this.$state.go('client.card.sample.index'));
} }
getWorkerEmail() { setClientSample(client) {
const userId = window.localStorage.currentUserWorkerId; const userId = window.localStorage.currentUserWorkerId;
const params = {filter: {where: {userFk: userId}}}; const params = {filter: {where: {userFk: userId}}};
this.$http.get('EmailUsers', params).then(res => { this.$http.get('EmailUsers', params).then(res => {
const [worker] = res && res.data; const [worker] = res && res.data;
this.clientSample.replyTo = worker.email; this.clientSample = {
clientFk: this.$params.id,
companyId: this.vnConfig.companyFk,
recipient: client.email,
replyTo: worker.email
};
}); });
} }
} }

View File

@ -191,15 +191,19 @@ describe('Client', () => {
}); });
}); });
describe('getWorkerEmail()', () => { describe('setClientSample()', () => {
it(`should perform a query and then set the replyTo property to the clientSample object`, () => { it(`should perform a query and then set the replyTo property to the clientSample object`, () => {
const client = {email: 'test@example.com'};
const expectedEmail = 'batman@arkhamcity.com'; const expectedEmail = 'batman@arkhamcity.com';
const serializedParams = $httpParamSerializer({filter: {where: {}}}); const serializedParams = $httpParamSerializer({filter: {where: {}}});
$httpBackend.expect('GET', `EmailUsers?${serializedParams}`).respond([{email: expectedEmail}]); $httpBackend.expect('GET', `EmailUsers?${serializedParams}`).respond([{email: expectedEmail}]);
controller.getWorkerEmail(); controller.setClientSample(client);
$httpBackend.flush(); $httpBackend.flush();
expect(controller.clientSample.replyTo).toEqual(expectedEmail); expect(controller.clientSample.replyTo).toEqual(expectedEmail);
expect(controller.clientSample.clientFk).toEqual(controller.$params.id);
expect(controller.clientSample.recipient).toEqual(client.email);
expect(controller.clientSample.companyId).toEqual(controller.vnConfig.companyFk);
}); });
}); });
}); });

View File

@ -87,6 +87,14 @@ module.exports = Self => {
for (let problem of problems) for (let problem of problems)
saleProblems.set(problem.saleFk, problem); saleProblems.set(problem.saleFk, problem);
const ticketLog = await Self.rawSql(`SELECT DISTINCT changedModelId
FROM ticketLog tl
WHERE changedModel = 'Sale'
AND originFk = ?`, [id], myOptions);
const salesWithLogs = ticketLog.map(sale => {
return sale.changedModelId;
});
for (let sale of sales) { for (let sale of sales) {
const problems = saleProblems.get(sale.id); const problems = saleProblems.get(sale.id);
const itemStock = itemAvailable.get(sale.itemFk); const itemStock = itemAvailable.get(sale.itemFk);
@ -98,6 +106,8 @@ module.exports = Self => {
sale.hasTicketRequest = problems.hasTicketRequest; sale.hasTicketRequest = problems.hasTicketRequest;
sale.hasComponentLack = problems.hasComponentLack; sale.hasComponentLack = problems.hasComponentLack;
} }
if (salesWithLogs.includes(sale.id))
sale.$hasLogs = true;
} }
return sales; return sales;

View File

@ -211,7 +211,8 @@
vn-none vn-none
vn-tooltip="History" vn-tooltip="History"
icon="history" icon="history"
ng-click="log.open()"> ng-click="log.open()"
ng-show="sale.$hasLogs">
</vn-icon-button> </vn-icon-button>
<vn-instance-log <vn-instance-log
vn-id="log" vn-id="log"