Implement the paid field in Order

This commit is contained in:
Rene Vergara 2022-05-24 13:18:46 -05:00
parent 796c39bec2
commit e9682c1871
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
8 changed files with 41 additions and 7 deletions

24
CHANGELOG.md Normal file
View File

@ -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

View File

@ -18,8 +18,6 @@
<mat-card-content> <mat-card-content>
<p class="small">Order ID: {{orderId}}</p> <p class="small">Order ID: {{orderId}}</p>
<p class="small">Zcash Price: {{order.price | currency: order.currency.toUpperCase()}}</p> <p class="small">Zcash Price: {{order.price | currency: order.currency.toUpperCase()}}</p>
<span *ngIf="order.closed"><fa-icon [icon]="faCheck"></fa-icon>Payment confirmed</span>
<span *ngIf="!order.closed"><fa-icon [icon]="faHourglass"></fa-icon>Payment pending</span>
<div align="center"> <div align="center">
<table> <table>
<tr> <tr>
@ -39,7 +37,9 @@
<td align="right">{{(item.qty * item.cost) | currency: order.currency.toUpperCase()}} </td> <td align="right">{{(item.qty * item.cost) | currency: order.currency.toUpperCase()}} </td>
<tr> <tr>
</table> </table>
<div class="qrcode" id="payment-qr"></div> <div class="qrcode" id="payment-qr" *ngIf="!order.paid"></div>
<span *ngIf="order.paid"><fa-icon [icon]="faCheck" color="primary"></fa-icon>Payment confirmed</span>
<span *ngIf="!order.paid"><fa-icon [icon]="faHourglass" color="primary"></fa-icon>Payment pending</span>
</div> </div>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>

View File

@ -33,6 +33,7 @@ export class InvoiceComponent implements OnInit {
price: 0, price: 0,
total: 0, total: 0,
totalZec: 0, totalZec: 0,
paid: false,
lines: [ lines: [
{ {
qty: 1, qty: 1,

View File

@ -27,6 +27,7 @@ export class OrderComponent implements OnInit{
price:0, price:0,
total:0, total:0,
totalZec: 0, totalZec: 0,
paid: false,
lines: [ lines: [
{ {
qty: 1, qty: 1,
@ -107,7 +108,7 @@ export class OrderComponent implements OnInit{
order: this.order._id order: this.order._id
}; };
console.log('Payment confirmed!'); console.log('Payment confirmed!');
this.orderService.closeOrder(); this.orderService.closeOrder(true);
const dialogRef2 = this.dialog.open(ReceiptQRComponent, dialogConfig2); const dialogRef2 = this.dialog.open(ReceiptQRComponent, dialogConfig2);
dialogRef2.afterClosed().subscribe( val => { dialogRef2.afterClosed().subscribe( val => {
if (val) { if (val) {
@ -134,7 +135,7 @@ export class OrderComponent implements OnInit{
const dialogRef = this.dialog.open(PromptInvoiceComponent, dialogConfig); const dialogRef = this.dialog.open(PromptInvoiceComponent, dialogConfig);
dialogRef.afterClosed().subscribe((val) => { dialogRef.afterClosed().subscribe((val) => {
if (val) { if (val) {
this.orderService.closeOrder(); this.orderService.closeOrder(false);
} else { } else {
console.log('Returning to order'); console.log('Returning to order');
} }

View File

@ -10,5 +10,6 @@ export interface Order {
price?: number, price?: number,
total: number, total: number,
totalZec: number, totalZec: number,
lines: LineItem[] lines: LineItem[],
paid: boolean
} }

View File

@ -56,6 +56,7 @@ export class OrderService {
price: 0, price: 0,
total: 0, total: 0,
totalZec: 0, totalZec: 0,
paid: false,
lines: [ lines: [
{ {
qty: 1, qty: 1,
@ -157,6 +158,7 @@ export class OrderService {
totalZec: 0, totalZec: 0,
price: 0, price: 0,
total: 0, total: 0,
paid: false,
lines: [lineItem] lines: [lineItem]
}; };
let obs = this.http.post<{message: string, order: Order}>(this.beUrl+'api/order', {payload: order}, { headers: this.reqHeaders }); 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, total: 0,
totalZec: 0, totalZec: 0,
price: 0, price: 0,
paid: false,
lines: [ lines: [
{ {
qty: 1, qty: 1,
@ -197,11 +200,12 @@ export class OrderService {
return obs; return obs;
} }
closeOrder(){ closeOrder(paid: boolean){
this.fullnodeService.priceUpdate.subscribe((price) => { this.fullnodeService.priceUpdate.subscribe((price) => {
this.dataStore.order.price = price; this.dataStore.order.price = price;
}); });
this.dataStore.order.closed = true; 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 }); let obs = this.http.post(this.beUrl+'api/order', {payload: this.dataStore.order}, { headers: this.reqHeaders });
obs.subscribe((orderData) => { obs.subscribe((orderData) => {
console.log('Closed order', orderData); console.log('Closed order', orderData);
@ -214,6 +218,7 @@ export class OrderService {
price: 0, price: 0,
total: 0, total: 0,
totalZec: 0, totalZec: 0,
paid: false,
lines: [ lines: [
{ {
qty: 1, qty: 1,

View File

@ -46,6 +46,7 @@ export class ReceiptService {
price: 0, price: 0,
total: 0, total: 0,
totalZec: 0, totalZec: 0,
paid: false,
lines: [ lines: [
{ {
qty: 1, qty: 1,

View File

@ -23,6 +23,7 @@ export class ReceiptComponent implements OnInit {
price: 0, price: 0,
total: 0, total: 0,
totalZec: 0, totalZec: 0,
paid: false,
lines: [ lines: [
{ {
qty: 1, qty: 1,