added rahimi
This commit is contained in:
@@ -746,4 +746,37 @@ class DashboardController extends Controller
|
||||
|
||||
return response()->json(['deleted' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* تطبیق دفتر اکانت روی نود همکار (Montzar) با سفارشهای مچشده — نه تهحساب.
|
||||
*/
|
||||
public function montzarReconcile(Request $request)
|
||||
{
|
||||
$config = app(ConfigService::class);
|
||||
if (!$config->usesMontzarPricing()) {
|
||||
return response()->json([
|
||||
'message' => 'این گزارش فقط وقتی منبع قیمت montzar است در دسترس است.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$startDate = $request->input('startDate')
|
||||
?: now()->subDays(30)->toDateString();
|
||||
$endDate = $request->input('endDate')
|
||||
?: now()->toDateString();
|
||||
|
||||
try {
|
||||
$payload = app(\App\Services\MontzarReconcileService::class)
|
||||
->reconcile((string) $startDate, (string) $endDate);
|
||||
} catch (\Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $e) {
|
||||
throw $e;
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'خواندن دفتر همکار ناموفق بود: ' . $e->getMessage(),
|
||||
], 422);
|
||||
}
|
||||
|
||||
return response()->json($payload);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user