feat: refactor week number handling to use WeekDefinitionId across multiple entities and queries
This commit is contained in:
@@ -111,6 +111,13 @@ service CommissionContract
|
||||
};
|
||||
};
|
||||
|
||||
// Week Definitions (for dropdowns)
|
||||
rpc GetWeekDefinitions(GetWeekDefinitionsRequest) returns (GetWeekDefinitionsResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/Commission/GetWeekDefinitions"
|
||||
};
|
||||
};
|
||||
|
||||
// Financial Reports
|
||||
rpc GetWithdrawalReports(GetWithdrawalReportsRequest) returns (GetWithdrawalReportsResponse){
|
||||
option (google.api.http) = {
|
||||
@@ -124,20 +131,20 @@ service CommissionContract
|
||||
// CalculateWeeklyBalances Command
|
||||
message CalculateWeeklyBalancesRequest
|
||||
{
|
||||
string week_number = 1; // Format: "YYYY-Www" (e.g., "2025-W01")
|
||||
int64 week_definition_id = 1; // Format: "YYYY-Www" (e.g., "2025-W01")
|
||||
bool force_recalculate = 2;
|
||||
}
|
||||
|
||||
// CalculateWeeklyCommissionPool Command
|
||||
message CalculateWeeklyCommissionPoolRequest
|
||||
{
|
||||
string week_number = 1;
|
||||
int64 week_definition_id = 1;
|
||||
}
|
||||
|
||||
// ProcessUserPayouts Command
|
||||
message ProcessUserPayoutsRequest
|
||||
{
|
||||
string week_number = 1;
|
||||
int64 week_definition_id = 1;
|
||||
bool force_reprocess = 2;
|
||||
}
|
||||
|
||||
@@ -176,19 +183,19 @@ message RejectWithdrawalRequest
|
||||
// GetWeeklyCommissionPool Query
|
||||
message GetWeeklyCommissionPoolRequest
|
||||
{
|
||||
string week_number = 1;
|
||||
int64 week_definition_id = 1;
|
||||
}
|
||||
|
||||
message GetWeeklyCommissionPoolResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
string week_number = 2;
|
||||
int64 total_pool_amount = 3; // Rials
|
||||
int32 total_balances = 4;
|
||||
int64 value_per_balance = 5; // Rials per balance
|
||||
bool is_calculated = 6;
|
||||
google.protobuf.Timestamp calculated_at = 7;
|
||||
google.protobuf.Timestamp created = 8;
|
||||
int64 week_definition_id = 2;
|
||||
int64 total_pool_amount = 4; // Rials
|
||||
int32 total_balances = 5;
|
||||
int64 value_per_balance = 6; // Rials per balance
|
||||
bool is_calculated = 7;
|
||||
google.protobuf.Timestamp calculated_at = 8;
|
||||
google.protobuf.Timestamp created = 9;
|
||||
}
|
||||
|
||||
// GetUserCommissionPayouts Query
|
||||
@@ -196,9 +203,9 @@ message GetUserCommissionPayoutsRequest
|
||||
{
|
||||
google.protobuf.Int64Value user_id = 1;
|
||||
google.protobuf.Int32Value status = 2; // CommissionPayoutStatus enum
|
||||
google.protobuf.StringValue week_number = 3;
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
google.protobuf.Int64Value week_definition_id = 3; // Preferred filter
|
||||
int32 page_index = 5;
|
||||
int32 page_size = 6;
|
||||
}
|
||||
|
||||
message GetUserCommissionPayoutsResponse
|
||||
@@ -210,19 +217,20 @@ message GetUserCommissionPayoutsResponse
|
||||
message UserCommissionPayoutModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string user_name = 3;
|
||||
string week_number = 4;
|
||||
int64 weekly_pool_id = 5;
|
||||
int64 balances_earned = 6;
|
||||
int64 value_per_balance = 7;
|
||||
int64 total_amount = 8;
|
||||
int32 status = 9; // CommissionPayoutStatus enum
|
||||
google.protobuf.Timestamp paid_at = 10;
|
||||
google.protobuf.Int32Value withdrawal_method = 11;
|
||||
string iban_number = 12;
|
||||
google.protobuf.Timestamp withdrawn_at = 13;
|
||||
google.protobuf.Timestamp created = 14;
|
||||
int64 week_definition_id = 2;
|
||||
int64 user_id = 3;
|
||||
string user_name = 4;
|
||||
string week_display_name = 5;
|
||||
int64 weekly_pool_id = 6;
|
||||
int64 balances_earned = 7;
|
||||
int64 value_per_balance = 8;
|
||||
int64 total_amount = 9;
|
||||
int32 status = 10; // CommissionPayoutStatus enum
|
||||
google.protobuf.Timestamp paid_at = 11;
|
||||
google.protobuf.Int32Value withdrawal_method = 12;
|
||||
string iban_number = 13;
|
||||
google.protobuf.Timestamp withdrawn_at = 14;
|
||||
google.protobuf.Timestamp created = 15;
|
||||
}
|
||||
|
||||
// GetCommissionPayoutHistory Query
|
||||
@@ -230,9 +238,9 @@ message GetCommissionPayoutHistoryRequest
|
||||
{
|
||||
google.protobuf.Int64Value payout_id = 1;
|
||||
google.protobuf.Int64Value user_id = 2;
|
||||
google.protobuf.StringValue week_number = 3;
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
google.protobuf.Int64Value week_definition_id = 3; // Preferred filter
|
||||
int32 page_index = 5;
|
||||
int32 page_size = 6;
|
||||
}
|
||||
|
||||
message GetCommissionPayoutHistoryResponse
|
||||
@@ -246,14 +254,14 @@ message CommissionPayoutHistoryModel
|
||||
int64 id = 1;
|
||||
int64 payout_id = 2;
|
||||
int64 user_id = 3;
|
||||
string week_number = 4;
|
||||
int64 amount_before = 5;
|
||||
int64 amount_after = 6;
|
||||
int32 old_status = 7; // CommissionPayoutStatus enum
|
||||
int32 new_status = 8;
|
||||
int32 action = 9; // CommissionPayoutAction enum
|
||||
string performed_by = 10;
|
||||
string reason = 11;
|
||||
int64 week_definition_id = 4;
|
||||
int64 amount_before = 6;
|
||||
int64 amount_after = 7;
|
||||
int32 old_status = 8; // CommissionPayoutStatus enum
|
||||
int32 new_status = 9;
|
||||
int32 action = 10; // CommissionPayoutAction enum
|
||||
string performed_by = 11;
|
||||
string reason = 12;
|
||||
google.protobuf.Timestamp created = 13;
|
||||
}
|
||||
|
||||
@@ -275,15 +283,16 @@ message GetAvailableWeeksResponse
|
||||
|
||||
message WeekInfo
|
||||
{
|
||||
string week_number = 1; // YYYY-Www format
|
||||
google.protobuf.Timestamp start_date = 2;
|
||||
google.protobuf.Timestamp end_date = 3;
|
||||
bool is_calculated = 4;
|
||||
google.protobuf.Timestamp calculated_at = 5;
|
||||
string last_execution_status = 6;
|
||||
int64 total_pool_amount = 7;
|
||||
int32 eligible_users_count = 8;
|
||||
string display_text = 9; // نمایش فارسی برای UI
|
||||
int64 week_definition_id = 1; // FK to WeekDefinition
|
||||
string display_name = 2;
|
||||
google.protobuf.Timestamp start_date = 3;
|
||||
google.protobuf.Timestamp end_date = 4;
|
||||
bool is_calculated = 5;
|
||||
google.protobuf.Timestamp calculated_at = 6;
|
||||
string last_execution_status = 7;
|
||||
int64 total_pool_amount = 8;
|
||||
int32 eligible_users_count = 9;
|
||||
string display_text = 10; // نمایش فارسی برای UI
|
||||
}
|
||||
|
||||
|
||||
@@ -291,10 +300,10 @@ message WeekInfo
|
||||
message GetUserWeeklyBalancesRequest
|
||||
{
|
||||
google.protobuf.Int64Value user_id = 1;
|
||||
google.protobuf.StringValue week_number = 2;
|
||||
bool only_active = 3; // Only non-expired balances
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
google.protobuf.Int64Value week_definition_id = 2; // Preferred filter
|
||||
bool only_active = 4; // Only non-expired balances
|
||||
int32 page_index = 5;
|
||||
int32 page_size = 6;
|
||||
}
|
||||
|
||||
message GetUserWeeklyBalancesResponse
|
||||
@@ -307,14 +316,15 @@ message UserWeeklyBalanceModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string week_number = 3;
|
||||
int32 left_leg_balances = 4;
|
||||
int32 right_leg_balances = 5;
|
||||
int32 total_balances = 6;
|
||||
int64 weekly_pool_contribution = 7;
|
||||
google.protobuf.Timestamp calculated_at = 8;
|
||||
bool is_expired = 9;
|
||||
google.protobuf.Timestamp created = 10;
|
||||
int64 week_definition_id = 3;
|
||||
string week_display_name = 4;
|
||||
int32 left_leg_balances = 5;
|
||||
int32 right_leg_balances = 6;
|
||||
int32 total_balances = 7;
|
||||
int64 weekly_pool_contribution = 8;
|
||||
google.protobuf.Timestamp calculated_at = 9;
|
||||
bool is_expired = 10;
|
||||
google.protobuf.Timestamp created = 11;
|
||||
}
|
||||
|
||||
// GetAllWeeklyPools Query
|
||||
@@ -336,13 +346,13 @@ message GetAllWeeklyPoolsResponse
|
||||
message WeeklyCommissionPoolModel
|
||||
{
|
||||
int64 id = 1;
|
||||
string week_number = 2;
|
||||
int64 total_pool_amount = 3;
|
||||
int32 total_balances = 4;
|
||||
int64 value_per_balance = 5;
|
||||
bool is_calculated = 6;
|
||||
google.protobuf.Timestamp calculated_at = 7;
|
||||
google.protobuf.Timestamp created = 8;
|
||||
int64 week_definition_id = 2;
|
||||
int64 total_pool_amount = 4;
|
||||
int32 total_balances = 5;
|
||||
int64 value_per_balance = 6;
|
||||
bool is_calculated = 7;
|
||||
google.protobuf.Timestamp calculated_at = 8;
|
||||
google.protobuf.Timestamp created = 9;
|
||||
}
|
||||
|
||||
// GetWithdrawalRequests Query
|
||||
@@ -350,10 +360,10 @@ message GetWithdrawalRequestsRequest
|
||||
{
|
||||
google.protobuf.Int32Value status = 1; // CommissionPayoutStatus enum: Pending=1, Approved=2, Rejected=3
|
||||
google.protobuf.Int64Value user_id = 2;
|
||||
google.protobuf.StringValue week_number = 3;
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
string iban_number = 6;
|
||||
google.protobuf.Int64Value week_definition_id = 3; // Preferred filter
|
||||
int32 page_index = 5;
|
||||
int32 page_size = 6;
|
||||
string iban_number = 7;
|
||||
}
|
||||
|
||||
message GetWithdrawalRequestsResponse
|
||||
@@ -367,7 +377,7 @@ message GetWithdrawalRequestsResponse
|
||||
// TriggerWeeklyCalculation Command
|
||||
message TriggerWeeklyCalculationRequest
|
||||
{
|
||||
string week_number = 1; // Format: "YYYY-Www" (e.g., "2025-W48")
|
||||
int64 week_definition_id = 1; // Format: "YYYY-Www" (e.g., "2025-W48")
|
||||
bool force_recalculate = 2; // اگر true باشد، محاسبات قبلی را حذف و دوباره محاسبه میکند
|
||||
bool skip_balances = 3; // Skip balance calculation (only pool and payouts)
|
||||
bool skip_pool = 4; // Skip pool calculation (only balances and payouts)
|
||||
@@ -405,12 +415,12 @@ message GetWorkerStatusResponse
|
||||
// GetWorkerExecutionLogs Query
|
||||
message GetWorkerExecutionLogsRequest
|
||||
{
|
||||
google.protobuf.StringValue week_number = 1; // Filter by week
|
||||
google.protobuf.StringValue execution_id = 2; // Filter by specific execution
|
||||
google.protobuf.BoolValue success_only = 3; // Show only successful runs
|
||||
google.protobuf.BoolValue failed_only = 4; // Show only failed runs
|
||||
int32 page_index = 5;
|
||||
int32 page_size = 6;
|
||||
google.protobuf.Int64Value week_definition_id = 1; // Preferred filter
|
||||
google.protobuf.StringValue execution_id = 3; // Filter by specific execution
|
||||
google.protobuf.BoolValue success_only = 4; // Show only successful runs
|
||||
google.protobuf.BoolValue failed_only = 5; // Show only failed runs
|
||||
int32 page_index = 6;
|
||||
int32 page_size = 7;
|
||||
}
|
||||
|
||||
message GetWorkerExecutionLogsResponse
|
||||
@@ -422,15 +432,15 @@ message GetWorkerExecutionLogsResponse
|
||||
message WorkerExecutionLogModel
|
||||
{
|
||||
string execution_id = 1;
|
||||
string week_number = 2;
|
||||
string step = 3; // "Balances" | "Pool" | "Payouts" | "Full"
|
||||
bool success = 4;
|
||||
google.protobuf.StringValue error_message = 5;
|
||||
google.protobuf.Timestamp started_at = 6;
|
||||
google.protobuf.Timestamp completed_at = 7;
|
||||
int64 duration_ms = 8; // Duration in milliseconds
|
||||
int32 records_processed = 9;
|
||||
google.protobuf.StringValue details = 10; // JSON or text details
|
||||
int64 week_definition_id = 2;
|
||||
string step = 4; // "Balances" | "Pool" | "Payouts" | "Full"
|
||||
bool success = 5;
|
||||
google.protobuf.StringValue error_message = 6;
|
||||
google.protobuf.Timestamp started_at = 7;
|
||||
google.protobuf.Timestamp completed_at = 8;
|
||||
int64 duration_ms = 9; // Duration in milliseconds
|
||||
int32 records_processed = 10;
|
||||
google.protobuf.StringValue details = 11; // JSON or text details
|
||||
}
|
||||
|
||||
// GetWithdrawalReports Query
|
||||
@@ -482,17 +492,69 @@ message WithdrawalRequestModel
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string user_name = 3;
|
||||
string week_number = 4;
|
||||
int64 amount = 5;
|
||||
int32 status = 6; // CommissionPayoutStatus enum
|
||||
int32 withdrawal_method = 7; // WithdrawalMethod enum
|
||||
string iban_number = 8;
|
||||
google.protobuf.Timestamp requested_at = 9;
|
||||
google.protobuf.Timestamp processed_at = 10;
|
||||
string processed_by = 11;
|
||||
string reason = 12;
|
||||
google.protobuf.Timestamp created = 13;
|
||||
string bank_reference_id = 14;
|
||||
string bank_tracking_code = 15;
|
||||
string payment_failure_reason = 16;
|
||||
int64 week_definition_id = 4;
|
||||
int64 amount = 6;
|
||||
int32 status = 7; // CommissionPayoutStatus enum
|
||||
int32 withdrawal_method = 8; // WithdrawalMethod enum
|
||||
string iban_number = 9;
|
||||
google.protobuf.Timestamp requested_at = 10;
|
||||
google.protobuf.Timestamp processed_at = 11;
|
||||
string processed_by = 12;
|
||||
string reason = 13;
|
||||
google.protobuf.Timestamp created = 14;
|
||||
string bank_reference_id = 15;
|
||||
string bank_tracking_code = 16;
|
||||
string payment_failure_reason = 17;
|
||||
}
|
||||
|
||||
// ============ Week Definitions (for dropdowns) ============
|
||||
|
||||
// GetWeekDefinitions Query - برای دریافت لیست هفتهها برای dropdown
|
||||
message GetWeekDefinitionsRequest
|
||||
{
|
||||
//موقعیت صفحه بندی
|
||||
messages.PaginationState pagination_state = 1;
|
||||
//مرتب سازی بر اساس
|
||||
google.protobuf.StringValue sort_by = 2;
|
||||
//فیلتر
|
||||
GetWeekDefinitionsFilter filter = 3;
|
||||
}
|
||||
|
||||
message GetWeekDefinitionsFilter
|
||||
{
|
||||
//جستجوی متنی روی DisplayName
|
||||
google.protobuf.StringValue search_text = 1;
|
||||
//شماره ترتیب هفته
|
||||
google.protobuf.Int32Value week_order = 2;
|
||||
//شماره هفته میلادی
|
||||
google.protobuf.StringValue gregorian_week_number = 3;
|
||||
//شماره هفته شمسی
|
||||
google.protobuf.StringValue persian_week_number = 4;
|
||||
//سال میلادی
|
||||
google.protobuf.Int32Value gregorian_year = 5;
|
||||
//سال شمسی
|
||||
google.protobuf.Int32Value persian_year = 6;
|
||||
//فقط هفتههای فعال
|
||||
google.protobuf.BoolValue is_active = 7;
|
||||
}
|
||||
|
||||
message GetWeekDefinitionsResponse
|
||||
{
|
||||
repeated WeekDefinitionItem data = 1;
|
||||
int32 total_count = 2;
|
||||
}
|
||||
|
||||
message WeekDefinitionItem
|
||||
{
|
||||
int64 id = 1; // WeekDefinitionId
|
||||
int32 week_order = 2;
|
||||
string display_name = 3; // هفته یکم، هفته دوم، ...
|
||||
string gregorian_week_number = 4; // 2025-W46
|
||||
string persian_week_number = 5; // 1404-W35
|
||||
google.protobuf.Timestamp start_date = 6;
|
||||
google.protobuf.Timestamp end_date = 7;
|
||||
int32 gregorian_year = 8;
|
||||
int32 persian_year = 9;
|
||||
bool is_active = 10;
|
||||
bool is_current_week = 11;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user