Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #67

Merged
merged 2 commits into from
Oct 29, 2023
Merged

Dev #67

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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