Skip to content
Code-Schnipsel Gruppen Projekte
Commit a3951088 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: feat: price factors are deletable now

Übergeordneter 86200b0d
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -8,6 +8,8 @@
* @event onArticleSelect [self, {Object} Article]
* @event onArticleUnSelect [self, {Object} Article]
* @event onArticleReplaceClick [self, {Object} Article]
*
* @todo move to erp package
*/
define('package/quiqqer/invoice/bin/backend/controls/InvoiceArticleList', [
......@@ -67,8 +69,9 @@ define('package/quiqqer/invoice/bin/backend/controls/InvoiceArticleList', [
vatText : []
};
this.$Container = null;
this.$Sortables = null;
this.$Container = null;
this.$Sortables = null;
this.$priceFactors = [];
this.addEvents({
onInject: this.$onInject
......@@ -132,7 +135,8 @@ define('package/quiqqer/invoice/bin/backend/controls/InvoiceArticleList', [
});
return {
articles: articles
articles : articles,
priceFactors: this.$priceFactors
};
},
......@@ -158,6 +162,10 @@ define('package/quiqqer/invoice/bin/backend/controls/InvoiceArticleList', [
data = list;
}
if ("priceFactors" in data) {
this.$priceFactors = data.priceFactors;
}
if (!("articles" in data)) {
return Promise.resolve();
}
......@@ -362,6 +370,32 @@ define('package/quiqqer/invoice/bin/backend/controls/InvoiceArticleList', [
return this.$calculations;
},
/**
* Return price factors
*
* @return {[]}
*/
getPriceFactors: function () {
return this.$priceFactors;
},
/**
* Remove a price factor
*
* @param no
*/
removePriceFactor: function (no) {
var newList = [];
for (var i = 0, len = this.$priceFactors.length; i < len; i++) {
if (i !== parseInt(no)) {
newList.push(this.$priceFactors[i]);
}
}
this.$priceFactors = newList;
},
/**
* Sorting
*/
......@@ -607,4 +641,4 @@ define('package/quiqqer/invoice/bin/backend/controls/InvoiceArticleList', [
return this.$selectedArticle;
}
});
});
\ No newline at end of file
});
<table class="data-table data-table-flexbox quiqqer-invoice-backend-temporaryInvoice-summaryWin-priceFactors">
<tbody>
{{#priceFactors}}
<tr data-index="{{index}}">
<td>
<label class="field-container">
<span class="field-container-item">{{title}}</span>
<span class="field-container-field">{{valueText}}</span>
<button style="width: 50px; cursor: pointer;">
<span class="fa fa-close"></span>
</button>
</label>
</td>
</tr>
{{/priceFactors}}
{{^priceFactors}}
<tr>
<td>Keine Preisfaktoren vorhanden</td>
</tr>
{{/priceFactors}}
</tbody>
</table>
<table class="data-table data-table-flexbox quiqqer-invoice-backend-temporaryInvoice-summaryWin-total">
<tbody>
{{#vatArray}}
<tr>
<td>
<label class="field-container">
<span class="field-container-item vat-title">{{text}}</span>
<span class="field-container-field vat-value">{{sum}}</span>
</label>
</td>
</tr>
{{/vatArray}}
<tr>
<td>
<label class="field-container">
<span class="field-container-item netto-title">Netto</span>
<span class="field-container-field netto-value"></span>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item brutto-title">Brutto</span>
<span class="field-container-field brutto-value"></span>
</label>
</td>
</tr>
</tbody>
</table>
......@@ -2,10 +2,15 @@
.quiqqer-invoice-backend-temporaryInvoice-summary {
background: #FFFFFF;
border-top: 2px solid #DEDEDE;
cursor: pointer;
float: left;
width: 100%;
}
.quiqqer-invoice-backend-temporaryInvoice-summary:hover {
background: rgba(0, 0, 0, 0.1);
}
.quiqqer-invoice-backend-temporaryInvoice-summary-pos,
.quiqqer-invoice-backend-temporaryInvoice-summary-total {
border-top: 1px solid #DEDEDE;
......@@ -36,4 +41,4 @@
.quiqqer-invoice-backend-temporaryInvoice-summary-total-title {
width: calc(100% - 800px);
}
\ No newline at end of file
}
......@@ -3,6 +3,8 @@
* @author www.pcsg.de (Henning Leutz)
*
* Displays a posted Invoice
*
* @todo move to erp package
*/
define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Summary', [
......@@ -31,7 +33,8 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Sum
Binds: [
'$onInject',
'$refreshArticleSelect'
'$refreshArticleSelect',
'openSummary'
],
initialize: function (options) {
......@@ -62,6 +65,8 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Sum
html : Mustache.render(template)
});
this.$Elm.addEvent('click', this.openSummary);
this.$NettoSum = this.$Elm.getElement(
'.quiqqer-invoice-backend-temporaryInvoice-summary-total .netto-value'
);
......@@ -145,6 +150,77 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Sum
List.addEvent('onArticleSelect', this.$refreshArticleSelect);
},
/**
* Open the summary with price factors
*/
openSummary: function () {
if (!this.getAttribute('List')) {
return;
}
var self = this;
require(['qui/controls/windows/Popup'], function (Popup) {
new Popup({
title : QUILocale.get('quiqqer/erp', 'article.summary.window.title'),
buttons : false,
maxHeight: 600,
maxWidth : 600,
events : {
onCreate: function (Win) {
Win.Loader.show();
self.$refreshSummaryContent(Win).then(function () {
Win.Loader.hide();
});
}
}
}).open();
});
},
$refreshSummaryContent: function (Win) {
var self = this;
return new Promise(function (resolve) {
var Content = Win.getContent();
var List = self.getAttribute('List');
var priceFactors = List.getPriceFactors();
var calculations = List.getCalculation();
for (var i = 0, len = priceFactors.length; i < len; i++) {
priceFactors[i].index = i;
}
Content.set('html', '');
require([
'text!package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Summary.Window.html'
], function (template) {
Content.set('html', Mustache.render(template, {
priceFactors: priceFactors,
vatArray : Object.values(calculations.vatArray)
}));
var Total = Content.getElement('.quiqqer-invoice-backend-temporaryInvoice-summaryWin-total');
Total.getElement('.netto-value').set('html', calculations.nettoSum);
Total.getElement('.brutto-value').set('html', calculations.sum);
Content.getElements(
'.quiqqer-invoice-backend-temporaryInvoice-summaryWin-priceFactors'
).addEvent('click', function (event) {
var index = event.target.getParent('tr').get('data-index');
List.removePriceFactor(index);
self.$refreshSummaryContent(Win);
});
resolve();
});
});
},
/**
* event: onArticleSelect
*
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren