@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 7715da8
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 4, 09:15 UTC

fix(company): export active company only and reject importing foreign-company records

davoodmehraban89 committed Oct 14, 2026 at 11:53 UTC 7715da8a18910c9f9b6b8622aebd9c52073d71ea
1 file changed +2 -1
js/backup.js
+2 -1
@@ -1,7 +1,7 @@
1 async function exportDataBlob(){
2 if(typeof window.requireFreshFinoraMembership==='function'&&!await window.requireFreshFinoraMembership()){alert('خروجی‌گیری متوقف شد؛ عضویت سازمانی باید دوباره از سرور تأیید شود.');return;}
3 if(typeof window.finoraCanManageOrganization==='function'&&!window.finoraCanManageOrganization()){alert('خروجی کامل سازمان فقط برای مالک یا عضو دارای مجوز مدیریت سازمان مجاز است.');return;}
4 - const userExport={user:currentUser?.username,exportedAt:new Date().toISOString(),companies:getMyCompanies(),contacts:getMyContacts(),products:getMyProducts(),invoices:getMyInvoices(),purchases:getMyPurchases(),cheques:getMyCheques(),expenses:getMyExpenses(),payments:getMyPayments(),fiscalYears:getMyFiscalYears(),accounts:getMyAccounts(),dimensionTypes:getMyDimensionTypes(),dimensionValues:getMyDimensionValues(),accountDimensionRules:getMyAccountDimensionRules(),branches:getMyBranches(),projects:getMyGlobalProjects(),projectLinks:afOwned('projectLinks'),postingProfiles:getMyPostingProfiles(),journalVouchers:getMyJournalVouchers(),journalLines:getMyJournalLines(),journalLineDimensions:getMyJournalLineDimensions(),contracts:getMyContracts(),contractAmendments:getMyContractAmendments(),contractParties:getMyContractParties(),contractDeductions:getMyContractDeductions(),guarantees:getMyGuarantees(),guaranteeEvents:getMyGuaranteeEvents(),contractStatements:getMyContractStatements(),phase4Audit:getMyPhase4Audit(),warehouses:getMyWarehouses(),stockMovements:getMyStockMovements(),inventoryCounts:getMyInventoryCounts(),fixedAssets:getMyFixedAssets(),assetDepreciations:getMyAssetDepreciations(),currencies:getMyCurrencies(),exchangeRates:getMyExchangeRates(),costCenters:getMyCostCenters(),importBatches:getMyImportBatches(),integrationConnections:getMyIntegrationConnections(),integrationOutbox:getMyIntegrationOutbox(),phase5Audit:getMyPhase5Audit(),settings:getMySettings()};
4 + const userExport={user:currentUser?.username,exportedAt:new Date().toISOString(),companies:getMyCompanies().filter(c=>c.id===finoraActiveCompanyId()),contacts:getMyContacts(),products:getMyProducts(),invoices:getMyInvoices(),purchases:getMyPurchases(),cheques:getMyCheques(),expenses:getMyExpenses(),payments:getMyPayments(),fiscalYears:getMyFiscalYears(),accounts:getMyAccounts(),dimensionTypes:getMyDimensionTypes(),dimensionValues:getMyDimensionValues(),accountDimensionRules:getMyAccountDimensionRules(),branches:getMyBranches(),projects:getMyGlobalProjects(),projectLinks:afOwned('projectLinks'),postingProfiles:getMyPostingProfiles(),journalVouchers:getMyJournalVouchers(),journalLines:getMyJournalLines(),journalLineDimensions:getMyJournalLineDimensions(),contracts:getMyContracts(),contractAmendments:getMyContractAmendments(),contractParties:getMyContractParties(),contractDeductions:getMyContractDeductions(),guarantees:getMyGuarantees(),guaranteeEvents:getMyGuaranteeEvents(),contractStatements:getMyContractStatements(),phase4Audit:getMyPhase4Audit(),warehouses:getMyWarehouses(),stockMovements:getMyStockMovements(),inventoryCounts:getMyInventoryCounts(),fixedAssets:getMyFixedAssets(),assetDepreciations:getMyAssetDepreciations(),currencies:getMyCurrencies(),exchangeRates:getMyExchangeRates(),costCenters:getMyCostCenters(),importBatches:getMyImportBatches(),integrationConnections:getMyIntegrationConnections(),integrationOutbox:getMyIntegrationOutbox(),phase5Audit:getMyPhase5Audit(),settings:getMySettings()};
5 const blobString="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(userExport,null,2));
6 const anchor=document.createElement('a');
7 anchor.setAttribute("href",blobString);
@@ -23,6 +23,7 @@ async function importDataBlob(event){
23 const imported=JSON.parse(e.target.result);
24 if(!imported||typeof imported!=='object'||Array.isArray(imported))throw new Error('bad');
25 if(typeof P5Domain==='object')P5Domain.validateRestore(imported,COLLS);
26 + finoraValidateImportCompanyScope(imported);
27 const summary=COLLS.filter(k=>Array.isArray(imported[k])&&imported[k].length).map(k=>k+': '+imported[k].length).join(' | ');
28 if(!confirm('بازگردانی به‌صورت ادغام امن انجام می‌شود و سابقه قطعی موجود بازنویسی نخواهد شد. ادامه؟\n'+summary))return;
29 absorbRecords(imported);