/************************************************************************************
 * Copyright (C) 2012-2023 E.R.P. Consultores y Asociados, C.A.                     *
 * Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com                     *
 * This program is free software: you can redistribute it and/or modify             *
 * it under the terms of the GNU General Public License as published by             *
 * the Free Software Foundation, either version 2 of the License, or                *
 * (at your option) any later version.                                              *
 * This program is distributed in the hope that it will be useful,                  *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                     *
 * GNU General Public License for more details.                                     *
 * You should have received a copy of the GNU General Public License                *
 * along with this program. If not, see <https://www.gnu.org/licenses/>.            *
 ************************************************************************************/
syntax = "proto3";

option java_multiple_files = true;
option java_package = "org.spin.backend.grpc.form.express_shipment";
option java_outer_classname = "ADempiereExpressShipment";

import "proto/base_data_type.proto";

package express_shipment;

service ExpressShipment {
	rpc ListBusinessPartners(ListBusinessPartnersRequest) returns (ListBusinessPartnersResponse) {}
	rpc ListSalesOrders(ListSalesOrdersRequest) returns (ListSalesOrdersResponse) {}
	rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) {}
	// Shipment
	rpc CreateShipment(CreateShipmentRequest) returns (Shipment) {}
	rpc DeleteShipment(DeleteShipmentRequest) returns (data.Empty) {}
	rpc ProcessShipment(ProcessShipmentRequest) returns (Shipment) {}
	//	Shipment Line
	rpc CreateShipmentLine(CreateShipmentLineRequest) returns (ShipmentLine) {}
	rpc DeleteShipmentLine(DeleteShipmentLineRequest) returns (data.Empty) {}
	rpc UpdateShipmentLine(UpdateShipmentLineRequest) returns (ShipmentLine) {}
	rpc ListShipmentLines(ListShipmentLinesRequest) returns (ListShipmentLinesResponse) {}
}


// Business Partner
message BusinessPartner {
	string uuid = 1;
	int32 id = 2;
	string value = 3;
	string tax_id = 4;
	string name = 5;
	string description = 6;
}

message ListBusinessPartnersRequest {
	int32 page_size = 1;
	string page_token = 2;
	string search_value = 3;
}

message ListBusinessPartnersResponse {
	int64 record_count = 1;
	repeated BusinessPartner records = 2;
	string next_page_token = 3;
}


// Orders
message ListSalesOrdersRequest {
	int32 page_size = 1;
	string page_token = 2;
	string search_value = 3;
	int32 business_partner_id = 4;
	string business_partner_uuid = 5;
}

message SalesOrder {
	int32 id = 1;
	string uuid = 2;
	string document_no = 3;
	int64 date_ordered = 4;
}

message ListSalesOrdersResponse {
	int64 record_count = 1;
	repeated SalesOrder records = 2;
	string next_page_token = 3;
}


// Product
message ListProductsRequest {
	int32 page_size = 1;
	string page_token = 2;
	string search_value = 3;
	int32 order_id = 4;
	string order_uuid = 5;
	string upc = 6;
	string sku = 7;
	string value = 8;
	string name = 9;
}

message Product {
	string uuid = 1;
	int32 id = 2;
	string upc = 3;
	string sku = 4;
	string value = 5;
	string name = 6;
	string description = 7;
}

message ListProductsResponse {
	int64 record_count = 1;
	repeated Product records = 2;
	string next_page_token = 3;
}


// Shipment
message CreateShipmentRequest {
	int32 order_id = 1;
	string order_uuid = 2;
	bool is_create_lines_from_order = 3;
}

message Shipment {
	int32 id = 1;
	string uuid = 2;
	string document_no = 3;
	int64 date_ordered = 4;
	int64 movement_date = 5;
	int32 order_id = 6;
	string order_uuid = 7;
	bool is_completed = 8;
}

message DeleteShipmentRequest {
	int32 id = 1;
	string uuid = 2;
}

message ProcessShipmentRequest {
	int32 id = 1;
	string uuid = 2;
	string description = 3;
}


// Shipment Line
message CreateShipmentLineRequest {
	int32 shipment_id = 1;
	string shipment_uuid = 2;
	string description = 3;
	int32 product_id = 4;
	string product_uuid = 5;
	data.Decimal quantity = 6;
	bool is_quantity_from_order_line = 7;
}

message ShipmentLine {
	int32 id = 1;
	string uuid = 2;
	int32 order_line_id = 3;
	string order_line_uuid = 4;
	Product product = 5;
	string description = 6;
	data.Decimal quantity = 7;
	int32 line = 8;
}

message ListShipmentLinesRequest {
	int32 page_size = 1;
	string page_token = 2;
	string search_value = 3;
	int32 shipment_id = 4;
	string shipment_uuid = 5;
}

message ListShipmentLinesResponse {
	int64 record_count = 1;
	repeated ShipmentLine records = 2;
	string next_page_token = 3;
}

message DeleteShipmentLineRequest {
	int32 id = 1;
	string uuid = 2;
}

message UpdateShipmentLineRequest {
	int32 id = 1;
	string uuid = 2;
	string description = 3;
	data.Decimal quantity = 4;
}
