diff --git a/src/app/invoice/invoice.component.html b/src/app/invoice/invoice.component.html
index 91ac922..2a6baaf 100644
--- a/src/app/invoice/invoice.component.html
+++ b/src/app/invoice/invoice.component.html
@@ -51,6 +51,24 @@
{{( item.qty * item.cost ) | number : '1.02' | currency: order.currency.toUpperCase()}}
+
0">
+ Sales Tax |
+ |
+ {{ order.taxAmount | currency: order.currency.toUpperCase() }} |
+ |
+
+ 0">
+ Value-Added Tax |
+ |
+ {{ order.vatAmount | currency: order.currency.toUpperCase() }} |
+ |
+
+ 0">
+ Tip |
+ |
+ {{ order.tipAmount | currency: order.currency.toUpperCase() }} |
+ |
+
diff --git a/src/app/invoice/invoice.component.ts b/src/app/invoice/invoice.component.ts
index 5c6bda0..ff53c93 100644
--- a/src/app/invoice/invoice.component.ts
+++ b/src/app/invoice/invoice.component.ts
@@ -49,6 +49,9 @@ export class InvoiceComponent implements OnInit {
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: 0,
+ vatAmount: 0,
+ tipAmount: 0,
lines: [
{
qty: 1,
diff --git a/src/app/listorders/listorders.component.html b/src/app/listorders/listorders.component.html
index a02ea90..cfa2040 100644
--- a/src/app/listorders/listorders.component.html
+++ b/src/app/listorders/listorders.component.html
@@ -154,6 +154,24 @@
width="30%">{{item.qty * item.cost | number:'1.02' | currency: order.currency.toUpperCase() }}
|
+ 0">
+ Sales Tax |
+ |
+ {{ order.taxAmount | currency: order.currency.toUpperCase() }} |
+ |
+
+ 0">
+ Value-Added Tax |
+ |
+ {{ order.vatAmount | currency: order.currency.toUpperCase() }} |
+ |
+
+ 0">
+ Tip |
+ |
+ {{ order.tipAmount | currency: order.currency.toUpperCase() }} |
+ |
+
0">
+
Sales Tax |
+ {{ tax / 100 | percent:'1.2-4'}} |
+ {{ total * tax / 100 | currency: getCurrency() }} |
+ |
+
+ 0">
+ Value-Added Tax |
+ {{ vat / 100 | percent:'1.2-4' }} |
+ {{ total * vat / 100 | currency: getCurrency() }} |
+ |
+
diff --git a/src/app/order/order.component.ts b/src/app/order/order.component.ts
index ecddf32..51a7051 100644
--- a/src/app/order/order.component.ts
+++ b/src/app/order/order.component.ts
@@ -48,6 +48,9 @@ export class OrderComponent implements OnInit{
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: 0,
+ vatAmount: 0,
+ tipAmount: 0,
lines: [
{
qty: 1,
@@ -58,9 +61,13 @@ export class OrderComponent implements OnInit{
};
public price: number = 1;
public total: number = 0;
+ public tax: number = 0;
+ public vat: number = 0;
public orderUpdate: Observable;
public priceUpdate: Observable;
public totalUpdate: Observable;
+ public taxUpdate: Observable;
+ public vatUpdate: Observable;
// ------------------------------------
//
@@ -106,9 +113,6 @@ export class OrderComponent implements OnInit{
this.orderUpdate = orderService.orderUpdate;
this.orderUpdate.subscribe((order) => {
this.order = order;
-
- //console.log('this.order > ' + JSON.stringify(this.order));
-// ------------------------------------------------
this.oLines = [];
this.myLines = this.order.lines;
var nl = {} as newLineItem;
@@ -134,6 +138,14 @@ export class OrderComponent implements OnInit{
this.total = total;
});
+ this.taxUpdate = orderService.taxUpdate;
+ this.taxUpdate.subscribe((tax) => {
+ this.tax = tax;
+ });
+ this.vatUpdate = orderService.vatUpdate;
+ this.vatUpdate.subscribe((vat) => {
+ this.vat = vat;
+ });
}
ngOnInit() {
diff --git a/src/app/order/order.model.ts b/src/app/order/order.model.ts
index 081e67c..05c59cd 100644
--- a/src/app/order/order.model.ts
+++ b/src/app/order/order.model.ts
@@ -1,7 +1,7 @@
import { LineItem } from '../items/lineitem.model';
export interface Order {
- _id?: string,
+ _id?: string|null,
address: string,
session: string,
timestamp?: string,
@@ -14,5 +14,8 @@ export interface Order {
paid: boolean,
externalInvoice: string,
shortCode: string,
- token: string
+ token: string,
+ taxAmount: number,
+ vatAmount: number,
+ tipAmount: number
}
diff --git a/src/app/order/order.service.ts b/src/app/order/order.service.ts
index 0f247c5..6c7fa01 100644
--- a/src/app/order/order.service.ts
+++ b/src/app/order/order.service.ts
@@ -57,6 +57,9 @@ export class OrderService {
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: 0,
+ vatAmount: 0,
+ tipAmount: 0,
lines: [
{
qty: 1,
@@ -72,6 +75,10 @@ export class OrderService {
public readonly totalUpdate: Observable = this._totalUpdated.asObservable();
private _allOrdersUpdated: BehaviorSubject = new BehaviorSubject(this.dataStore.allOrders);
public readonly allOrdersUpdate: Observable = this._allOrdersUpdated.asObservable();
+ private _taxUpdated: BehaviorSubject = new BehaviorSubject(this.dataStore.owner.taxValue);
+ public readonly taxUpdate: Observable = this._taxUpdated.asObservable();
+ private _vatUpdated: BehaviorSubject = new BehaviorSubject(this.dataStore.owner.vatValue);
+ public readonly vatUpdate: Observable = this._vatUpdated.asObservable();
public userUpdate: Observable;
public ownerUpdate: Observable;
private reqHeaders: HttpHeaders;
@@ -95,6 +102,16 @@ export class OrderService {
});
this.ownerUpdate.subscribe((owner) => {
this.dataStore.owner = owner;
+ if (this.dataStore.owner.tax) {
+ this._taxUpdated.next(Object.assign({}, this.dataStore).owner.taxValue);
+ } else {
+ this._taxUpdated.next(0);
+ }
+ if (this.dataStore.owner.vat) {
+ this._vatUpdated.next(Object.assign({}, this.dataStore).owner.vatValue);
+ } else {
+ this._vatUpdated.next(0);
+ }
});
}
@@ -105,10 +122,10 @@ export class OrderService {
if (OrderDataResponse.status == 200) {
this.dataStore.order = OrderDataResponse.body!.order;
this._orderUpdated.next(Object.assign({}, this.dataStore).order);
- this.dataStore.order.total = 0;
- for(var line of this.dataStore.order.lines) {
- this.dataStore.order.total += line.qty * line.cost;
- }
+ //this.dataStore.order.total = 0;
+ //for(var line of this.dataStore.order.lines) {
+ //this.dataStore.order.total += line.qty * line.cost;
+ //}
this._totalUpdated.next(Object.assign({}, this.dataStore).order.total);
} else {
console.log('No order found');
@@ -148,6 +165,14 @@ export class OrderService {
}
createOrder(lineItem: LineItem) {
+ let localTax = 0;
+ let localVat = 0;
+ if (this.dataStore.owner.tax) {
+ localTax = lineItem.cost * lineItem.qty * this.dataStore.owner.taxValue / 100;
+ }
+ if (this.dataStore.owner.vat) {
+ localVat = lineItem.cost * lineItem.qty * this.dataStore.owner.vatValue / 100;
+ }
var order:Order = {
_id: '',
address: this.dataStore.user.address,
@@ -162,11 +187,13 @@ export class OrderService {
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: localTax,
+ vatAmount: localVat,
+ tipAmount: 0,
lines: [lineItem]
};
let obs = this.http.post<{message: string, order: Order}>(this.beUrl+'api/order', {payload: order}, { headers: this.reqHeaders, params: this.reqParams });
obs.subscribe((orderData) => {
- console.log('Created order');
this.getOrder()
});
@@ -192,6 +219,9 @@ export class OrderService {
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: 0,
+ vatAmount: 0,
+ tipAmount: 0,
lines: [
{
qty: 1,
@@ -214,7 +244,7 @@ export class OrderService {
this.dataStore.order.paid = paid;
let obs = this.http.post(this.beUrl+'api/order', {payload: this.dataStore.order}, { headers: this.reqHeaders, params: this.reqParams });
obs.subscribe((orderData) => {
- console.log('Closed order', orderData);
+ //console.log('Closed order', orderData);
this.dataStore.order = {
address: '',
session: '',
@@ -228,6 +258,9 @@ export class OrderService {
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: 0,
+ vatAmount: 0,
+ tipAmount: 0,
lines: [
{
qty: 1,
diff --git a/src/app/pmtservice/pmtservice.component.ts b/src/app/pmtservice/pmtservice.component.ts
index b324e65..f290a4a 100644
--- a/src/app/pmtservice/pmtservice.component.ts
+++ b/src/app/pmtservice/pmtservice.component.ts
@@ -68,6 +68,9 @@ export class PmtserviceComponent implements OnInit {
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: 0,
+ vatAmount: 0,
+ tipAmount: 0,
lines: [
{
qty: 1,
diff --git a/src/app/receipt.service.ts b/src/app/receipt.service.ts
index 99be879..177fcde 100644
--- a/src/app/receipt.service.ts
+++ b/src/app/receipt.service.ts
@@ -47,6 +47,9 @@ export class ReceiptService {
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: 0,
+ vatAmount: 0,
+ tipAmount: 0,
lines: [
{
qty: 1,
diff --git a/src/app/receipt/receipt.component.html b/src/app/receipt/receipt.component.html
index b948cf0..342b9bf 100644
--- a/src/app/receipt/receipt.component.html
+++ b/src/app/receipt/receipt.component.html
@@ -51,6 +51,24 @@
{{( item.qty * item.cost ) | number : '1.02' | currency: order.currency.toUpperCase()}}
+ 0">
+ Sales Tax |
+ |
+ {{ order.taxAmount | currency: order.currency.toUpperCase() }} |
+ |
+
+ 0">
+ Value-Added Tax |
+ |
+ {{ order.vatAmount | currency: order.currency.toUpperCase() }} |
+ |
+
+ 0">
+ Tip |
+ |
+ {{ order.tipAmount | currency: order.currency.toUpperCase() }} |
+ |
+
@@ -92,4 +110,4 @@
-
\ No newline at end of file
+
diff --git a/src/app/receipt/receipt.component.ts b/src/app/receipt/receipt.component.ts
index 2b95dda..5146817 100644
--- a/src/app/receipt/receipt.component.ts
+++ b/src/app/receipt/receipt.component.ts
@@ -32,6 +32,9 @@ export class ReceiptComponent implements OnInit {
externalInvoice: '',
shortCode: '',
token: '',
+ taxAmount: 0,
+ vatAmount: 0,
+ tipAmount: 0,
lines: [
{
qty: 1,
|