Skip to content

Commit

Permalink
not yet done still working on so entry part for demo purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl M. Mobe committed Dec 7, 2017
1 parent 72c5aba commit 882d1ab
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 101 deletions.
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';

import { AppComponent } from './app.component';

Expand Down Expand Up @@ -73,6 +74,7 @@ import { ChartsModule } from 'ng2-charts/ng2-charts';
AppRoutingModule,
BsDropdownModule.forRoot(),
TabsModule.forRoot(),
HttpClientModule,
ChartsModule
],
declarations: [
Expand Down
134 changes: 76 additions & 58 deletions src/app/services/testdata.service.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,53 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class TestDataService {
BaseUrl:string = "http://localhost:9008/api";

getCustomers(): Customer[] {
let list = new Array<Customer>();
constructor(private http: HttpClient) {

list.push({ CustomerNo: 'CUST0001', Name: 'EC Calderon Construction Development, Inc.', Address: 'B. Suico, Pagsabungan Road,, Mandaue City, Cebu', IsActive: true });
list.push({ CustomerNo: 'CUST0002', Name: 'Hi-Speed Construction Corporation', Address: '800 A. S. Fortuna St, Mandaue City, 6014 Cebu', IsActive: true });
list.push({ CustomerNo: 'CUST0003', Name: 'Dakay Construction ', Address: 'Doña Modesta Gaisano St, Cebu City, Cebu', IsActive: true });

return list;
}

getCustomerByCustomerNo(customerNo: string): Customer {
return this.getCustomers().filter(x => x.CustomerNo == customerNo)[0];
}
async getCustomers(): Promise<Customer[]> {
const res = await this.http.get(this.BaseUrl + '/customers/get-all').toPromise();
return res as Customer[];

getItems(): Item[] {
let list = new Array<Item>();
// let list = new Array<Customer>();

list.push({ ItemNo: 'ITM0001', Name: 'CEMEX', Description: 'CEMEX APO Masonry Cement', UnitPrice: 150, IsActive: true });
list.push({ ItemNo: 'ITM0002', Name: 'Valspar 82020', Description: 'Valspar 82020 Gray Solid Color Concrete Sealer 1 Gallon', UnitPrice: 450, IsActive: true });
list.push({ ItemNo: 'ITM0003', Name: 'Rizal Cement', Description: 'Rizal Portland Super Type 1P cement', UnitPrice: 145, IsActive: true });
list.push({ ItemNo: 'ITM0004', Name: 'Island Cement', Description: 'Island Portland Type 1 Cement', UnitPrice: 140, IsActive: true });
list.push({ ItemNo: 'ITM0005', Name: 'Palitada King', Description: 'Palitada King Masonry Cement', UnitPrice: 130, IsActive: true });
// list.push({ CustomerNo: 'CUST0001', Name: 'EC Calderon Construction Development, Inc.', Address: 'B. Suico, Pagsabungan Road,, Mandaue City, Cebu', IsActive: true });
// list.push({ CustomerNo: 'CUST0002', Name: 'Hi-Speed Construction Corporation', Address: '800 A. S. Fortuna St, Mandaue City, 6014 Cebu', IsActive: true });
// list.push({ CustomerNo: 'CUST0003', Name: 'Dakay Construction ', Address: 'Doña Modesta Gaisano St, Cebu City, Cebu', IsActive: true });

return list;
// return list;
}

getItemByItemNo(itemNo: string): Item {
return this.getItems().filter(x => x.ItemNo == itemNo)[0];
// async getCustomerByCustomerNo(customerNo: string): Promise<Customer> {
// return (await this.getCustomers()).filter(x => x.CustomerNo == customerNo)[0];
// }

async getItems(): Promise<Item[]> {
const res = await this.http.get(this.BaseUrl + '/product/get-all').toPromise();
return res as Item[];
// let list = new Array<Item>();

// list.push({ ItemNo: 'ITM0001', Name: 'CEMEX', Description: 'CEMEX APO Masonry Cement', UnitPrice: 150, IsActive: true });
// list.push({ ItemNo: 'ITM0002', Name: 'Valspar 82020', Description: 'Valspar 82020 Gray Solid Color Concrete Sealer 1 Gallon', UnitPrice: 450, IsActive: true });
// list.push({ ItemNo: 'ITM0003', Name: 'Rizal Cement', Description: 'Rizal Portland Super Type 1P cement', UnitPrice: 145, IsActive: true });
// list.push({ ItemNo: 'ITM0004', Name: 'Island Cement', Description: 'Island Portland Type 1 Cement', UnitPrice: 140, IsActive: true });
// list.push({ ItemNo: 'ITM0005', Name: 'Palitada King', Description: 'Palitada King Masonry Cement', UnitPrice: 130, IsActive: true });

// return list;
}

// getItemByItemNo(itemNo: string): Item {
// return this.getItems().filter(x => x.ItemNo == itemNo)[0];
// }

getStocks(): Stock[] {

async getStocks(): Promise<Stock[]> {
let list = new Array<Stock>();
let items = this.getItems();
let items = await this.getItems();

let stockId = 1;
for (let item of items) {
Expand All @@ -55,56 +66,64 @@ export class TestDataService {
return list;
}

getSalesOrder(): SalesOrder[] {
let list = new Array<SalesOrder>();
let customers = this.getCustomers();
async getSalesOrders(): Promise<SalesOrder[]> {
const res = await this.http.get(this.BaseUrl + '/order/get-all').toPromise();
return res as SalesOrder[];

for (let ctr = 1; ctr <= 10; ctr++) {
let id = ctr;
// let list = new Array<SalesOrder>();
// let customers = this.getCustomers();

let order = new SalesOrder();
order.Date.setDate(new Date().getDate());
// for (let ctr = 1; ctr <= 10; ctr++) {
// let id = ctr;

order.SalesOrderNo = "SO-00000" + id;
order.Customer = customers[Math.floor(Math.random() * customers.length)];
// let order = new SalesOrder();
// order.Date.setDate(new Date().getDate());

if (id % 2 == 0) {
order.Salesman = "Chuckie";
}
else {
order.Salesman = "Reggie";
}
// order.SalesOrderNo = "SO-00000" + id;
// //order.Customer = customers[Math.floor(Math.random() * customers.length)];

order.Total = Math.round((Math.floor(Math.random() * 1500) + 500) / 10) * 10;
// if (id % 2 == 0) {
// order.Salesman = "Chuckie";
// }
// else {
// order.Salesman = "Reggie";
// }

let result = Math.floor(Math.random() * 3) + 1
// order.Total = Math.round((Math.floor(Math.random() * 1500) + 500) / 10) * 10;

switch (result) {
case 1:
order.Status = "Cancelled";
break;
case 2:
order.Status = "Approved";
break;
// let result = Math.floor(Math.random() * 3) + 1

case 3:
order.Status = "Pending";
break;
}
// switch (result) {
// case 1:
// order.Status = "Cancelled";
// break;
// case 2:
// order.Status = "Approved";
// break;

list.push(order);
}
// case 3:
// order.Status = "Pending";
// break;
// }

return list;
// list.push(order);
// }

// return list;
}

async getOrderByTransaction(transNo:string) : Promise<SalesOrder>{
const res = await this.http.get(this.BaseUrl + '/order/get-order?transactionNo=' + transNo).toPromise();
return res as SalesOrder;
}

}

export class Customer {
CustomerNo: string;
Name: string;
Address: string;
IsActive: boolean;
ContactNo:string;
ContactPerson:string;
}

export class Item {
Expand All @@ -123,10 +142,9 @@ export class Stock {
}

export class SalesOrder {
SalesOrderNo: string;
TransactionNo: string;
Date: Date = new Date();
Customer: Customer;
Salesman: string;
Customer: Customer = new Customer();
Total: number;
Status: string;
}
5 changes: 0 additions & 5 deletions src/app/views/inventory/stocks.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<table class="table table-hover">
<thead>
<tr>
<th>Item #</th>
<th>Name</th>
<th>Description</th>
<th>Unit Price</th>
Expand All @@ -28,14 +27,10 @@
<td>
<input class="form-control" />
</td>
<td>
<input class="form-control" />
</td>
<td></td>
<td></td>
</tr>
<tr *ngFor="let stock of Stocks">
<td>{{stock.Item.ItemNo}}</td>
<td>{{stock.Item.Name}}</td>
<td>{{stock.Item.Description}}</td>
<td>{{stock.Item.UnitPrice | number:'3.2-5'}}</td>
Expand Down
5 changes: 4 additions & 1 deletion src/app/views/inventory/stocks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export class StocksComponent {
Stocks: Stock[] = new Array<Stock>();

constructor(private service: TestDataService) {
this.Stocks = this.service.getStocks();
this.LoadData();
}

async LoadData(){
this.Stocks = await this.service.getStocks();
}
}
16 changes: 8 additions & 8 deletions src/app/views/sales/neworder.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@
<label for="exampleInputEmail1">SO #
<small id="emailHelp" class="text-muted">System generated value</small>
</label>
<input type="text" class="form-control" readonly id="exampleInputEmail1" aria-describedby="emailHelp">
<input type="text" [(ngModel)]="Model.TransactionNo" name="TransactionNo" class="form-control" readonly id="exampleInputEmail1" aria-describedby="emailHelp">
</div>
<div class="form-group">
<label for="exampleInputEmail2">Date</label>
<input type="date" class="form-control" id="exampleInputEmail2" aria-describedby="emailHelp">
<input type="date" [(ngModel)]="Model.Date" name="Date" class="form-control" id="exampleInputEmail2" aria-describedby="emailHelp">
</div>
<div class="form-group">
<label for="exampleInputEmail2">Status</label>
<select class="form-control">
<option>Pending</option>
<option>Approved</option>
<option>Cancel</option>
<select class="form-control" [(ngModel)]="Model.Status" name="Status">
<option value="Pending">Pending</option>
<option value="Approved">Approved</option>
<option value="Cancelled">Cancelled</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail3">Customer</label>
<input type="text" class="form-control" id="exampleInputEmail3" aria-describedby="emailHelp">
<input type="text" [(ngModel)]="Model.Customer.Name" name="Customer.Name" class="form-control" id="exampleInputEmail3" aria-describedby="emailHelp">
</div>
<div class="form-group">
<label for="exampleInputEmail4">Salesman</label>
<input type="text" class="form-control" id="exampleInputEmail4" aria-describedby="emailHelp">
</div>
<div class="form-group">
<label for="exampleInputEmail4">Total Amount</label>
<input type="text" class="form-control" id="exampleInputEmail4" aria-describedby="emailHelp">
<input [(ngModel)]="Model.Total" name="Total" type="text" class="form-control" id="exampleInputEmail4" aria-describedby="emailHelp">
</div>
</div>
</div>
Expand Down
18 changes: 17 additions & 1 deletion src/app/views/sales/neworder.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import { Component } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';

import { TestDataService, SalesOrder, Customer } from '../../services/testdata.service';

@Component({
templateUrl: 'neworder.component.html'
})
export class NewOrderComponent {
constructor() { }

Model:SalesOrder = new SalesOrder();

constructor(private router: Router, private route: ActivatedRoute, private service: TestDataService) {
this.Model.Customer = new Customer();
this.LoadData();
}

async LoadData(){
let transNo: string = this.route.snapshot.queryParams['transactionNo'];
if(transNo != undefined){
this.Model = await this.service.getOrderByTransaction(transNo);
}
}
}
6 changes: 2 additions & 4 deletions src/app/views/sales/order.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<tr>
<th>SO #</th>
<th>Customer</th>
<th>Salesman</th>
<th>Date</th>
<th>Total Amout</th>
<th>Status</th>
Expand Down Expand Up @@ -45,14 +44,13 @@
<td></td>
</tr>
<tr *ngFor="let order of Orders">
<td>{{order.SalesOrderNo}}</td>
<td>{{order.TransactionNo}}</td>
<td>{{order.Customer.Name}}</td>
<td>{{order.Salesman}}</td>
<td>{{order.Date | date: 'dd/MM/yyyy'}}</td>
<td>{{order.Total | number:'3.2-5'}}</td>
<td>{{order.Status}}</td>
<td>
<a routerLink="/sales/order" [queryParams] ="{id: order.ID}">View</a>
<a routerLink="/sales/order" [queryParams] ="{transactionNo: order.TransactionNo}">View</a>
</td>
</tr>
</tbody>
Expand Down
6 changes: 5 additions & 1 deletion src/app/views/sales/order.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export class OrderComponent {
Orders: SalesOrder[] = new Array<SalesOrder>();

constructor(private service : TestDataService) {
this.Orders = this.service.getSalesOrder();
this.LoadData();
}

async LoadData(){
this.Orders = await this.service.getSalesOrders();
}
}
13 changes: 5 additions & 8 deletions src/app/views/setup/customer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<table class="table table-hover">
<thead>
<tr>
<th>Customer #</th>
<th>Name</th>
<th>Address</th>
<th>Status</th>
<th>Contact #</th>
<th>Contact Person</th>
</tr>
</thead>
<tbody>
Expand All @@ -28,17 +28,14 @@
</td>

<td>
<select class="form-control">
<option>Active</option>
<option>Inactive</option>
</select>
<input class="form-control" />
</td>
</tr>
<tr *ngFor="let cust of Customers">
<td>{{cust?.CustomerNo}}</td>
<td>{{cust?.Name}}</td>
<td>{{cust?.Address}}</td>
<td>{{cust?.IsActive ? 'Active' : 'Inactive'}}</td>
<td>{{cust?.ContactNo}}</td>
<td>{{cust?.ContactPerson}}</td>
</tr>
</tbody>
</table>
Expand Down
6 changes: 5 additions & 1 deletion src/app/views/setup/customer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export class CustomerComponent {
Customers: Customer[] = new Array<Customer>();

constructor(private service: TestDataService) {
this.Customers = this.service.getCustomers();
this.loadData();
}

async loadData(){
this.Customers = await this.service.getCustomers();
}

}
Loading

0 comments on commit 882d1ab

Please sign in to comment.