syntax = "proto3"; package purchase; option go_package = "./pb"; // ==================== Supplier ==================== message SupplierInfo { string supplier_id = 1; string supplier_name = 2; string phone = 3; int64 purchase_count = 4; string delivered_qty = 5; string payable_amount = 6; string paid_amount = 7; int64 status = 8; string remark = 9; string created_at = 10; string updated_at = 11; } message CreateSupplierReq { string supplier_name = 1; string phone = 2; string remark = 3; } message UpdateSupplierReq { string supplier_id = 1; string supplier_name = 2; string phone = 3; int64 status = 4; string remark = 5; } message DeleteSupplierReq { string supplier_id = 1; } message GetSupplierReq { string supplier_id = 1; } message ListSupplierReq { int64 page = 1; int64 page_size = 2; string supplier_name = 3; int64 status = 4; } message ListSupplierResp { int64 total = 1; repeated SupplierInfo list = 2; } // ==================== PurchaseOrder ==================== message PurchaseOrderInfo { string order_id = 1; string order_no = 2; string supplier_id = 3; string supplier_name = 4; string order_date = 5; string contract_amount = 6; string received_qty = 7; string paid_amount = 8; int64 payment_status = 9; int64 receipt_status = 10; string purchase_by = 11; string creator = 12; string operator = 13; int64 status = 14; string remark = 15; string created_at = 16; string updated_at = 17; repeated PurchaseOrderDetailInfo details = 18; } message PurchaseOrderDetailInfo { string detail_id = 1; string order_id = 2; string product_id = 3; string product_name = 4; string spec = 5; string color = 6; string quantity = 7; string unit_price = 8; string amount = 9; string received_qty = 10; string remark = 11; } message PurchaseOrderDetailReq { string product_id = 1; string product_name = 2; string spec = 3; string color = 4; string quantity = 5; string unit_price = 6; string remark = 7; } message CreatePurchaseOrderReq { string supplier_id = 1; string order_date = 2; string purchase_by = 3; string remark = 4; repeated PurchaseOrderDetailReq details = 5; } message UpdatePurchaseOrderReq { string order_id = 1; string supplier_id = 2; string order_date = 3; string purchase_by = 4; string remark = 5; repeated PurchaseOrderDetailReq details = 6; } message ConfirmPurchaseOrderReq { string order_id = 1; } message CancelPurchaseOrderReq { string order_id = 1; } message GetPurchaseOrderReq { string order_id = 1; } message ListPurchaseOrderReq { int64 page = 1; int64 page_size = 2; string supplier_id = 3; int64 status = 4; string start_date = 5; string end_date = 6; } message ListPurchaseOrderResp { int64 total = 1; repeated PurchaseOrderInfo list = 2; } // ==================== PurchaseReceipt ==================== message PurchaseReceiptInfo { string receipt_id = 1; string receipt_no = 2; string order_id = 3; string receipt_date = 4; string received_by = 5; int64 status = 6; string remark = 7; string created_at = 8; repeated PurchaseReceiptDetailInfo details = 9; } message PurchaseReceiptDetailInfo { string detail_id = 1; string receipt_id = 2; string order_detail_id = 3; string product_id = 4; string actual_qty = 5; string unit_cost = 6; string remark = 7; } message PurchaseReceiptDetailReq { string order_detail_id = 1; string product_id = 2; string actual_qty = 3; string unit_cost = 4; string remark = 5; } message CreatePurchaseReceiptReq { string order_id = 1; string receipt_date = 2; string received_by = 3; string remark = 4; repeated PurchaseReceiptDetailReq details = 5; } message ConfirmPurchaseReceiptReq { string receipt_id = 1; } message GetPurchaseReceiptReq { string receipt_id = 1; } message ListPurchaseReceiptReq { int64 page = 1; int64 page_size = 2; string order_id = 3; int64 status = 4; string start_date = 5; string end_date = 6; } message ListPurchaseReceiptResp { int64 total = 1; repeated PurchaseReceiptInfo list = 2; } // ==================== PurchasePayment ==================== message PurchasePaymentInfo { string payment_id = 1; string order_id = 2; string supplier_id = 3; string payment_date = 4; string amount = 5; string payment_method = 6; string operator = 7; string remark = 8; string created_at = 9; } message CreatePurchasePaymentReq { string order_id = 1; string payment_date = 2; string amount = 3; string payment_method = 4; string remark = 5; } message GetPurchasePaymentReq { string payment_id = 1; } message ListPurchasePaymentReq { int64 page = 1; int64 page_size = 2; string order_id = 3; string supplier_id = 4; string start_date = 5; string end_date = 6; } message ListPurchasePaymentResp { int64 total = 1; repeated PurchasePaymentInfo list = 2; } // ==================== InventoryLog ==================== message InventoryLogInfo { string log_id = 1; string product_id = 2; string change_qty = 3; string balance_after = 4; int64 change_type = 5; string ref_type = 6; string ref_id = 7; string contact_id = 8; string log_date = 9; string operator = 10; string remark = 11; string created_at = 12; } message ListInventoryLogReq { int64 page = 1; int64 page_size = 2; string product_id = 3; string ref_type = 4; int64 change_type = 5; string start_date = 6; string end_date = 7; } message ListInventoryLogResp { int64 total = 1; repeated InventoryLogInfo list = 2; } // ==================== Stats ==================== message PurchaseStatsSummaryReq { string start_date = 1; string end_date = 2; } message PurchaseStatsSummaryResp { string total_purchase_amount = 1; string total_paid_amount = 2; string total_unpaid_amount = 3; int64 order_count = 4; int64 receipt_count = 5; } message PurchaseStatsBySupplierItem { string supplier_id = 1; string supplier_name = 2; string purchase_amount = 3; string paid_amount = 4; int64 order_count = 5; } message PurchaseStatsBySupplierResp { repeated PurchaseStatsBySupplierItem list = 1; } message PurchaseStatsByProductItem { string product_id = 1; string product_name = 2; string spec = 3; string color = 4; string total_qty = 5; string avg_unit_price = 6; string total_amount = 7; } message PurchaseStatsByProductResp { repeated PurchaseStatsByProductItem list = 1; } // ==================== Common ==================== message IdResp { string id = 1; } message Empty {} // ==================== Service ==================== service PurchaseService { // Supplier CRUD rpc CreateSupplier(CreateSupplierReq) returns (IdResp); rpc UpdateSupplier(UpdateSupplierReq) returns (Empty); rpc DeleteSupplier(DeleteSupplierReq) returns (Empty); rpc GetSupplier(GetSupplierReq) returns (SupplierInfo); rpc ListSupplier(ListSupplierReq) returns (ListSupplierResp); // PurchaseOrder CRUD + status rpc CreatePurchaseOrder(CreatePurchaseOrderReq) returns (IdResp); rpc UpdatePurchaseOrder(UpdatePurchaseOrderReq) returns (Empty); rpc ConfirmPurchaseOrder(ConfirmPurchaseOrderReq) returns (Empty); rpc CancelPurchaseOrder(CancelPurchaseOrderReq) returns (Empty); rpc GetPurchaseOrder(GetPurchaseOrderReq) returns (PurchaseOrderInfo); rpc ListPurchaseOrder(ListPurchaseOrderReq) returns (ListPurchaseOrderResp); // Receipt rpc CreatePurchaseReceipt(CreatePurchaseReceiptReq) returns (IdResp); rpc ConfirmPurchaseReceipt(ConfirmPurchaseReceiptReq) returns (Empty); rpc GetPurchaseReceipt(GetPurchaseReceiptReq) returns (PurchaseReceiptInfo); rpc ListPurchaseReceipt(ListPurchaseReceiptReq) returns (ListPurchaseReceiptResp); // Payment rpc CreatePurchasePayment(CreatePurchasePaymentReq) returns (IdResp); rpc ListPurchasePayment(ListPurchasePaymentReq) returns (ListPurchasePaymentResp); // InventoryLog rpc ListInventoryLog(ListInventoryLogReq) returns (ListInventoryLogResp); // Stats rpc GetPurchaseStatsSummary(PurchaseStatsSummaryReq) returns (PurchaseStatsSummaryResp); rpc GetPurchaseStatsBySupplier(PurchaseStatsSummaryReq) returns (PurchaseStatsBySupplierResp); rpc GetPurchaseStatsByProduct(PurchaseStatsSummaryReq) returns (PurchaseStatsByProductResp); }