Show all open Tally companies in cash payment review
This commit is contained in:
@@ -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