Skip to content

Commit

Permalink
Merge pull request #66 from SLIIT-Y3S2/feature/mobile/delivery/view
Browse files Browse the repository at this point in the history
backend site populate added
  • Loading branch information
Sandaru-IT21001352 committed Oct 29, 2023
2 parents 1c7698b + 7799fbe commit ff21359
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions backend/src/__tests__/delivery-for-site-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ describe("deliveries for site manager", () => {
)
.set("Authorization", `Bearer ${jwt}`);

console.log(body);

expect(statusCode).toBe(200);

expect(body.status).toBe("received");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function markDeliveryAsReceivedHandler(
deliveries.every((delivery) => delivery.status === "received") &&
delivery.order.status !== "received"
) {
delivery.order.status = "received";
delivery.order.status = "pending-payment";
await delivery.order.save();
}
return res.send(updatedDelivery);
Expand Down
1 change: 1 addition & 0 deletions backend/src/service/deliver.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function getDeliveryList(
.populate("items.item")
.populate("order")
.populate("supplier")
.populate("site")
.exec();
}

Expand Down
27 changes: 25 additions & 2 deletions flutter_client/lib/models/goods_receipt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@ import 'package:flutter_client/models/product_model.dart';

enum GoodsReceiptStatus { pendingShipping, received }

class Supplier {
final String id;
final String name;
final String email;
final String contactNumber;

Supplier({
required this.id,
required this.name,
required this.email,
required this.contactNumber,
});

factory Supplier.fromJson(Map<String, dynamic> json) {
return Supplier(
id: json['_id'],
name: json['name'],
email: json['email'],
contactNumber: json['contactNumber'],
);
}
}

class GoodsReceiptItem {
final Product item;
final int quantity;
Expand All @@ -14,12 +37,12 @@ class GoodsReceiptItem {

class GoodsReceipt {
final String id;
final String supplier;
final String site;
final String siteManager;
final String goodsReceiptId;
final GoodsReceiptStatus status;
final List<GoodsReceiptItem> items;
final Supplier supplier;
final DateTime createdAt;

GoodsReceipt({
Expand All @@ -36,7 +59,7 @@ class GoodsReceipt {
factory GoodsReceipt.fromJson(Map<String, dynamic> json) {
return GoodsReceipt(
id: json['_id'],
supplier: json['supplier'],
supplier: Supplier.fromJson(json['supplier']),
site: json['site'],
siteManager: json['siteManager'],
goodsReceiptId: json['goodReceiptId'],
Expand Down
4 changes: 2 additions & 2 deletions flutter_client/lib/widgets/delivery_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DeliveryAdviceCard extends StatelessWidget {
),
const SizedBox(height: 20),
Text(
'Supplier name',
goodsReceipt.supplier.name,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 12,
fontWeight: FontWeight.bold,
Expand All @@ -93,7 +93,7 @@ class DeliveryAdviceCard extends StatelessWidget {
Row(
children: [
Text(
'Rs.25.000',
'Site Name: ${goodsReceipt.site}',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 12,
fontWeight: FontWeight.normal,
Expand Down

0 comments on commit ff21359

Please sign in to comment.