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

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

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

Synced Dec 4, 01:45 UTC

Sync payment settlements and include them in imports

davoodmehraban89 committed Sep 28, 2026 at 15:06 UTC 2de5b3409a8d2cd64e13a7dc60229c7627944046
1 file changed +4 -3
js/sync.js
+4 -3
@@ -1,4 +1,4 @@
1 -let datastore={companies:[],contacts:[],products:[],invoices:[],purchases:[],cheques:[],expenses:[],settings:[]};
1 +let datastore={companies:[],contacts:[],products:[],invoices:[],purchases:[],cheques:[],expenses:[],payments:[],settings:[]};
2 function getMyProducts(){return !currentUser?[]:datastore.products.filter(p=>p.ownerUserId===currentUser.id);}
3 function getMyContacts(){return !currentUser?[]:datastore.contacts.filter(c=>c.ownerUserId===currentUser.id);}
4 function getMyCompanies(){return !currentUser?[]:datastore.companies.filter(c=>c.ownerUserId===currentUser.id);}
@@ -6,6 +6,7 @@ function getMyInvoices(){return !currentUser?[]:datastore.invoices.filter(i=>i.o
6 function getMyPurchases(){return !currentUser?[]:(datastore.purchases||[]).filter(i=>i.ownerUserId===currentUser.id);}
7 function getMyCheques(){return !currentUser?[]:datastore.cheques.filter(c=>c.ownerUserId===currentUser.id);}
8 function getMyExpenses(){return !currentUser?[]:datastore.expenses.filter(e=>e.ownerUserId===currentUser.id);}
9 +function getMyPayments(){return !currentUser?[]:(datastore.payments||[]).filter(p=>p.ownerUserId===currentUser.id);}
10 function getMySettings(){
11 if(!currentUser)return{invoice_kind:'non_formal',vat_mode:'none',vat_rate:10,default_company_id:'',currency_mode:'rial',currency_custom:''};
12 if(!Array.isArray(datastore.settings))datastore.settings=[];
@@ -144,7 +145,7 @@ function safeId(raw,prefix){
145 }
146 function absorbRecords(imported){
147 const uid=currentUser.id;let count=0;
147 - ['companies','contacts','products','invoices','purchases','cheques','expenses'].forEach(key=>{
148 + ['companies','contacts','products','invoices','purchases','cheques','expenses','payments'].forEach(key=>{
149 if(!Array.isArray(imported[key]))return;
150 imported[key].forEach(raw=>{
151 if(!raw||typeof raw!=='object')return;
@@ -170,7 +171,7 @@ function maybeMigrateLegacyData(){
171 let old;try{old=JSON.parse(rawOld);}catch(e){return;}
172 const isSeed=it=>it&&it.ownerUserId==='user_admin'&&['COMP-1','C-1','P-1','P-2'].includes(it.id);
173 const clean={};let n=0;
173 - ['companies','contacts','products','invoices','purchases','cheques','expenses'].forEach(k=>{
174 + ['companies','contacts','products','invoices','purchases','cheques','expenses','payments'].forEach(k=>{
175 clean[k]=(old&&Array.isArray(old[k])?old[k]:[]).filter(it=>!isSeed(it));
176 n+=clean[k].length;
177 });