feat: import both confirmed and declined orders in historical import
Historical import now fetches: - state=confirmed -> sync_status='confirmed' - state=declined -> sync_status='rejected' Stats are combined from both API calls. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -454,7 +454,7 @@ function adminMarketplaceLetzshop() {
|
||||
},
|
||||
|
||||
/**
|
||||
* Import historical orders from Letzshop (all confirmed orders)
|
||||
* Import historical orders from Letzshop (confirmed and declined orders)
|
||||
*/
|
||||
async importHistoricalOrders() {
|
||||
if (!this.selectedVendor || !this.letzshopStatus.is_configured) return;
|
||||
@@ -465,16 +465,31 @@ function adminMarketplaceLetzshop() {
|
||||
this.historicalImportResult = null;
|
||||
|
||||
try {
|
||||
const response = await apiClient.post(
|
||||
// Import confirmed orders
|
||||
const confirmedResponse = await apiClient.post(
|
||||
`/admin/letzshop/vendors/${this.selectedVendor.id}/import-history?state=confirmed`
|
||||
);
|
||||
const confirmedStats = confirmedResponse.statistics || confirmedResponse;
|
||||
|
||||
// Stats are nested under 'statistics' key
|
||||
this.historicalImportResult = response.statistics || response;
|
||||
// Import declined (rejected) orders
|
||||
const declinedResponse = await apiClient.post(
|
||||
`/admin/letzshop/vendors/${this.selectedVendor.id}/import-history?state=declined`
|
||||
);
|
||||
const declinedStats = declinedResponse.statistics || declinedResponse;
|
||||
|
||||
// Combine stats
|
||||
this.historicalImportResult = {
|
||||
imported: (confirmedStats.imported || 0) + (declinedStats.imported || 0),
|
||||
updated: (confirmedStats.updated || 0) + (declinedStats.updated || 0),
|
||||
skipped: (confirmedStats.skipped || 0) + (declinedStats.skipped || 0),
|
||||
products_matched: (confirmedStats.products_matched || 0) + (declinedStats.products_matched || 0),
|
||||
products_not_found: (confirmedStats.products_not_found || 0) + (declinedStats.products_not_found || 0),
|
||||
};
|
||||
const stats = this.historicalImportResult;
|
||||
this.successMessage = `Historical import complete: ${stats.imported} imported, ${stats.updated} updated`;
|
||||
|
||||
marketplaceLetzshopLog.info('Historical import result:', response);
|
||||
marketplaceLetzshopLog.info('Historical import result (confirmed):', confirmedResponse);
|
||||
marketplaceLetzshopLog.info('Historical import result (declined):', declinedResponse);
|
||||
|
||||
// Reload orders to show new data
|
||||
await this.loadOrders();
|
||||
|
||||
Reference in New Issue
Block a user