4998-claim_photos_back #1343

Merged
alexm merged 4 commits from 4998-claim_photos_back into dev 2023-02-24 08:15:36 +00:00
6 changed files with 19 additions and 15 deletions
Showing only changes of commit bd225e6824 - Show all commits

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

@ -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

@ -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);
}); });
}); });
}); });