hasToInvoice gets enabled with isActive
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-11-19 10:51:28 +01:00
parent fcca5c5eab
commit e8df57dae2
2 changed files with 18 additions and 0 deletions

View File

@ -8,6 +8,14 @@ export default class Controller extends Section {
const hasContactData = this.client.email || this.client.phone || this.client.mobile;
const hasChangedTaxData = !orgData.isTaxDataChecked && this.client.isTaxDataChecked;
const shouldInvoice = this.client.isActive && !this.client.hasToInvoice;
const clientActivation = this.client.isActive && (orgData.isActive != this.client.isActive);
if (shouldInvoice && clientActivation) {
this.client.hasToInvoice = true;
this.vnApp.showMessage(this.$t('Client invoices enabled'));
}
if (hasChangedTaxData && hasContactData)
this.checkExistingClient();
else this.save();

View File

@ -50,6 +50,16 @@ describe('Client', () => {
expect(controller.save).not.toHaveBeenCalledWith();
expect(controller.checkExistingClient).toHaveBeenCalledWith();
});
it('should enable the hasToInvoice property any time the form activates the client with isActive', () => {
$scope.watcher.orgData.isActive = false;
controller.client.isActive = true;
controller.client.hasToInvoice = false;
controller.onSubmit();
expect(controller.client.hasToInvoice).toBe(true);
});
});
describe('checkExistingClient()', () => {