@colijnit/transaction 12.1.178 → 12.1.179

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/bundles/colijnit-transaction.umd.js +214 -167
  2. package/bundles/colijnit-transaction.umd.js.map +1 -1
  3. package/colijnit-transaction.metadata.json +1 -1
  4. package/esm2015/lib/component/checkout/checkout-overview-relation-edit/checkout-overview-relation-edit.component.js +45 -3
  5. package/esm2015/lib/component/checkout/checkout.component.js +10 -9
  6. package/esm2015/lib/component/transaction-card/transaction-card/transaction-card.component.js +1 -1
  7. package/esm2015/lib/component/transaction-card/transaction-card-sales-overview/transaction-card-sales-overview.module.js +15 -15
  8. package/esm2015/lib/component/transaction-header/transaction-header-popup/transaction-header-popup-relation.component.js +2 -2
  9. package/esm2015/lib/component/transaction-line/transaction-line/transaction-line.component.js +1 -1
  10. package/esm2015/lib/component/transaction-lines-side-panel/transaction-lines-side-panel/transaction-lines-side-panel.component.js +1 -1
  11. package/esm2015/lib/component/transaction-search/transaction-filter/transaction-filter/transaction-filter.component.js +3 -3
  12. package/esm2015/lib/component/transaction-search/transaction-search-grid/transaction-search-grid/transaction-search-grid.component.js +3 -3
  13. package/esm2015/lib/component/transaction-search/transaction-search-tile/transaction-search-tile/transaction-search-tile.component.js +3 -3
  14. package/esm2015/lib/component/transaction-tags/transaction-tags.component.js +17 -6
  15. package/esm2015/lib/service/pending-reason.service.js +6 -6
  16. package/esm2015/lib/service/relation-suggestions.service.js +3 -2
  17. package/esm2015/lib/service/transaction-base.service.js +5 -3
  18. package/esm2015/lib/service/transaction.service.js +37 -50
  19. package/esm2015/lib/transaction-version.js +3 -3
  20. package/fesm2015/colijnit-transaction.js +117 -75
  21. package/fesm2015/colijnit-transaction.js.map +1 -1
  22. package/lib/component/checkout/checkout-overview-relation-edit/checkout-overview-relation-edit.component.d.ts +4 -0
  23. package/lib/component/transaction-search/transaction-filter/transaction-filter/transaction-filter.component.d.ts +2 -2
  24. package/lib/component/transaction-search/transaction-search-grid/transaction-search-grid/transaction-search-grid.component.d.ts +3 -3
  25. package/lib/component/transaction-search/transaction-search-tile/transaction-search-tile/transaction-search-tile.component.d.ts +3 -3
  26. package/lib/component/transaction-tags/transaction-tags.component.d.ts +4 -1
  27. package/lib/service/relation-suggestions.service.d.ts +1 -1
  28. package/package.json +1 -1
@@ -3,8 +3,8 @@ export class Version {
3
3
  constructor() {
4
4
  this.name = "@colijnit/transaction";
5
5
  this.description = "Colijn IT transaction package";
6
- this.symVer = "12.1.178";
7
- this.publishDate = "27-12-2023 17:14:05";
6
+ this.symVer = "12.1.179";
7
+ this.publishDate = "28-12-2023 18:39:19";
8
8
  }
9
9
  }
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNhY3Rpb24tdmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3RyYW5zYWN0aW9uL3NyYy9saWIvdHJhbnNhY3Rpb24tdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSx1REFBdUQ7QUFDdkQsTUFBTSxPQUFPLE9BQU87SUFBcEI7UUFDUyxTQUFJLEdBQUcsdUJBQXVCLENBQUM7UUFDL0IsZ0JBQVcsR0FBRywrQkFBK0IsQ0FBQztRQUM5QyxXQUFNLEdBQUcsVUFBVSxDQUFDO1FBQ3BCLGdCQUFXLEdBQUcscUJBQXFCLENBQUM7SUFDN0MsQ0FBQztDQUFBIiwic291cmNlc0NvbnRlbnQiOlsiLy8gdGhpcyBmaWxlIGlzIGR5bmFtaWNhbGx5IGNyZWF0ZWQsIGRvIG5vdCBjaGFuZ2UgdGhpc1xuZXhwb3J0IGNsYXNzIFZlcnNpb24ge1xuICBwdWJsaWMgbmFtZSA9IFwiQGNvbGlqbml0L3RyYW5zYWN0aW9uXCI7XG4gIHB1YmxpYyB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209
  constructor() {
210
210
  this.name = "@colijnit/transaction";
211
211
  this.description = "Colijn IT transaction package";
212
- this.symVer = "12.1.178";
213
- this.publishDate = "27-12-2023 17:14:05";
212
+ this.symVer = "12.1.179";
213
+ this.publishDate = "28-12-2023 18:39:19";
214
214
  }
215
215
  }
216
216
 
@@ -7443,7 +7443,7 @@ class TransactionBaseService extends BaseModuleService {
7443
7443
  if (response && response.isSuccess) {
7444
7444
  this.resetLockTransaction();
7445
7445
  if (rememberTransaction) {
7446
- this.rememberCurrentTransaction(response);
7446
+ yield this.rememberCurrentTransaction(response);
7447
7447
  }
7448
7448
  }
7449
7449
  return response;
@@ -7574,7 +7574,9 @@ class TransactionBaseService extends BaseModuleService {
7574
7574
  this.checkRefTransaction(); // todo: get from the header status
7575
7575
  if (this.getRelationOnRememberCurrentTransaction) {
7576
7576
  if (this.currentTransaction.transactionInfo.relation && this.currentTransaction.transactionInfo.relation.relationId) {
7577
- yield this._getRelation(this.currentTransaction.transactionInfo.relation);
7577
+ if (!this.relation || this.relation.relationId !== this.currentTransaction.transactionInfo.relation.relationId) {
7578
+ yield this._getRelation(this.currentTransaction.transactionInfo.relation);
7579
+ }
7578
7580
  }
7579
7581
  else {
7580
7582
  this.relation = new CustomerFullObject();
@@ -7755,7 +7757,7 @@ class PendingReasonService extends TransactionBaseService {
7755
7757
  return this.saveTransactionAndCommit(response);
7756
7758
  }
7757
7759
  else { // just replace transaction object
7758
- this.rememberCurrentTransaction(response);
7760
+ yield this.rememberCurrentTransaction(response);
7759
7761
  }
7760
7762
  }
7761
7763
  return success;
@@ -7787,7 +7789,7 @@ class PendingReasonService extends TransactionBaseService {
7787
7789
  }
7788
7790
  else {
7789
7791
  if (rememberTransaction) {
7790
- this.rememberCurrentTransaction(response);
7792
+ yield this.rememberCurrentTransaction(response);
7791
7793
  }
7792
7794
  }
7793
7795
  }
@@ -7908,9 +7910,9 @@ class PendingReasonService extends TransactionBaseService {
7908
7910
  _cancelArticle(uuid) {
7909
7911
  return __awaiter(this, void 0, void 0, function* () {
7910
7912
  this.cancelAddTransactionLine(uuid)
7911
- .then((response) => {
7912
- this.rememberCurrentTransaction(response);
7913
- });
7913
+ .then((response) => __awaiter(this, void 0, void 0, function* () {
7914
+ yield this.rememberCurrentTransaction(response);
7915
+ }));
7914
7916
  });
7915
7917
  }
7916
7918
  }
@@ -8511,7 +8513,7 @@ class TransactionService extends PendingReasonService {
8511
8513
  }
8512
8514
  // await this.relationService.commit();
8513
8515
  if (!this.currentTransaction.transactionInfo.relation || (this.currentTransaction.transactionInfo.relation.relationId !== this.relation.relationId)) {
8514
- const response = yield this.addRelationToTransaction(this.relation.relationId);
8516
+ yield this.addRelationToTransaction(this.relation.relationId);
8515
8517
  }
8516
8518
  return true;
8517
8519
  });
@@ -8527,17 +8529,14 @@ class TransactionService extends PendingReasonService {
8527
8529
  }
8528
8530
  createSalesOrder(request) {
8529
8531
  return __awaiter(this, void 0, void 0, function* () {
8530
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
8531
- yield this.checkBranch();
8532
- if (!this.currentBranch) {
8533
- return reject();
8534
- }
8535
- request.branchNr = this.currentBranch;
8536
- this.connector.createSalesOrder(request).then((response) => {
8537
- this.rememberCurrentTransaction(response);
8538
- resolve(true);
8539
- });
8540
- }));
8532
+ yield this.checkBranch();
8533
+ if (!this.currentBranch) {
8534
+ return false;
8535
+ }
8536
+ request.branchNr = this.currentBranch;
8537
+ const response = yield this.connector.createSalesOrder(request);
8538
+ yield this.rememberCurrentTransaction(response);
8539
+ return true;
8541
8540
  });
8542
8541
  }
8543
8542
  createCashRegisterOrder(request) {
@@ -8552,32 +8551,26 @@ class TransactionService extends PendingReasonService {
8552
8551
  }
8553
8552
  createPurchaseOrder(request) {
8554
8553
  return __awaiter(this, void 0, void 0, function* () {
8555
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
8556
- yield this.checkBranch();
8557
- if (!this.currentBranch) {
8558
- return reject();
8559
- }
8560
- request.branchNr = this.currentBranch;
8561
- this.connector.createPurchaseOrder(request).then((response) => {
8562
- this.rememberCurrentTransaction(response);
8563
- resolve(true);
8564
- });
8565
- }));
8554
+ yield this.checkBranch();
8555
+ if (!this.currentBranch) {
8556
+ return false;
8557
+ }
8558
+ request.branchNr = this.currentBranch;
8559
+ const response = yield this.connector.createPurchaseOrder(request);
8560
+ yield this.rememberCurrentTransaction(response);
8561
+ return true;
8566
8562
  });
8567
8563
  }
8568
8564
  createServiceOrder(request) {
8569
8565
  return __awaiter(this, void 0, void 0, function* () {
8570
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
8571
- yield this.checkBranch();
8572
- if (!this.currentBranch) {
8573
- return reject();
8574
- }
8575
- request.branchNr = this.currentBranch;
8576
- this.connector.createServiceOrder(request).then((response) => {
8577
- this.rememberCurrentTransaction(response);
8578
- resolve(true);
8579
- });
8580
- }));
8566
+ yield this.checkBranch();
8567
+ if (!this.currentBranch) {
8568
+ return false;
8569
+ }
8570
+ request.branchNr = this.currentBranch;
8571
+ const response = yield this.connector.createServiceOrder(request);
8572
+ yield this.rememberCurrentTransaction(response);
8573
+ return true;
8581
8574
  });
8582
8575
  }
8583
8576
  createSalesQuotation(request) {
@@ -8588,10 +8581,10 @@ class TransactionService extends PendingReasonService {
8588
8581
  return reject();
8589
8582
  }
8590
8583
  request.branchNr = this.currentBranch;
8591
- this.connector.createSalesQuotation(request).then((response) => {
8592
- this.rememberCurrentTransaction(response);
8584
+ this.connector.createSalesQuotation(request).then((response) => __awaiter(this, void 0, void 0, function* () {
8585
+ yield this.rememberCurrentTransaction(response);
8593
8586
  resolve(true);
8594
- });
8587
+ }));
8595
8588
  }));
8596
8589
  });
8597
8590
  }
@@ -8603,7 +8596,7 @@ class TransactionService extends PendingReasonService {
8603
8596
  }
8604
8597
  const response = yield this.connector.addRelationToTransaction(this.currentTransaction.transactionInfo.uuid, relationId);
8605
8598
  if (response) {
8606
- return this.handleHeaderOperationStatuses(response);
8599
+ return yield this.handleHeaderOperationStatuses(response);
8607
8600
  }
8608
8601
  return false;
8609
8602
  });
@@ -9621,23 +9614,19 @@ class TransactionService extends PendingReasonService {
9621
9614
  if (!this.currentTransaction || !this.currentTransaction.transactionInfo || !this.currentTransaction.transactionInfo.transactionNr) {
9622
9615
  const createMethod = this._createTransactionMethods.get(this.transactionKind);
9623
9616
  if (createMethod) {
9624
- return new Promise((resolve) => {
9625
- const request = new CreateTransactionRequest();
9626
- createMethod(request)
9627
- .then(() => {
9628
- resolve(true);
9629
- })
9630
- .catch(() => {
9631
- resolve(false);
9632
- });
9633
- });
9617
+ const request = new CreateTransactionRequest();
9618
+ this.getRelationOnRememberCurrentTransaction = false;
9619
+ yield createMethod(request);
9620
+ this.getRelationOnRememberCurrentTransaction = true;
9621
+ return true;
9634
9622
  }
9635
9623
  else {
9636
9624
  throwError("Failed to create transaction");
9625
+ return false;
9637
9626
  }
9638
9627
  }
9639
9628
  else {
9640
- return Promise.resolve(true);
9629
+ return true;
9641
9630
  }
9642
9631
  });
9643
9632
  }
@@ -9803,15 +9792,16 @@ class CheckoutComponent {
9803
9792
  }
9804
9793
  handleCreateTransaction(event) {
9805
9794
  return __awaiter(this, void 0, void 0, function* () {
9806
- let success = true;
9807
- if (this.stepper.activeStep === 0 && (yield this.handleRelationValidation())) {
9808
- success = yield this.service.saveRelation();
9809
- if (success && this.transactionType !== this.transKind.SalesQuotation) {
9810
- yield this.service.updateHeaderTransactionDefinitive(this.service.currentTransaction.transactionInfo.uuid, true, true);
9795
+ if (this.stepper.activeStep === 0) {
9796
+ if (yield this.handleRelationValidation()) {
9797
+ // success = await this.service.saveRelation();
9798
+ if (this.transactionType !== this.transKind.SalesQuotation) {
9799
+ yield this.service.updateHeaderTransactionDefinitive(this.service.currentTransaction.transactionInfo.uuid, true, true);
9800
+ }
9801
+ }
9802
+ else {
9803
+ return;
9811
9804
  }
9812
- }
9813
- if (!success) {
9814
- return;
9815
9805
  }
9816
9806
  const saveSuccess = yield this.service.saveTransactionAndCommit();
9817
9807
  if (saveSuccess) {
@@ -10132,7 +10122,8 @@ class RelationSuggestionsService {
10132
10122
  this._componentRef.destroy();
10133
10123
  }
10134
10124
  }
10135
- init() {
10125
+ init(relationKind) {
10126
+ this.relationKind = relationKind;
10136
10127
  if (this._componentRef) {
10137
10128
  this._componentRef.destroy();
10138
10129
  }
@@ -10247,7 +10238,7 @@ class CheckoutOverviewRelationEditComponent {
10247
10238
  if (this._relation instanceof CustomerFullObject) {
10248
10239
  this.customerGroup = this._relation.customerGroup;
10249
10240
  }
10250
- this.address = this._relation.getFirstAddressOrCreateNew();
10241
+ this.address = this._getFirstActiveAddressOrCreateNew(this._relation);
10251
10242
  if (this.address) {
10252
10243
  this.deliveryAddressNawNr = this.address.nawNr;
10253
10244
  this.deliveryAddressChange.emit(this.deliveryAddressNawNr);
@@ -10273,7 +10264,7 @@ class CheckoutOverviewRelationEditComponent {
10273
10264
  }
10274
10265
  ngOnInit() {
10275
10266
  return __awaiter(this, void 0, void 0, function* () {
10276
- this._suggestionsService.init();
10267
+ this._suggestionsService.init(this._relationKind);
10277
10268
  this._subs.push(this._screenConfigService.configSet.subscribe((configObjects) => {
10278
10269
  if (configObjects && configObjects.length > 0) {
10279
10270
  this.showPreferences = this._screenConfigService.getObjectConfigurationFor(this.cfgNames.RelationPreferencesHeader).immediatelyVisible();
@@ -10371,6 +10362,47 @@ class CheckoutOverviewRelationEditComponent {
10371
10362
  this.invoiceAddressNawNr = this.deliveryAddressNawNr;
10372
10363
  this.invoiceAddressChange.next(this.invoiceAddressNawNr);
10373
10364
  }
10365
+ _getFirstActiveAddressOrCreateNew(relation) {
10366
+ if (!relation.addresses || relation.addresses.length === 0) {
10367
+ return this._createNewAddress(relation);
10368
+ }
10369
+ const firstAvailableAddress = this._getFirstAddress(relation, [
10370
+ AddressType.DeliveryAddress,
10371
+ AddressType.BillingAddress,
10372
+ AddressType.VisitingAddress,
10373
+ AddressType.MailingAddress,
10374
+ AddressType.NursingAddress
10375
+ ]);
10376
+ return firstAvailableAddress ? firstAvailableAddress : this._createNewAddress(relation);
10377
+ }
10378
+ _getFirstAddress(relation, order = []) {
10379
+ const activeAddresses = relation.addresses.filter(a => a.isActive);
10380
+ const len = order.length;
10381
+ for (let i = 0; i < len; i++) {
10382
+ const address = this._getFirstAddressOfType(activeAddresses, order[i]);
10383
+ if (address) {
10384
+ return address;
10385
+ }
10386
+ }
10387
+ }
10388
+ _getFirstAddressOfType(addresses, type) {
10389
+ if (addresses) {
10390
+ const len = addresses.length;
10391
+ for (let i = 0; i < len; i++) {
10392
+ if (addresses[i].addressType === type) {
10393
+ return addresses[i];
10394
+ }
10395
+ }
10396
+ }
10397
+ }
10398
+ _createNewAddress(relation) {
10399
+ const address = new Address();
10400
+ address.addressType = AddressType.DeliveryAddress;
10401
+ address.startDate = new Date();
10402
+ address.sequence = relation.getNextAddressSequence();
10403
+ relation.addresses.push(address);
10404
+ return address;
10405
+ }
10374
10406
  _setCountryNameToAddress(address) {
10375
10407
  return __awaiter(this, void 0, void 0, function* () {
10376
10408
  if (address.countryId && !address.countryName) {
@@ -27638,7 +27670,7 @@ class TransactionHeaderPopupRelationComponent extends TransactionHeaderPopupBase
27638
27670
  });
27639
27671
  return __awaiter(this, void 0, void 0, function* () {
27640
27672
  _super.ngOnInit.call(this);
27641
- this._suggestionsService.init();
27673
+ this._suggestionsService.init(this.relation.relationType);
27642
27674
  this.subs.push(this.screenConfigService.configSet.subscribe((configObjects) => {
27643
27675
  if (configObjects && configObjects.length > 0) {
27644
27676
  this.categories.length = 0;
@@ -41268,9 +41300,10 @@ TransactionLineGridModule.decorators = [
41268
41300
  ];
41269
41301
 
41270
41302
  class TransactionTagsComponent {
41271
- constructor(_transactionService, _transactionEventService, iconCacheService) {
41303
+ constructor(_transactionService, _transactionEventService, _transactionConnectorService, iconCacheService) {
41272
41304
  this._transactionService = _transactionService;
41273
41305
  this._transactionEventService = _transactionEventService;
41306
+ this._transactionConnectorService = _transactionConnectorService;
41274
41307
  this.iconCacheService = iconCacheService;
41275
41308
  this.icons = Icon;
41276
41309
  this.tags = [];
@@ -41279,11 +41312,17 @@ class TransactionTagsComponent {
41279
41312
  this.showEditTagsDialog = false;
41280
41313
  this._table = TableName.Transactions;
41281
41314
  this._subs = [];
41315
+ this._loaded = false;
41282
41316
  this._subs.push(this._transactionEventService.transactionSet.subscribe((transaction) => {
41283
41317
  if (transaction && transaction.transactionInfo.id) {
41284
41318
  this._key = transaction.transactionInfo.transactionNr.toString();
41285
41319
  this._getJoinedTags();
41286
41320
  }
41321
+ }), this._transactionConnectorService.connectionInitialized.subscribe((initialized) => {
41322
+ if (initialized) {
41323
+ this._loaded = true;
41324
+ this._getJoinedTags();
41325
+ }
41287
41326
  }));
41288
41327
  }
41289
41328
  showClass() {
@@ -41293,10 +41332,12 @@ class TransactionTagsComponent {
41293
41332
  this._subs.forEach(s => s.unsubscribe());
41294
41333
  }
41295
41334
  _getJoinedTags() {
41296
- this._transactionService.getJoinedTags(this._table, this._key).then((tags) => {
41297
- this.tags = tags;
41298
- this.editingTags = [...tags];
41299
- });
41335
+ if (this._key && this._loaded && this.tags.length === 0) {
41336
+ this._transactionService.getJoinedTags(this._table, this._key).then((tags) => {
41337
+ this.tags = tags;
41338
+ this.editingTags = [...tags];
41339
+ });
41340
+ }
41300
41341
  }
41301
41342
  _getTabCategory() {
41302
41343
  switch (this._transactionService.transactionKind) {
@@ -41362,6 +41403,7 @@ TransactionTagsComponent.decorators = [
41362
41403
  TransactionTagsComponent.ctorParameters = () => [
41363
41404
  { type: TransactionService },
41364
41405
  { type: TransactionEventService },
41406
+ { type: TransactionConnectorService },
41365
41407
  { type: IconCacheService }
41366
41408
  ];
41367
41409
  TransactionTagsComponent.propDecorators = {