Merge branch 'dev' into 2408-item_request
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
b34545b316
|
@ -2,6 +2,9 @@
|
|||
"Account": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"AccountingType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Bank": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "AccountingType",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "accountingType"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"description": {
|
||||
"type": "String",
|
||||
"required": true
|
||||
},
|
||||
"receiptDescription": {
|
||||
"type": "String",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}]
|
||||
}
|
|
@ -13,28 +13,38 @@
|
|||
"description": "Identifier"
|
||||
},
|
||||
"bank": {
|
||||
"type": "string",
|
||||
"type": "String",
|
||||
"required": true
|
||||
},
|
||||
"account": {
|
||||
"type": "string",
|
||||
"type": "String",
|
||||
"required": true
|
||||
},
|
||||
"cash": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
"accountingTypeFk": {
|
||||
"type": "Number",
|
||||
"required": true,
|
||||
"mysql": {
|
||||
"columnName": "cash"
|
||||
}
|
||||
},
|
||||
"entityFk": {
|
||||
"type": "string",
|
||||
"type": "Number",
|
||||
"required": true
|
||||
},
|
||||
"isActive": {
|
||||
"type": "string",
|
||||
"type": "Boolean",
|
||||
"required": true
|
||||
},
|
||||
"currencyFk": {
|
||||
"type": "string",
|
||||
"type": "Number",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"accountingType": {
|
||||
"type": "belongsTo",
|
||||
"model": "AccountingType",
|
||||
"foreignKey": "accountingTypeFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE `vn`.`accountingType`
|
||||
ADD COLUMN `receiptDescription` VARCHAR(50) NULL AFTER `description`;
|
|
@ -116,13 +116,13 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park
|
|||
('GVC', '1', '0', '1', '0', '106'),
|
||||
('HEJ', '2', '0', '1', '0', '106');
|
||||
|
||||
INSERT INTO `vn`.`accountingType`(`id`, `description`)
|
||||
INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`)
|
||||
VALUES
|
||||
(1, 'Digital money'),
|
||||
(2, 'Cash'),
|
||||
(3, 'Card'),
|
||||
(4, 'Stolen Money'),
|
||||
(5, 'Miscellaneous');
|
||||
(1, 'Digital money', ''),
|
||||
(2, 'Cash', 'Cash'),
|
||||
(3, 'Card', 'Pay on receipt'),
|
||||
(4, 'Stolen Money', ''),
|
||||
(5, 'Miscellaneous', '');
|
||||
|
||||
INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
|
||||
VALUES
|
||||
|
@ -133,8 +133,8 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
|
|||
|
||||
INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`)
|
||||
VALUES
|
||||
(1, 'Pay on receipt', '0000000000', 4, 0, 1, 1),
|
||||
(2, 'Cash', '1111111111', 1, 0, 1, 1);
|
||||
(1, 'Pay on receipt', '0000000000', 3, 0, 1, 1),
|
||||
(2, 'Cash', '1111111111', 2, 0, 1, 1);
|
||||
|
||||
INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
|
||||
VALUES
|
||||
|
|
|
@ -189,8 +189,9 @@ export default {
|
|||
newPaymentBank: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.receipt.bankFk"]',
|
||||
newPaymentAmount: '.vn-dialog.shown vn-input-number[ng-model="$ctrl.receipt.amountPaid"]',
|
||||
saveButton: '.vn-dialog.shown [response="accept"]',
|
||||
firstBalanceLine: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)'
|
||||
|
||||
firstLineBalance: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)',
|
||||
firstLineReference: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable',
|
||||
firstLineReferenceInput: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable > div > field > vn-textfield'
|
||||
},
|
||||
webPayment: {
|
||||
confirmFirstPaymentButton: 'vn-client-web-payment vn-tr:nth-child(1) vn-icon-button[icon="done_all"]',
|
||||
|
|
|
@ -53,15 +53,28 @@ describe('Client balance path', () => {
|
|||
expect(message.type).toBe('success');
|
||||
});
|
||||
|
||||
it('should check balance is now 0 and the company is now VNL becouse the user local settings were removed', async() => {
|
||||
it('should edit the 1st line reference', async() => {
|
||||
await page.waitToClick(selectors.clientBalance.firstLineReference);
|
||||
await page.write(selectors.clientBalance.firstLineReferenceInput, 'Miscellaneous payment');
|
||||
await page.keyboard.press('Enter');
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.type).toBe('success');
|
||||
});
|
||||
|
||||
it('should check balance is now 0, the reference was saved and the company is now VNL becouse the user local settings were removed', async() => {
|
||||
await page.waitForSpinnerLoad();
|
||||
let company = await page
|
||||
.waitToGetProperty(selectors.clientBalance.company, 'value');
|
||||
|
||||
let reference = await page
|
||||
.waitToGetProperty(selectors.clientBalance.firstLineReference, 'innerText');
|
||||
|
||||
let firstBalanceLine = await page
|
||||
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
||||
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
|
||||
|
||||
expect(company).toEqual('VNL');
|
||||
expect(reference).toEqual('Miscellaneous payment');
|
||||
expect(firstBalanceLine).toContain('0.00');
|
||||
});
|
||||
|
||||
|
@ -76,7 +89,7 @@ describe('Client balance path', () => {
|
|||
|
||||
it('should check balance is now -100', async() => {
|
||||
let result = await page
|
||||
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
||||
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
|
||||
|
||||
expect(result).toContain('-€100.00');
|
||||
});
|
||||
|
@ -92,7 +105,7 @@ describe('Client balance path', () => {
|
|||
|
||||
it('should check balance is now 50', async() => {
|
||||
let result = await page
|
||||
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
||||
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
|
||||
|
||||
expect(result).toEqual('€50.00');
|
||||
});
|
||||
|
|
|
@ -42,11 +42,11 @@ module.exports = Self => {
|
|||
r.workerFk,
|
||||
c.code company,
|
||||
r.created,
|
||||
r.invoiceFk ref,
|
||||
r.invoiceFk description,
|
||||
NULL debit,
|
||||
r.amountPaid credit,
|
||||
r.bankFk,
|
||||
u.nickname userNickname,
|
||||
u.name userName,
|
||||
r.clientFk,
|
||||
FALSE hasPdf,
|
||||
FALSE isInvoice
|
||||
|
|
|
@ -17,11 +17,17 @@
|
|||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
url="Banks"
|
||||
label="Bank"
|
||||
url="Banks"
|
||||
show-field="bank"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.receipt.bankFk">
|
||||
fields="['accountingTypeFk']"
|
||||
include="{relation: 'accountingType'}"
|
||||
order="id"
|
||||
ng-model="$ctrl.receipt.bankFk"
|
||||
search-function="{or: [{id: $search}, {bank: {like: '%'+ $search +'%'}}]}"
|
||||
selection="$ctrl.bankSelection">
|
||||
<tpl-item>{{id}}: {{bank}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-input-number
|
||||
vn-focus
|
||||
|
@ -31,6 +37,13 @@
|
|||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
label="Reference"
|
||||
ng-model="$ctrl.receipt.description"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
|
|
|
@ -50,6 +50,19 @@ class Controller extends Dialog {
|
|||
return this.receipt.description;
|
||||
}
|
||||
|
||||
get bankSelection() {
|
||||
return this._bankSelection;
|
||||
}
|
||||
|
||||
set bankSelection(value) {
|
||||
this._bankSelection = value;
|
||||
|
||||
if (value) {
|
||||
const accountingType = value.accountingType;
|
||||
this.receipt.description = accountingType && accountingType.receiptDescription;
|
||||
}
|
||||
}
|
||||
|
||||
getAmountPaid() {
|
||||
const filter = {
|
||||
where: {
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
import './index';
|
||||
|
||||
describe('Client', () => {
|
||||
describe('Component vnClientBalancCreate', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $httpParamSerializer;
|
||||
|
||||
beforeEach(ngModule('client'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$httpParamSerializer = _$httpParamSerializer_;
|
||||
let $scope = $rootScope.$new();
|
||||
const $element = angular.element('<vn-client-balance-create></vn-client-balance-create>');
|
||||
const $transclude = {
|
||||
$$boundTransclude: {
|
||||
$$slots: []
|
||||
}
|
||||
};
|
||||
controller = $componentController('vnClientBalanceCreate', {$element, $scope, $transclude});
|
||||
controller.receipt = {
|
||||
clientFk: 101,
|
||||
companyFk: 442
|
||||
};
|
||||
}));
|
||||
|
||||
describe('bankSelection() setter', () => {
|
||||
it('should set the receipt description property', () => {
|
||||
controller.bankSelection = {
|
||||
id: 1,
|
||||
bank: 'Cash',
|
||||
accountingType: {
|
||||
id: 2,
|
||||
receiptDescription: 'Cash'
|
||||
}
|
||||
};
|
||||
|
||||
expect(controller.receipt.description).toEqual('Cash');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAmountPaid()', () => {
|
||||
it('should make an http GET query and then set the receipt amountPaid property', () => {
|
||||
controller.$params = {id: 101};
|
||||
const receipt = controller.receipt;
|
||||
const filter = {
|
||||
where: {
|
||||
clientFk: 101,
|
||||
companyFk: 442
|
||||
}
|
||||
};
|
||||
const serializedParams = $httpParamSerializer({filter});
|
||||
$httpBackend.expect('GET', `ClientRisks?${serializedParams}`,).respond([{amount: 20}]);
|
||||
controller.getAmountPaid();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(receipt.amountPaid).toEqual(20);
|
||||
});
|
||||
});
|
||||
|
||||
describe('responseHandler()', () => {
|
||||
it('should make an http POST query and then call to the parent responseHandler() method', () => {
|
||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||
|
||||
controller.$params = {id: 101};
|
||||
|
||||
$httpBackend.expect('POST', `Receipts`,).respond({id: 1});
|
||||
controller.responseHandler('accept');
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -68,25 +68,33 @@
|
|||
<span
|
||||
vn-click-stop="workerDescriptor.show($event, balance.workerFk)"
|
||||
class="link">
|
||||
{{::balance.userNickname}}
|
||||
{{::balance.userName}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td expand>
|
||||
<div ng-show="::balance.ref">
|
||||
<vn-td-editable disabled="balance.isInvoice || !$ctrl.isAdministrative" expand>
|
||||
<text>
|
||||
<div ng-show="::balance.description">
|
||||
<span
|
||||
ng-if="balance.isInvoice"
|
||||
title="{{'BILL' | translate: {ref: balance.ref} }}"
|
||||
title="{{'BILL' | translate: {ref: balance.description} }}"
|
||||
vn-click-stop="$ctrl.showInvoiceOutDescriptor($event, balance)"
|
||||
class="link">
|
||||
{{'BILL' | translate: {ref: balance.ref} }}
|
||||
{{'BILL' | translate: {ref: balance.description} }}
|
||||
</span>
|
||||
<span
|
||||
ng-if="!balance.isInvoice"
|
||||
title="{{::balance.ref}}">
|
||||
{{::balance.ref}}
|
||||
title="{{::balance.description}}">
|
||||
{{balance.description}}
|
||||
</span>
|
||||
</div>
|
||||
</vn-td>
|
||||
</text>
|
||||
<field>
|
||||
<vn-textfield vn-acl="administrative" class="dense" vn-focus
|
||||
ng-model="balance.description"
|
||||
on-change="$ctrl.changeDescription(balance)">
|
||||
</vn-textfield>
|
||||
</field>
|
||||
</vn-td-editable>
|
||||
<vn-td number>{{::balance.bankFk}}</vn-td>
|
||||
<vn-td number expand>{{::balance.debit | currency: 'EUR':2}}</vn-td>
|
||||
<vn-td number expand>{{::balance.credit | currency: 'EUR':2}}</vn-td>
|
||||
|
|
|
@ -39,6 +39,10 @@ class Controller extends Section {
|
|||
this.getBalances();
|
||||
}
|
||||
|
||||
get isAdministrative() {
|
||||
return this.aclService.hasAny(['administrative']);
|
||||
}
|
||||
|
||||
getData() {
|
||||
return this.$.model.applyFilter(null, {
|
||||
clientId: this.$params.id,
|
||||
|
@ -58,7 +62,7 @@ class Controller extends Section {
|
|||
return balance.companyFk === selectedCompany;
|
||||
});
|
||||
|
||||
return currentBalance.amount;
|
||||
return currentBalance && currentBalance.amount;
|
||||
}
|
||||
|
||||
getBalances() {
|
||||
|
@ -79,6 +83,13 @@ class Controller extends Section {
|
|||
|
||||
this.$.invoiceOutDescriptor.show(event.target, balance.id);
|
||||
}
|
||||
|
||||
changeDescription(balance) {
|
||||
const params = {description: balance.description};
|
||||
const endpoint = `Receipts/${balance.id}`;
|
||||
this.$http.patch(endpoint, params)
|
||||
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
|
|
@ -3,10 +3,12 @@ import './index';
|
|||
describe('Client', () => {
|
||||
describe('Component vnClientBalanceIndex', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(ngModule('client'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope) => {
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
let $scope = $rootScope.$new();
|
||||
const $element = angular.element('<vn-client-balance-index></vn-client-balance-index>');
|
||||
controller = $componentController('vnClientBalanceIndex', {$element, $scope});
|
||||
|
@ -133,5 +135,21 @@ describe('Client', () => {
|
|||
expect(controller.getBalances).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('changeDescription()', () => {
|
||||
it('should make an http PATCH query', () => {
|
||||
const expectedParams = {description: 'Web'};
|
||||
|
||||
$httpBackend.expect('PATCH', `Receipts/1`, expectedParams).respond(200);
|
||||
controller.changeDescription({
|
||||
id: 1,
|
||||
description: 'Web',
|
||||
accountingType: {
|
||||
description: 'Cash'
|
||||
}
|
||||
});
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue