From e9682c18715997d02e929a72fc16d28dd91707c7 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Tue, 24 May 2022 13:18:46 -0500 Subject: [PATCH] Implement the paid field in Order --- CHANGELOG.md | 24 ++++++++++++++++++++++++ src/app/invoice/invoice.component.html | 6 +++--- src/app/invoice/invoice.component.ts | 1 + src/app/order/order.component.ts | 5 +++-- src/app/order/order.model.ts | 3 ++- src/app/order/order.service.ts | 7 ++++++- src/app/receipt.service.ts | 1 + src/app/receipt/receipt.component.ts | 1 + 8 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d0b34b1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Invoice display via URL +- Invoice button for closing order +- Field `paid` for Order type + +## [1.1.0] - 2022-05-20 + +### Changed + +- Services interacting with backend API were modified to support the new [ZGo Backend](https://gitlabl.com/pitmutt/zgo-backend). + +### Removed + +- NodeJS back-end + + diff --git a/src/app/invoice/invoice.component.html b/src/app/invoice/invoice.component.html index 8cb432d..d371270 100644 --- a/src/app/invoice/invoice.component.html +++ b/src/app/invoice/invoice.component.html @@ -18,8 +18,6 @@

Order ID: {{orderId}}

Zcash Price: {{order.price | currency: order.currency.toUpperCase()}}

- Payment confirmed - Payment pending
@@ -39,7 +37,9 @@
{{(item.qty * item.cost) | currency: order.currency.toUpperCase()}}
-
+
+ Payment confirmed + Payment pending
diff --git a/src/app/invoice/invoice.component.ts b/src/app/invoice/invoice.component.ts index b9f6c36..407a220 100644 --- a/src/app/invoice/invoice.component.ts +++ b/src/app/invoice/invoice.component.ts @@ -33,6 +33,7 @@ export class InvoiceComponent implements OnInit { price: 0, total: 0, totalZec: 0, + paid: false, lines: [ { qty: 1, diff --git a/src/app/order/order.component.ts b/src/app/order/order.component.ts index 25b0c42..93e99b9 100644 --- a/src/app/order/order.component.ts +++ b/src/app/order/order.component.ts @@ -27,6 +27,7 @@ export class OrderComponent implements OnInit{ price:0, total:0, totalZec: 0, + paid: false, lines: [ { qty: 1, @@ -107,7 +108,7 @@ export class OrderComponent implements OnInit{ order: this.order._id }; console.log('Payment confirmed!'); - this.orderService.closeOrder(); + this.orderService.closeOrder(true); const dialogRef2 = this.dialog.open(ReceiptQRComponent, dialogConfig2); dialogRef2.afterClosed().subscribe( val => { if (val) { @@ -134,7 +135,7 @@ export class OrderComponent implements OnInit{ const dialogRef = this.dialog.open(PromptInvoiceComponent, dialogConfig); dialogRef.afterClosed().subscribe((val) => { if (val) { - this.orderService.closeOrder(); + this.orderService.closeOrder(false); } else { console.log('Returning to order'); } diff --git a/src/app/order/order.model.ts b/src/app/order/order.model.ts index 435f480..3b7e66f 100644 --- a/src/app/order/order.model.ts +++ b/src/app/order/order.model.ts @@ -10,5 +10,6 @@ export interface Order { price?: number, total: number, totalZec: number, - lines: LineItem[] + lines: LineItem[], + paid: boolean } diff --git a/src/app/order/order.service.ts b/src/app/order/order.service.ts index a9b2817..63fe706 100644 --- a/src/app/order/order.service.ts +++ b/src/app/order/order.service.ts @@ -56,6 +56,7 @@ export class OrderService { price: 0, total: 0, totalZec: 0, + paid: false, lines: [ { qty: 1, @@ -157,6 +158,7 @@ export class OrderService { totalZec: 0, price: 0, total: 0, + paid: false, lines: [lineItem] }; let obs = this.http.post<{message: string, order: Order}>(this.beUrl+'api/order', {payload: order}, { headers: this.reqHeaders }); @@ -183,6 +185,7 @@ export class OrderService { total: 0, totalZec: 0, price: 0, + paid: false, lines: [ { qty: 1, @@ -197,11 +200,12 @@ export class OrderService { return obs; } - closeOrder(){ + closeOrder(paid: boolean){ this.fullnodeService.priceUpdate.subscribe((price) => { this.dataStore.order.price = price; }); this.dataStore.order.closed = true; + this.dataStore.order.paid = paid; let obs = this.http.post(this.beUrl+'api/order', {payload: this.dataStore.order}, { headers: this.reqHeaders }); obs.subscribe((orderData) => { console.log('Closed order', orderData); @@ -214,6 +218,7 @@ export class OrderService { price: 0, total: 0, totalZec: 0, + paid: false, lines: [ { qty: 1, diff --git a/src/app/receipt.service.ts b/src/app/receipt.service.ts index daed6a7..55dfa81 100644 --- a/src/app/receipt.service.ts +++ b/src/app/receipt.service.ts @@ -46,6 +46,7 @@ export class ReceiptService { price: 0, total: 0, totalZec: 0, + paid: false, lines: [ { qty: 1, diff --git a/src/app/receipt/receipt.component.ts b/src/app/receipt/receipt.component.ts index 67e9038..756a914 100644 --- a/src/app/receipt/receipt.component.ts +++ b/src/app/receipt/receipt.component.ts @@ -23,6 +23,7 @@ export class ReceiptComponent implements OnInit { price: 0, total: 0, totalZec: 0, + paid: false, lines: [ { qty: 1,