@colijnit/transaction 256.1.6 → 256.1.7

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 (22) hide show
  1. package/bundles/colijnit-transaction.umd.js +112 -78
  2. package/bundles/colijnit-transaction.umd.js.map +1 -1
  3. package/colijnit-transaction.metadata.json +1 -1
  4. package/esm2015/lib/component/add-product/add-product.component.js +5 -5
  5. package/esm2015/lib/component/dialog/catalog/dialog-catalog/dialog-catalog.component.js +9 -2
  6. package/esm2015/lib/component/dialog/transaction-line/dialog-transaction-line-warehouse-cc/dialog-direct-sell.component.js +87 -68
  7. package/esm2015/lib/component/transaction-header-fields/transaction-header-deposit-amount.component.js +16 -11
  8. package/esm2015/lib/component/transaction-line-fields/transaction-line-supplier-button.component.js +2 -2
  9. package/esm2015/lib/service/transaction-connector-adapter.service.js +5 -5
  10. package/esm2015/lib/service/transaction-connector.service.js +5 -5
  11. package/esm2015/lib/service/transaction.service.js +11 -11
  12. package/esm2015/lib/transaction-version.js +3 -3
  13. package/fesm2015/colijnit-transaction.js +132 -103
  14. package/fesm2015/colijnit-transaction.js.map +1 -1
  15. package/lib/component/dialog/catalog/dialog-catalog/dialog-catalog.component.d.ts +5 -1
  16. package/lib/component/dialog/transaction-line/dialog-transaction-line-warehouse-cc/dialog-direct-sell.component.d.ts +8 -4
  17. package/lib/service/transaction-connector-adapter.service.d.ts +2 -2
  18. package/lib/service/transaction-connector.service.d.ts +2 -2
  19. package/lib/service/transaction.service.d.ts +5 -5
  20. package/package.json +1 -1
  21. package/colijnit-transaction-256.1.4.tgz +0 -0
  22. package/colijnit-transaction-256.1.5.tgz +0 -0
@@ -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 = "256.1.6";
7
- this.publishDate = "28-10-2024 10:33:24";
6
+ this.symVer = "256.1.7";
7
+ this.publishDate = "29-10-2024 18:11:52";
8
8
  }
9
9
  }
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNhY3Rpb24tdmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3RyYW5zYWN0aW9uL3NyYy9saWIvdHJhbnNhY3Rpb24tdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSx1REFBdUQ7QUFDdkQsTUFBTSxPQUFPLE9BQU87SUFBcEI7UUFDUyxTQUFJLEdBQUcsdUJBQXVCLENBQUM7UUFDL0IsZ0JBQVcsR0FBRywrQkFBK0IsQ0FBQztRQUM5QyxXQUFNLEdBQUcsU0FBUyxDQUFDO1FBQ25CLGdCQUFXLEdBQUcscUJBQXFCLENBQUM7SUFDN0MsQ0FBQztDQUFBIiwic291cmNlc0NvbnRlbnQiOlsiLy8gdGhpcyBmaWxlIGlzIGR5bmFtaWNhbGx5IGNyZWF0ZWQsIGRvIG5vdCBjaGFuZ2UgdGhpc1xuZXhwb3J0IGNsYXNzIFZlcnNpb24ge1xuICBwdWJsaWMgbmFtZSA9IFwiQGNvbGlqbml0L3RyYW5zYWN0aW9uXCI7XG4gIHB1YmxpYyBkZXNjcmlwdGlvbiA9IFwiQ29saWpuIElUIHRyYW5zYWN0aW9uIHBhY2thZ2VcIjtcbiAgcHVibGljIHN5bVZlciA9IFwiMjU2LjEuNlwiO1xuICBwdWJsaWMgcHVibGlzaERhdGUgPSBcIjI4LTEwLTIwMjQgMTA6MzM6MjRcIjtcbn0iXX0=
10
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNhY3Rpb24tdmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3RyYW5zYWN0aW9uL3NyYy9saWIvdHJhbnNhY3Rpb24tdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSx1REFBdUQ7QUFDdkQsTUFBTSxPQUFPLE9BQU87SUFBcEI7UUFDUyxTQUFJLEdBQUcsdUJBQXVCLENBQUM7UUFDL0IsZ0JBQVcsR0FBRywrQkFBK0IsQ0FBQztRQUM5QyxXQUFNLEdBQUcsU0FBUyxDQUFDO1FBQ25CLGdCQUFXLEdBQUcscUJBQXFCLENBQUM7SUFDN0MsQ0FBQztDQUFBIiwic291cmNlc0NvbnRlbnQiOlsiLy8gdGhpcyBmaWxlIGlzIGR5bmFtaWNhbGx5IGNyZWF0ZWQsIGRvIG5vdCBjaGFuZ2UgdGhpc1xuZXhwb3J0IGNsYXNzIFZlcnNpb24ge1xuICBwdWJsaWMgbmFtZSA9IFwiQGNvbGlqbml0L3RyYW5zYWN0aW9uXCI7XG4gIHB1YmxpYyBkZXNjcmlwdGlvbiA9IFwiQ29saWpuIElUIHRyYW5zYWN0aW9uIHBhY2thZ2VcIjtcbiAgcHVibGljIHN5bVZlciA9IFwiMjU2LjEuN1wiO1xuICBwdWJsaWMgcHVibGlzaERhdGUgPSBcIjI5LTEwLTIwMjQgMTg6MTE6NTJcIjtcbn0iXX0=
@@ -278,8 +278,8 @@ class Version {
278
278
  constructor() {
279
279
  this.name = "@colijnit/transaction";
280
280
  this.description = "Colijn IT transaction package";
281
- this.symVer = "256.1.6";
282
- this.publishDate = "28-10-2024 10:33:24";
281
+ this.symVer = "256.1.7";
282
+ this.publishDate = "29-10-2024 18:11:52";
283
283
  }
284
284
  }
285
285
 
@@ -2996,10 +2996,10 @@ class TransactionConnectorAdapterService {
2996
2996
  });
2997
2997
  });
2998
2998
  }
2999
- addTransactionLine(uuid, articleNo, quantity, aboveLineNr, belowLineNr) {
2999
+ addTransactionLine(uuid, articleNo, quantity, aboveLineNr, belowLineNr, showLoader = false) {
3000
3000
  return __awaiter(this, void 0, void 0, function* () {
3001
3001
  return new Promise((resolve, reject) => {
3002
- return this.connector.addTransactionLine(uuid, articleNo, quantity, aboveLineNr, belowLineNr).then((result) => {
3002
+ return this.connector.addTransactionLine(uuid, articleNo, quantity, aboveLineNr, belowLineNr, showLoader).then((result) => {
3003
3003
  if (result.validationResult && result.validationResult.success) {
3004
3004
  resolve(this._boFactory.makeWithRawBackendData(TransactionInfoResponse, result.resultObject));
3005
3005
  }
@@ -5738,9 +5738,9 @@ class TransactionConnectorAdapterService {
5738
5738
  }
5739
5739
  });
5740
5740
  }
5741
- addExternalCatalogArticlesToTransaction(uuid, catalogId, rawData) {
5741
+ addExternalCatalogArticlesToTransaction(uuid, catalogId, rawData, showLoader = false) {
5742
5742
  return __awaiter(this, void 0, void 0, function* () {
5743
- const response = yield this.connector.addExternalCatalogArticlesToTransaction(uuid, catalogId, rawData);
5743
+ const response = yield this.connector.addExternalCatalogArticlesToTransaction(uuid, catalogId, rawData, showLoader);
5744
5744
  if (response && response.validationResult && response.validationResult.success) {
5745
5745
  return this._boFactory.makeWithRawBackendData(TransactionInfoResponse, response.resultObject);
5746
5746
  }
@@ -6620,9 +6620,9 @@ class TransactionConnectorService {
6620
6620
  return this._adapterService.addWebSessionTransactionLine(transactionUuid, articleNumber, quantity);
6621
6621
  });
6622
6622
  }
6623
- addTransactionLine(uuid, articleNo, quantity, aboveLineNr, belowLineNr) {
6623
+ addTransactionLine(uuid, articleNo, quantity, aboveLineNr, belowLineNr, showLoader = false) {
6624
6624
  return __awaiter(this, void 0, void 0, function* () {
6625
- return this._adapterService.addTransactionLine(uuid, articleNo, quantity, aboveLineNr, belowLineNr);
6625
+ return this._adapterService.addTransactionLine(uuid, articleNo, quantity, aboveLineNr, belowLineNr, showLoader);
6626
6626
  });
6627
6627
  }
6628
6628
  addTextLineToTransaction(uuid, showOnDocuments, text, amount, articleBound, refArticleLineNr, aboveLineNr, belowLineNr) {
@@ -7650,9 +7650,9 @@ class TransactionConnectorService {
7650
7650
  return yield this._adapterService.copySalesQuotation(copyTransactionRequest);
7651
7651
  });
7652
7652
  }
7653
- addExternalCatalogArticlesToTransaction(uuid, catalogId, rawData) {
7653
+ addExternalCatalogArticlesToTransaction(uuid, catalogId, rawData, showLoader = false) {
7654
7654
  return __awaiter(this, void 0, void 0, function* () {
7655
- return yield this._adapterService.addExternalCatalogArticlesToTransaction(uuid, catalogId, rawData);
7655
+ return yield this._adapterService.addExternalCatalogArticlesToTransaction(uuid, catalogId, rawData, showLoader);
7656
7656
  });
7657
7657
  }
7658
7658
  addPaymentLineToTransaction(request) {
@@ -11272,9 +11272,9 @@ class TransactionService extends PendingReasonService {
11272
11272
  return this.connector.getArticleExtended(articleNr);
11273
11273
  });
11274
11274
  }
11275
- addArticle(articleNo, quantity = 1, aboveLineNr = 0, belowLineNr = 0, saveTransaction = true) {
11275
+ addArticle(articleNo, quantity = 1, aboveLineNr = 0, belowLineNr = 0, saveTransaction = true, showLoader = false) {
11276
11276
  return __awaiter(this, void 0, void 0, function* () {
11277
- const response = yield this.addTransactionLine(articleNo, quantity, aboveLineNr, belowLineNr);
11277
+ const response = yield this.addTransactionLine(articleNo, quantity, aboveLineNr, belowLineNr, showLoader);
11278
11278
  if (response !== null) {
11279
11279
  this.transactionDirty = true;
11280
11280
  return this.handleLineOperationStatuses(response, saveTransaction);
@@ -11284,7 +11284,7 @@ class TransactionService extends PendingReasonService {
11284
11284
  }
11285
11285
  });
11286
11286
  }
11287
- addTransactionLine(articleNo, quantity = 1, aboveLineNr = 0, belowLineNr = 0) {
11287
+ addTransactionLine(articleNo, quantity = 1, aboveLineNr = 0, belowLineNr = 0, showLoader = false) {
11288
11288
  return __awaiter(this, void 0, void 0, function* () {
11289
11289
  const created = yield this._checkAndCreateTransaction();
11290
11290
  if (!created) {
@@ -11293,7 +11293,7 @@ class TransactionService extends PendingReasonService {
11293
11293
  const lockSuccess = yield this.tryToLockTransaction(this.currentTransaction.transactionInfo.id, this.currentTransaction.transactionInfo.version);
11294
11294
  if (lockSuccess) {
11295
11295
  this.transactionLineAdded = true;
11296
- const response = yield this.connector.addTransactionLine(this.currentTransaction.transactionInfo.uuid, articleNo, quantity, aboveLineNr, belowLineNr);
11296
+ const response = yield this.connector.addTransactionLine(this.currentTransaction.transactionInfo.uuid, articleNo, quantity, aboveLineNr, belowLineNr, showLoader);
11297
11297
  return response;
11298
11298
  }
11299
11299
  else {
@@ -11309,22 +11309,22 @@ class TransactionService extends PendingReasonService {
11309
11309
  yield this.addArticle(artNr, jsonArticleObject.quantity);
11310
11310
  });
11311
11311
  }
11312
- addExternalCatalogArticle(request) {
11312
+ addExternalCatalogArticle(request, showLoader = false) {
11313
11313
  return __awaiter(this, void 0, void 0, function* () {
11314
- yield this.addExternalCatalogArticleWithRawData(request.catalogId, request.articleJson);
11314
+ yield this.addExternalCatalogArticleWithRawData(request.catalogId, request.articleJson, showLoader);
11315
11315
  });
11316
11316
  }
11317
- addExternalCatalogArticleFromGoodId(jsonArticleString) {
11317
+ addExternalCatalogArticleFromGoodId(jsonArticleString, showLoader = false) {
11318
11318
  return __awaiter(this, void 0, void 0, function* () {
11319
11319
  const jsonArticleObject = JSON.parse(jsonArticleString);
11320
- const response = yield this.addTransactionLine(jsonArticleObject.sku, jsonArticleObject.quantity);
11320
+ const response = yield this.addTransactionLine(jsonArticleObject.sku, jsonArticleObject.quantity, 0, 0, showLoader);
11321
11321
  const handled = yield this.handleLineOperationStatuses(response, true);
11322
11322
  if (handled && jsonArticleObject.price !== undefined) {
11323
11323
  yield this.updatePriceTransactionLine(response.transactionInfo.uuid, response.lineOperationStatuses[0].uuid, jsonArticleObject.price);
11324
11324
  }
11325
11325
  });
11326
11326
  }
11327
- addExternalCatalogArticleWithRawData(catalogId, jsonArticleString) {
11327
+ addExternalCatalogArticleWithRawData(catalogId, jsonArticleString, showLoader = false) {
11328
11328
  return __awaiter(this, void 0, void 0, function* () {
11329
11329
  const created = yield this._checkAndCreateTransaction();
11330
11330
  if (!created) {
@@ -11333,7 +11333,7 @@ class TransactionService extends PendingReasonService {
11333
11333
  const lockSuccess = yield this.tryToLockTransaction(this.currentTransaction.transactionInfo.id, this.currentTransaction.transactionInfo.version);
11334
11334
  if (lockSuccess) {
11335
11335
  this.transactionLineAdded = true;
11336
- const response = yield this.connector.addExternalCatalogArticlesToTransaction(this.currentTransaction.transactionInfo.uuid, catalogId, jsonArticleString);
11336
+ const response = yield this.connector.addExternalCatalogArticlesToTransaction(this.currentTransaction.transactionInfo.uuid, catalogId, jsonArticleString, showLoader);
11337
11337
  yield this.handleLineOperationStatuses(response, true);
11338
11338
  }
11339
11339
  });
@@ -28784,7 +28784,7 @@ class TransactionLineSupplierButtonComponent extends TransactionBaseComponent {
28784
28784
  this._getSupplierDescription();
28785
28785
  }
28786
28786
  _getSupplierDescription() {
28787
- if (this.transactionLine && this.transactionLine.isArticle && this.transactionLine.supplierDescription === undefined && this.visible) {
28787
+ if (this.transactionLine && this.transactionLine.isArticle && this.transactionLine.supplierDescription === undefined) {
28788
28788
  this._relationService.getRelationById(this.transactionLine.supplierId).then((relations) => {
28789
28789
  const relation = relations && relations.length > 0 ? relations[0] : null;
28790
28790
  this.transactionLine.supplierDescription = relation ? relation.displayName : "";
@@ -36271,16 +36271,21 @@ TransactionHeaderDepositAmountComponent.decorators = [
36271
36271
  { type: Component, args: [{
36272
36272
  selector: "co-transaction-header-deposit-amount",
36273
36273
  template: `
36274
- <span *ngIf="(!editMode || headerReadonly) && !defaultEditMode" [textContent]="(transactionInfo.depositAmount | coCurrency) || '...'" [tooltip]="tooltipMessage"></span>
36275
- <co-input-text #input *ngIf="editMode || defaultEditMode"
36276
- [type]="'number'"
36277
- [placeholder]="showLabel ? ('DOWNPAYMENT' | localize) : ''"
36278
- [showSaveCancel]="!headerReadonly"
36279
- [hidden]="hidden"
36280
- [readonly]="readonly || headerReadonly"
36281
- [model]="transactionInfo.depositAmount"
36282
- (blur)="editMode = false"
36283
- ></co-input-text>
36274
+ <span
36275
+ *ngIf="(!editMode || headerReadonly) && !defaultEditMode"
36276
+ [textContent]="(transactionInfo.depositAmount | coCurrency) || '...'"
36277
+ [tooltip]="tooltipMessage">
36278
+ </span>
36279
+ <co-input-text
36280
+ #input
36281
+ *ngIf="editMode || defaultEditMode"
36282
+ [placeholder]="showLabel ? ('DOWNPAYMENT' | localize) : ''"
36283
+ [showSaveCancel]="!headerReadonly"
36284
+ [hidden]="hidden"
36285
+ [readonly]="readonly || headerReadonly"
36286
+ [model]="transactionInfo.depositAmount | coCurrency"
36287
+ (blur)="editMode = false">
36288
+ </co-input-text>
36284
36289
  `,
36285
36290
  providers: [{
36286
36291
  provide: SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME,
@@ -37451,13 +37456,15 @@ CatalogScreenConfigurationService.ctorParameters = () => [
37451
37456
  ];
37452
37457
 
37453
37458
  class DialogCatalogComponent {
37454
- constructor(_transactionService, _catalogService, _catalogEventService, _articleService, _dialogService, _screenConfigService, iconCacheService) {
37459
+ constructor(_transactionService, _catalogService, _catalogEventService, _articleService, _dialogService, _screenConfigService, _productConnectorAdapterService, _transactionEventService, iconCacheService) {
37455
37460
  this._transactionService = _transactionService;
37456
37461
  this._catalogService = _catalogService;
37457
37462
  this._catalogEventService = _catalogEventService;
37458
37463
  this._articleService = _articleService;
37459
37464
  this._dialogService = _dialogService;
37460
37465
  this._screenConfigService = _screenConfigService;
37466
+ this._productConnectorAdapterService = _productConnectorAdapterService;
37467
+ this._transactionEventService = _transactionEventService;
37461
37468
  this.iconCacheService = iconCacheService;
37462
37469
  this.icons = Icon;
37463
37470
  this.handleAddArticleInternally = true;
@@ -37496,6 +37503,8 @@ class DialogCatalogComponent {
37496
37503
  }
37497
37504
  this._subs.push(this._catalogEventService.stockDetailsClick.subscribe((article) => {
37498
37505
  this.handleStockButtonClick(article);
37506
+ }), this._productConnectorAdapterService.showLoader.subscribe((show) => {
37507
+ this._transactionEventService.showLoader.next(show);
37499
37508
  }));
37500
37509
  });
37501
37510
  }
@@ -37721,6 +37730,8 @@ DialogCatalogComponent.ctorParameters = () => [
37721
37730
  { type: ArticleService },
37722
37731
  { type: DialogService },
37723
37732
  { type: CatalogScreenConfigurationService },
37733
+ { type: ProductConnectorAdapterService },
37734
+ { type: TransactionEventService },
37724
37735
  { type: IconCacheService }
37725
37736
  ];
37726
37737
  DialogCatalogComponent.propDecorators = {
@@ -51599,13 +51610,13 @@ class AddProductComponent {
51599
51610
  if (typeof data.article === 'string') {
51600
51611
  const article = JSON.parse(data.article);
51601
51612
  if (article.selectorData && article.selectorData.compositions) { // configured (frozen) article
51602
- yield this.transactionService.addArticle(article.selectorData.compositions[0].compositionArticleNo, data.quantity, 0, 0 /*, lastArticle*/);
51613
+ yield this.transactionService.addArticle(article.selectorData.compositions[0].compositionArticleNo, data.quantity, 0, 0, true, true);
51603
51614
  }
51604
51615
  }
51605
51616
  else { // flat (simple) article
51606
51617
  const articleNr = data.article['articleNr'] || data.article['articleNumber'] || data.article['articleNo'];
51607
51618
  if (articleNr) {
51608
- yield this.transactionService.addArticle(articleNr, data.quantity, 0, 0 /*, lastArticle*/);
51619
+ yield this.transactionService.addArticle(articleNr, data.quantity, 0, 0, true, true);
51609
51620
  }
51610
51621
  }
51611
51622
  }
@@ -51661,7 +51672,7 @@ class AddProductComponent {
51661
51672
  request.catalogId = iFrameFeedbackObject.catalog;
51662
51673
  request.catalogType = iFrameFeedbackObject.sourceType;
51663
51674
  request.articleJson = iFrameFeedbackObject.jsonString;
51664
- yield this.transactionService.addExternalCatalogArticle(request);
51675
+ yield this.transactionService.addExternalCatalogArticle(request, true);
51665
51676
  });
51666
51677
  }
51667
51678
  handleAddCatFarmArticleClick(data) {
@@ -51671,7 +51682,7 @@ class AddProductComponent {
51671
51682
  request.catalogId = data.catalog;
51672
51683
  request.catalogType = ExternalCatalogTypes.CatalogFarm;
51673
51684
  request.articleJson = data.jsonString;
51674
- yield this.transactionService.addExternalCatalogArticle(request);
51685
+ yield this.transactionService.addExternalCatalogArticle(request, true);
51675
51686
  });
51676
51687
  }
51677
51688
  _prepareCatalogRequest() {
@@ -55604,40 +55615,9 @@ class DialogDirectSellComponent {
55604
55615
  this.showDirectSellModal = new EventEmitter();
55605
55616
  this.icons = Icon;
55606
55617
  this.directSellSuppliers = [];
55607
- this.supplierStockRowSelected = false;
55608
- this.tempObject = {
55609
- articleNumber: 'articleNumber 123',
55610
- availableStock: 10,
55611
- supplierStockForecasts: [
55612
- {
55613
- purchaseOrderNumber: 1,
55614
- amount: 11,
55615
- amountReserved: 7,
55616
- amountAvailable: 4,
55617
- deliveryDate: new Date(),
55618
- confirmedDeliveryDate: new Date(),
55619
- arrivalDate: new Date()
55620
- },
55621
- {
55622
- purchaseOrderNumber: 2,
55623
- amount: 14,
55624
- amountReserved: 7,
55625
- amountAvailable: 7,
55626
- deliveryDate: new Date(),
55627
- confirmedDeliveryDate: new Date(),
55628
- arrivalDate: new Date()
55629
- },
55630
- {
55631
- purchaseOrderNumber: 3,
55632
- amount: 5,
55633
- amountReserved: 1,
55634
- amountAvailable: 4,
55635
- deliveryDate: new Date(),
55636
- confirmedDeliveryDate: new Date(),
55637
- arrivalDate: new Date()
55638
- }
55639
- ]
55640
- };
55618
+ this.availableStockCollection = new SupplierArticleStockForecast();
55619
+ this.formValid = false;
55620
+ this.fromStock = false;
55641
55621
  }
55642
55622
  ngOnInit() {
55643
55623
  this._getDirectSellSuppliers();
@@ -55645,39 +55625,82 @@ class DialogDirectSellComponent {
55645
55625
  hideModal() {
55646
55626
  this.showDirectSellModal.emit(false);
55647
55627
  }
55648
- handleSupplierChanged(supplier) {
55628
+ handleSupplierChanged() {
55649
55629
  this._getAvailableStock();
55650
55630
  }
55651
- handleChecked(event, row, index) {
55631
+ onStockChecked(event) {
55632
+ var _a;
55652
55633
  event.preventDefault();
55653
55634
  event.stopPropagation();
55654
- const checkbox = this.checkboxes.toArray()[index];
55655
- checkbox.model = !checkbox.model;
55635
+ if (this.selectedSupplier && ((_a = this.availableStockCollection.supplierStockForecasts) === null || _a === void 0 ? void 0 : _a.length) > 0) {
55636
+ this.checkboxes.forEach(po => po.model = false);
55637
+ }
55638
+ this.fromStock = !this.fromStock;
55639
+ if (this.fromStock) {
55640
+ this.selectedForecast = null;
55641
+ }
55642
+ this.formValid = this.fromStock;
55643
+ }
55644
+ toggleStockChecked(event) {
55645
+ var _a;
55646
+ if (this.selectedSupplier && ((_a = this.availableStockCollection.supplierStockForecasts) === null || _a === void 0 ? void 0 : _a.length) > 0) {
55647
+ this.checkboxes.forEach(po => po.model = false);
55648
+ }
55649
+ this.formValid = event;
55650
+ }
55651
+ handleChecked(index, selectedForecast, event) {
55652
+ var _a;
55653
+ event.preventDefault();
55654
+ event.stopPropagation();
55655
+ if (this.selectedSupplier && ((_a = this.availableStockCollection.supplierStockForecasts) === null || _a === void 0 ? void 0 : _a.length) > 0) {
55656
+ this.checkboxes.forEach(po => po.model = false);
55657
+ }
55658
+ const selectedCheckbox = this.checkboxes.toArray()[index];
55659
+ selectedCheckbox.model = !selectedCheckbox.model;
55660
+ if (selectedCheckbox.model) {
55661
+ this.selectedForecast = selectedForecast;
55662
+ }
55663
+ this.fromStock = false;
55664
+ this.formValid = selectedCheckbox.model;
55665
+ }
55666
+ toggleForecastChecked(event) {
55667
+ var _a;
55668
+ if (this.selectedSupplier && ((_a = this.availableStockCollection.supplierStockForecasts) === null || _a === void 0 ? void 0 : _a.length) > 0) {
55669
+ this.checkboxes.forEach(po => po.model = false);
55670
+ }
55671
+ this.fromStock = false;
55672
+ this.formValid = event;
55656
55673
  }
55657
55674
  onOkClick() {
55658
55675
  const changeLineDirectSellRequest = {
55659
55676
  transactionUuid: this.transactionUuid,
55660
55677
  lineUuid: this.lineUuid,
55661
- newDirectSell: true
55678
+ newDirectSell: !this.fromStock,
55679
+ newSupplierId: this.selectedSupplier.relationId,
55680
+ newPurchaseOrderNumber: this.fromStock ? null : this.selectedForecast.purchaseOrderNumber.toString(),
55681
+ newStockForecastDeliveryDate: this.fromStock ? null : this.selectedForecast.deliveryDate
55662
55682
  };
55663
- // this.transactionService.changeLineDirectSell(changeLineDirectSellRequest).then((response) => {
55664
- // console.log(response);
55665
- // });
55683
+ this.transactionService.changeLineDirectSell(changeLineDirectSellRequest).then((response) => {
55684
+ console.log(response);
55685
+ });
55666
55686
  this.hideModal();
55667
55687
  }
55668
55688
  _getAvailableStock() {
55669
55689
  return __awaiter(this, void 0, void 0, function* () {
55670
55690
  // TODO this method doesn't retrieve any data for now, until we fix ESB instance as this is a call to a third party
55671
- // await this.transactionService.getAvailableStockForSupplier(this.goodId, this.selectedSupplier.relationId).then((availableStock) => {
55672
- // this.availableStockCollection = availableStock;
55673
- // });
55674
- // For now, we will use dummy data
55675
- this.availableStockCollection = this.tempObject;
55691
+ yield this.transactionService.getAvailableStockForSupplier(this.goodId, this.selectedSupplier.relationId).then((availableStock) => {
55692
+ if (availableStock) {
55693
+ this.availableStockCollection = availableStock;
55694
+ }
55695
+ });
55676
55696
  });
55677
55697
  }
55678
55698
  _getDirectSellSuppliers() {
55679
55699
  this._relationService.getDirectSellSuppliers().then((suppliers) => {
55680
55700
  this.directSellSuppliers = suppliers;
55701
+ if (this.directSellSuppliers.length === 1) {
55702
+ this.selectedSupplier = this.directSellSuppliers[0];
55703
+ }
55681
55704
  });
55682
55705
  }
55683
55706
  }
@@ -55695,30 +55718,37 @@ DialogDirectSellComponent.decorators = [
55695
55718
  <div class="supplier-list-wrapper flex">
55696
55719
  <co-list-of-values
55697
55720
  class="supplier-list"
55698
- label="Direct Sell Supplier"
55721
+ [label]="'FROM_SUPPLIER' | localize"
55699
55722
  [required]="true"
55700
55723
  [noClickFocus]="true"
55701
55724
  [searchPlaceholder]="'SEARCH' | localize"
55702
55725
  [collection]="directSellSuppliers"
55703
55726
  [displayField]="'supplierName'"
55704
55727
  [(model)]="selectedSupplier"
55705
- (modelChange)="handleSupplierChanged($event)">
55728
+ (modelChange)="handleSupplierChanged()">
55706
55729
  </co-list-of-values>
55707
55730
  </div>
55708
55731
 
55709
55732
  <div class="available-stock checkbox-list-wrapper" *ngIf="selectedSupplier">
55710
- <div class="checkbox-list-item">
55733
+ <div
55734
+ class="checkbox-list-item"
55735
+ [class.checked]="fromStock"
55736
+ (click)="onStockChecked($event)">
55711
55737
  <div class="cell">
55712
55738
  <div class="checkbox-wrapper">
55713
- <co-input-checkbox [model]="false"></co-input-checkbox>
55739
+ <co-input-checkbox
55740
+ [(model)]="fromStock"
55741
+ (modelChange)="toggleStockChecked($event)">
55742
+ </co-input-checkbox>
55714
55743
  </div>
55715
55744
  </div>
55716
55745
  <div class="cell">Uit vooraad</div>
55717
- <div class="cell"><strong>{{availableStockCollection.availableStock}}</strong></div>
55746
+ <div class="cell"><strong>{{ availableStockCollection.availableStock }}</strong></div>
55718
55747
  </div>
55719
55748
  </div>
55720
55749
 
55721
- <div class="forecast-table" *ngIf="selectedSupplier">
55750
+ <div class="forecast-table"
55751
+ *ngIf="selectedSupplier && availableStockCollection.supplierStockForecasts?.length > 0">
55722
55752
  <div class="forecast-table-header">
55723
55753
  <div class="cell"></div>
55724
55754
  <div class="cell">Order</div>
@@ -55734,30 +55764,34 @@ DialogDirectSellComponent.decorators = [
55734
55764
  #scrollingItem
55735
55765
  class="checkbox-list-item"
55736
55766
  [class.checked]="checkbox.model"
55737
- (click)="handleChecked($event, row, i)">
55767
+ (click)="handleChecked(i, row, $event)">
55738
55768
  <div class="cell">
55739
55769
  <div class="checkbox-wrapper">
55740
- <co-input-checkbox #checkbox [model]="false"></co-input-checkbox>
55770
+ <co-input-checkbox
55771
+ #checkbox
55772
+ [(model)]="checkbox.model"
55773
+ (modelChange)="toggleForecastChecked($event)">
55774
+ </co-input-checkbox>
55741
55775
  </div>
55742
55776
  </div>
55743
- <div class="cell">{{row.purchaseOrderNumber}}</div>
55744
- <div class="cell">{{row.amount}}</div>
55745
- <div class="cell">{{row.deliveryDate | date}}</div>
55746
- <div class="cell">{{row.confirmedDeliveryDate | date}}</div>
55747
- <div class="cell">{{row.arrivalDate | date}}</div>
55777
+ <div class="cell">{{ row.purchaseOrderNumber }}</div>
55778
+ <div class="cell">{{ row.amount }}</div>
55779
+ <div class="cell">{{ row.deliveryDate | date }}</div>
55780
+ <div class="cell">{{ row.confirmedDeliveryDate | date }}</div>
55781
+ <div class="cell">{{ row.arrivalDate | date }}</div>
55748
55782
  </div>
55749
55783
  </div>
55750
55784
  </div>
55751
55785
  </co-dialog>
55752
55786
  <ng-template #headerTemplate>
55753
55787
  <co-icon [iconData]="iconCacheService.getIcon(icons.IndustryRegular)"></co-icon>
55754
- <div class="co-dialog-header-title" [textContent]="'CASH_ON_DELIVERY' | localize"></div>
55788
+ <div class="co-dialog-header-title" [textContent]="'DIRECT_SELL' | localize"></div>
55755
55789
  </ng-template>
55756
55790
  <ng-template #footerTemplate>
55757
55791
  <div class="co-dialog-footer-button-wrapper">
55758
55792
  <co-button
55759
55793
  class="save-button"
55760
- [disabled]="true"
55794
+ [disabled]="!formValid"
55761
55795
  [iconData]="iconCacheService.getIcon(icons.CheckDuotone)"
55762
55796
  (click)="onOkClick()">
55763
55797
  </co-button>
@@ -55766,11 +55800,6 @@ DialogDirectSellComponent.decorators = [
55766
55800
  [iconData]="iconCacheService.getIcon(icons.Crossskinny)"
55767
55801
  (click)="hideModal()">
55768
55802
  </co-button>
55769
- <co-button
55770
- class="close-button"
55771
- [iconData]="iconCacheService.getIcon(icons.TrashCanLight)"
55772
- (click)="hideModal()">
55773
- </co-button>
55774
55803
  </div>
55775
55804
  </ng-template>
55776
55805
  `,