Show all open Tally companies in cash payment review
This commit is contained in:
@@ -273,7 +273,7 @@ async def cash_payment_ledgers(request: Request):
|
||||
date_from = str(form.get("date_from") or date.today().isoformat()).strip()
|
||||
force_refresh = str(form.get("force_refresh") or "").strip().lower() in {"1","true","yes","on"}
|
||||
if not tally_guid:
|
||||
return JSONResponse({"ok": False, "error": "Select a mapped Tally company."}, status_code=400)
|
||||
return JSONResponse({"ok": False, "error": "Select an open Tally company."}, status_code=400)
|
||||
node = get_active_storage_node_for_branch(db, scope.tenant_id, scope.branch_id)
|
||||
if not node or not _node_online(node):
|
||||
return JSONResponse({"ok": False, "error": "ERP Local Agent is offline."}, status_code=409)
|
||||
@@ -351,6 +351,7 @@ async def start_cash_payment_cache(request: Request):
|
||||
if not selected_client:
|
||||
return JSONResponse({"ok": False, "error": "Select a valid client."}, status_code=400)
|
||||
tally_guid = str(form.get("tally_guid") or "").strip()
|
||||
company_name = str(form.get("company_name") or "").strip()
|
||||
cash_ledger_name = str(form.get("cash_ledger_name") or "").strip()
|
||||
date_from = str(form.get("date_from") or "").strip()
|
||||
date_to = str(form.get("date_to") or "").strip()
|
||||
@@ -362,7 +363,7 @@ async def start_cash_payment_cache(request: Request):
|
||||
except Exception as exc:
|
||||
return JSONResponse({"ok": False, "error": str(exc)}, status_code=400)
|
||||
if not tally_guid:
|
||||
return JSONResponse({"ok": False, "error": "Select a mapped Tally company."}, status_code=400)
|
||||
return JSONResponse({"ok": False, "error": "Select an open Tally company."}, status_code=400)
|
||||
if not cash_ledger_name:
|
||||
return JSONResponse({"ok": False, "error": "Load the Tally ledgers and confirm the Cash ledger."}, status_code=400)
|
||||
node = get_active_storage_node_for_branch(db, scope.tenant_id, scope.branch_id)
|
||||
@@ -376,6 +377,7 @@ async def start_cash_payment_cache(request: Request):
|
||||
{
|
||||
**_accounting_storage_payload(selected_client, _financial_year_for_date(parsed_from)),
|
||||
"tally_guid": tally_guid,
|
||||
"company_name": company_name,
|
||||
"date_from": date_from,
|
||||
"date_to": date_to,
|
||||
"cash_ledger_name": cash_ledger_name,
|
||||
|
||||
@@ -32,11 +32,25 @@
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-xs font-semibold uppercase text-slate-500">Tally Company</label>
|
||||
<select name="tally_guid" class="mt-1 w-full rounded-xl border-slate-300 text-sm" {% if selected_client %}required{% endif %}>
|
||||
<option value="">Select open/mapped company</option>
|
||||
<select id="cash-tally-company" name="tally_guid" class="mt-1 w-full rounded-xl border-slate-300 text-sm" {% if selected_client %}required{% endif %}>
|
||||
<option value="">Select open Tally company</option>
|
||||
{% set mapped_guids = [] %}
|
||||
{% if live_result and live_result.accounting %}
|
||||
{% for mapping in live_result.accounting.mappings or [] %}
|
||||
<option value="{{ mapping.tally_guid }}" data-company-name="{{ mapping.company_name or mapping.tally_company_name or '' }}" {% if selected_tally_guid == mapping.tally_guid %}selected{% endif %}>{{ mapping.company_name or mapping.tally_company_name or mapping.tally_guid }}</option>
|
||||
{% if mapping.tally_guid %}{% set _ = mapped_guids.append(mapping.tally_guid) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if live_result and live_result.tally %}
|
||||
{% for company in live_result.tally.companies or [] %}
|
||||
{% set is_mapped = company.guid in mapped_guids %}
|
||||
<option value="{{ company.guid }}" data-company-name="{{ company.name or '' }}" data-open-company="1" {% if selected_tally_guid == company.guid or (not selected_tally_guid and is_mapped) %}selected{% endif %}>{{ company.name or company.guid }}{% if is_mapped %} • Mapped{% endif %}</option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if live_result and live_result.accounting %}
|
||||
{% for mapping in live_result.accounting.mappings or [] %}
|
||||
{% if mapping.tally_guid and mapping.tally_guid not in ((live_result.tally.companies or [])|map(attribute='guid')|list if live_result and live_result.tally else []) %}
|
||||
<option value="{{ mapping.tally_guid }}" data-company-name="{{ mapping.company_name or mapping.tally_company_name or '' }}" data-open-company="0" {% if selected_tally_guid == mapping.tally_guid %}selected{% endif %}>{{ mapping.company_name or mapping.tally_company_name or mapping.tally_guid }} • Mapped (not open)</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</select>
|
||||
@@ -284,6 +298,12 @@
|
||||
}
|
||||
if (ledgerButton) ledgerButton.addEventListener('click', function(){loadCashLedgers(false);});
|
||||
if (ledgerRefreshButton) ledgerRefreshButton.addEventListener('click', function(){loadCashLedgers(true);});
|
||||
const companySelect = document.getElementById('cash-tally-company');
|
||||
if (companySelect) companySelect.addEventListener('change', function(){
|
||||
ledgerSelect.innerHTML = '<option value="">Load and confirm cash ledger</option>';
|
||||
ledgerHelp.textContent = this.value ? 'Company changed. Click Load to use that company's cached ledgers, or Refresh from Tally to re-sync.' : 'Select an open Tally company first.';
|
||||
ledgerProgress.classList.add('hidden');
|
||||
});
|
||||
|
||||
function show() {
|
||||
overlay.classList.remove('hidden');
|
||||
@@ -366,6 +386,10 @@
|
||||
if (!form.reportValidity()) return;
|
||||
const fd = new FormData(form);
|
||||
fd.set('csrf_token', document.getElementById('cash-csrf-token').value);
|
||||
const selectedCompany = document.getElementById('cash-tally-company');
|
||||
const selectedCompanyOption = selectedCompany && selectedCompany.options[selectedCompany.selectedIndex];
|
||||
const selectedCompanyName = selectedCompanyOption ? String(selectedCompanyOption.dataset.companyName || selectedCompanyOption.textContent || '').replace(' • Mapped','').replace(' • Mapped (not open)','').trim() : '';
|
||||
if (selectedCompanyName) fd.set('company_name', selectedCompanyName);
|
||||
button.disabled = true;
|
||||
show();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user