NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

{% extends 'dashboard/index.html' %}
{% load mathfilters %}
{% load humanize %}

{% block dashoard_title %}
Party Ledger
{% if choose_from == "P" %}
({{selected_party.party_name}}) -
{% else %}
({{choose_vendor.vendor_name}}) -
{% endif %}
{% endblock %}

{% block dashboard_heading %}
<h1 class="h4 mb-0 text-gray-800">
Party Ledger
</h1>

<style>
table td, th {
padding: 0px!important;
}
</style>

{% endblock %}

{% block dashboard_content %}
<form action="" method="post" action="">
{% csrf_token %}
<div class="row">
<div class="col-md-12 col-sm-12 mb-3 d-flex justify-content-start" id="action_form">
<input type="submit" name="action_type" value="EXPORT LEDGER" class="btn btn-sm btn-primary mr-2" />
<input type="submit" name="action_type" value="SEND LEDGER" class="btn btn-sm btn-primary" />

</div>
</div>

<div class="col-12 col-md-2 mb-3">
<label>Party Email</label>
<div class="form-check">
{% for j in ledger_party %}
<input class="form-check-input" type="checkbox" id="email_{{ j.id }}" name="emails" value="{{ j.id }}">
<label class="form-check-label" for="email_{{ j.id }}">
{{ j.corp_email }}
</label>
<br>
{% endfor %}
</div>
</div>


{% comment %} <div class="row">
<div class="col-md-2 col-sm-12 mb-3" id="action_form">
<button type="submit" name="action_type" value="EXPORT LEDGER" class="btn btn-sm btn-primary">EXPORT LEDGER</button><br><br>
<button type="submit" name="action_type" value="SEND LEDGER" class="ml-2 btn btn-sm btn-primary">SEND LEDGER</button>
</div>
</div> {% endcomment %}









<div class="row">
<div class="col-12 col-md-2 mb-3">
<label for="region">Choose Country</label>
<select name="region" id="region" required class="form-control">
{% if not selected_region %}
<option value="" selected hidden disabled>Choose Country</option>
{% endif %}
{% for i in company_regions %}
<option value="{{i.region}}" {% if i.region == selected_region or not selected_region %}selected{% endif %}>{{i.region}}</option>
{% endfor %}
</select>
</div>
<div class="col-12 col-md-2 mb-3">
<label for="from_date">From</label>
<input type="date" name="from_date" value="{{from_date|date:'Y-m-d'}}" required id="from_date" class="form-control form-control-sm" />
</div>
<div class="col-12 col-md-2 mb-3">
<label for="to_date">To</label>
<input type="date" name="to_date" required id="to_date" value="{{to_date|date:'Y-m-d'}}" class="form-control form-control-sm" />
</div>
<div class="col-12 col-md-2 mb-3">
<label for="choose_company">Choose Company</label>
<select name="choose_company" class="form-control form-control-sm" id="choose_company">
<option value="All" {% if choose_company == 'All' %}selected{% endif %}>All</option>
{% for data in global_companies %}
<option value="{{data.id}}" {% if choose_company == data.id %}selected{% endif %}>{{data.company_name}}</option>
{% endfor %}
</select>
</div>
<div class="col-12 col-md-2 mb-3">
<label for="choose_from">Choose From</label>
<select name="choose_from" required class="form-control form-control-sm" id="choose_from">
<option value="P" {% if choose_from == 'P' %}selected{% endif %}>Party</option>
<option value="V" {% if choose_from == 'V' %}selected{% endif %}>Vendor</option>
</select>
</div>
<div class="col-12 col-md-2 mb-3">
<label for="report_type">Choose Type</label>
<select name="report_type" required class="form-control form-control-sm" id="report_type">
<option value="B" {% if report_type == "B" %}selected{% endif %}>Both</option>
<option value="D" {% if report_type == "D" %}selected{% endif %}>Debtors</option>
<option value="C" {% if report_type == "C" %}selected{% endif %}>Creditors</option>
</select>
</div>
<div class="col-12 col-md-2 mb-3" id="vendor_div" {% if choose_from == "P" %}style="display:none;"{% endif %}>
<label for="choose_vendor">Choose Vendor</label>
<select name="choose_vendor" class="form-control form-control-sm" id="choose_vendor" {% if choose_from == "P" %}disabled{% endif %}>
<option value="" {% if not choose_vendor %}disabled selected{% endif %}>Choose Vendor</option>
{% for party in vendors %}
<option value="{{party.id}}" {% if choose_vendor == party.id %}selected{% endif %}>{{party}}</option>
{% endfor %}
</select>
</div>
<div class="col-12 col-md-2 mb-3" id="party_div" {% if choose_from == "V" %}style="display:none;"{% endif %}>
<label for="choose_party">Choose Party</label>
<select name="choose_party" class="form-control form-control-sm" id="choose_party" {% if choose_from == "V" %}disabled{% endif %}>
<option value="" {% if not choose_party %}disabled selected{% endif %}>Choose Party</option>
{% for party in parties %}
<option value="{{party.id}}"{% if choose_party == party.id %}selected{% endif %}>{{party}}</option>
{% endfor %}
</select>
<label for="corp_email">Party Email</label>
<select id="corp_email" name="corp_email" required>
<option value="">-----------</option>
{% for j in ledger_party %}
<option value="{{j.id}}">{{j.corp_email}}</option>
{% endfor %}
</select>
</div>


<div class="col-12 col-md-2 mb-3">
<label for="round_off">Round Off</label>
<select name="round_off" required class="form-control form-control-sm" id="round_off">
<option value="Y" {% if round_off == "Y" or not round_off %}selected{% endif %}>Yes</option>
<option value="N" {% if round_off == "N" %}selected{% endif %}>No</option>
</select>
</div>


<div class="col-12 col-md-2 mb-3">

<button type="submit" class="btn btn-sm btn-primary mt-4">Filter</button>
</div>
</div>


</form>

{% if report or opening_balance > 0 or opening_balance < 0 %}
<!-- <form action="{% url 'dashboard:generate_party_ledger_pdf' %}" method="post" target="_blank">
{% csrf_token %}
<input type="hidden" name="selected_region_pdf" value="{{selected_region}}" >
<input type="hidden" name="choose_company_pdf" value="{{choose_company}}" >
<input type="hidden" name="choose_from_pdf" value="{{choose_from}}" >
<input type="hidden" name="report_type_pdf" value="{{report_type}}" >
<input type="hidden" name="choose_vendor_pdf" value="{{choose_vendor}}" >
<input type="hidden" name="choose_party_pdf" value="{{choose_party}}" >
<div class="my-2">
<button type="submit" class="btn btn-sm btn-primary">Generate PDF Report</button>
</div>
</form> -->
{% endif %}

<div class="table-responsive">
<table class="display table table-primary table-bordered table-hover" id="party_ledger_table">
<thead>
<tr>
<th colspan="9" class="text-center" style="color:white!important;">{{company.legal_name}}</th>
</tr>
{% if selected_party or choose_vendor %}
<tr>
<th rowspan="1" colspan="9" class="text-center" style="color:white!important;">
{% if choose_from == "P" %}
({{selected_party.party_name}})
<br>
{{selected_party.party_address.first.corp_address_line1}}
<br>
{{selected_party.party_address.first.corp_address_line2}}
<br>
{{selected_party.party_address.first.corp_address_line3}}
<br>
{% else %}
({{choose_vendor.vendor_name}})
<br>
{{choose_vendor.vendor_name.address_line1}}
<br>
{{choose_vendor.vendor_name.address_line2}}
<br>
{{choose_vendor.vendor_name.address_line3}}
<br>
{% endif %}
</th>
</tr>
{% endif %}
<tr>
<th>Date</th>
<th></th>
<th>Particulars</th>
<th>Bill Wise Adjusted Ref.</th>
<th>Remarks</th>
<th>Invoice No.</th>
<th>Debit</th>
<th>Credit</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>
{% if opening_balance > 0 %}
TO
{% else %}
BY
{% endif %}
</td>
<td>OPENING BALANCE</td>
<td></td>
<td></td>
<td></td>
<td align="right" data-order="{{opening_balance|floatformat:round_off_value|floatformat:2}}">{{opening_balance|floatformat:round_off_value|floatformat:2}}</td>
<td align="right" data-order="{% if opening_balance < 0 %}{{opening_balance|mul:-1|floatformat:round_off_value|floatformat:2}}{% else %}0{% endif %}">{{opening_balance|floatformat:round_off_value|floatformat:2}}</td>
<td align="right" data-order="{% if opening_balance < 0 %}{{opening_balance|mul:-1|floatformat:round_off_value|floatformat:2}}{% else %}{{opening_balance|floatformat:round_off_value|floatformat:2}}{% endif %}">{{opening_balance|floatformat:round_off_value|floatformat:2}} {% if opening_balance < 0 %}Cr.{% else %}Dr.{% endif %}</td>
</tr>
{% if report %}
{% for data in report %}
{% if data.by_to %}
<tr style="{% if data.color %}background-color:{{data.color}};{% endif %}">
<td align="center">{{data.date|date:"Y-m-d"}}</td>
<td>{{data.by_to}}</td>
<td>{{data.particulars}}</td>
<td>&nbsp;</td>
<td>{{data.remarks}}</td>
<td>{{data.invoice_no}}</td>
<td align="right" data-order="{{data.dr_amount|floatformat:round_off_value|floatformat:2}}">{{data.dr_amount|floatformat:round_off_value|floatformat:2}}</td>
<td align="right" data-order="{{data.cr_amount|floatformat:round_off_value|floatformat:2}}">{{data.cr_amount|floatformat:round_off_value|floatformat:2}}</td>
<td align="right" data-order="{{data.current_balance|floatformat:round_off_value|floatformat:2}}">{{data.current_balance|floatformat:round_off_value|floatformat:2}} {{data.balance_in}}</td>
</tr>
{% else %}
<tr style="{% if data.color %}background-color:{{data.color}};{% endif %}">
<td align="center">&nbsp;</td>
<td>&nbsp;</td>
<td>{{data.particulars}}</td>
<td>&nbsp;</td>
<td>{{data.remarks}}</td>
<td>{{data.invoice_no}}</td>
<td align="right" data-order="0"></td>
<td align="right" data-order="0"></td>
<td align="right" data-order="0"></td>
</tr>
{% endif %}
{% if data.adjustments %}
{% for adjustment in data.adjustments %}
<tr style="background-color: {% if adjustment.invoice_no == 'Advance' %}#b4c6e7{% else %}#ffe699{% endif %};">
<td align="center" style="background-color: white!important; color:rgba(250, 240, 230, 0)!important;">{{data.date|date:"Y-m-d"}}</td>
<td></td>
<td>{{adjustment.particulars}}</td>
<td>{{adjustment.invoice_no}}</td>
<td></td>
<td align="right">
{% if adjustment.dr_amount > 0 %}
<span>{{adjustment.dr_amount|floatformat:round_off_value|floatformat:2}} Dr.</span>
{% endif %}
{% if adjustment.cr_amount > 0 %}
<span>{{adjustment.cr_amount|floatformat:round_off_value|floatformat:2}} Cr.</span>
{% endif %}
</td>
<td data-order="0"></td>
<td data-order="0"></td>
<td data-order="0"></td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
</tbody>
<tfoot>
<tr>
<td colspan="5"></td>
<td class="text-white">Total</td>
<td class="text-white text-right">0</td>
<td class="text-white text-right">0</td>
<td class="text-white text-right">
{% if debit_balance > 0 or credit_balance > 0 %}
{{debit_balance|sub:credit_balance|floatformat:round_off_value|floatformat:2|intcomma}}
{% endif %}
</td>
</tr>
</tfoot>
</table>

{% if debit_balance > 0 or credit_balance > 0 %}
<table class="table table-bordered">
<tr>
<th>Total Debit</th>
<td class="text-right" align="right">{{debit_balance|floatformat:round_off_value|floatformat:2|intcomma}}</td>
</tr>
<tr>
<th>Total Credit</th>
<td class="text-right" align="right">{{credit_balance|floatformat:round_off_value|floatformat:2|intcomma}}</td>
</tr>
<tr>
<th>Net Balance</th>
<td class="text-right" align="right"><strong>{{debit_balance|sub:credit_balance|floatformat:round_off_value|floatformat:2|intcomma}}</strong></td>
</tr>
</table>
{% endif %}
</div>
{% endblock %}


{% block js %}

<script>
$(document).ready(function () {

jQuery.fn.dataTable.Api.register( 'sum()', function ( ) {
return this.flatten().reduce( function ( a, b ) {
var x = parseFloat(a) ;
var y = parseFloat($(b).attr('data-order')) ;

return parseFloat((x+y)).toFixed(2)
}, 0 );
} );



let table = new DataTable('#party_ledger_table', {
// options
dom: 'BQlfrtip',
"ordering": false,
columnDefs: [
{ "type": "date", "targets": 0,"displayFormat": 'dddd D MMMM YYYY' },

],
lengthMenu: [
[10, 25, 50, -1],
[10, 25, 50, 'All'],
],
order: [[0, 'asc']],
buttons: [
{
extend: 'collection',
text: 'Export',

buttons: [
{ extend: 'copy', footer: true, header:true, },
{ extend: 'excel', footer: true, header:true,
exportOptions: {
format: {
header: function (data) {
return $('<div></div>')
.append(data)
.find('.tooltip')
.remove()
.end()
.text()
}
}
}
},

{ extend: 'csv', footer: true, header:true, },
{ extend: 'pdf', footer: true, header:true,orientation: 'landscape', modifier: {
page: 'all'
},
format: {
header: function ( data, columnIdx ) {
if(columnIdx==1){
return 'column_1_header';
}
else{
return data;
}
}
}},

]
}
],

select: {
style:'multiple'
},

drawCallback: function () {
var api = this.api();
$( api.table().column(6).footer() ).html(
api.column( 6, {page:'current'} ).nodes().sum()
);

$( api.table().column(7).footer() ).html(
api.column( 7, {page:'current'} ).nodes().sum()
);



}

});


document.querySelector('.dtsb-title').style.display = 'none'

})


const handlePartyOrVendor = () => {
var choose_from = document.getElementById('choose_from').value
var vendor_div = document.getElementById('vendor_div')
var party_div = document.getElementById('party_div')
var party_select = document.getElementById('choose_party')
var vendor_select = document.getElementById('choose_vendor')

if(choose_from == "P"){
party_div.required=true
party_div.style.display='block'
vendor_select.required=false
vendor_div.style.display='none'
party_select.required=true
}
if(choose_from == "V"){
vendor_select.required=true
vendor_div.style.display='block'

party_select.required=false
party_div.style.display='none'

}
}
document.getElementById('choose_from').addEventListener('change',handlePartyOrVendor)
document.getElementById('choose_from').addEventListener('keyup',handlePartyOrVendor)


$('#choose_party').select2({
placeholder: 'Choose Party',
templateSelection: function (data, container) {
// Add custom attributes to the <option> tag for the selected option
$(data.element).attr('data-custom-attribute', data.customValue);
return data.text;
}
})
$('#choose_vendor').select2({
placeholder: 'Choose Vendor',
templateSelection: function (data, container) {
// Add custom attributes to the <option> tag for the selected option
$(data.element).attr('data-custom-attribute', data.customValue);
return data.text;
}
})

table.on('select', function (e, dt, type, indexes) {
var rowData = table.rows(indexes).data().toArray();

indexes.map(index => {

var selected_fields = document.getElementById('selected_fields')

var indexValue = document.getElementById(`party_ledger_${index + 1}`).value
selected_ids.push(indexValue)

selected_fields.value = selected_ids


})

if (selected_ids.length > 0) {
var action_form = document.getElementById('action_form')
action_form.style.display = 'flex'
document.getElementById('list_selected').value = 1

}
})
.on('deselect', function (e, dt, type, indexes) {
var rowData = table.rows(indexes).data().toArray();

indexes.map(index => {

var selected_fields = document.getElementById('selected_fields')

var indexValue = document.getElementById(`party_ledger_${index + 1}`).value
selected_ids = selected_ids.filter(item => item !== indexValue)

selected_fields.value = selected_ids


})

if (selected_ids.length == 0) {
var action_form = document.getElementById('action_form')
action_form.style.display = 'none'
document.getElementById('list_selected').value = 0
}

})


document.addEventListener('DOMContentLoaded', function() {
var choosePartySelect = document.getElementById('choose_party');
var corpEmailSelect = document.getElementById('corp_email');

// Extract email data from HTML
var partyEmails = {};
var options = choosePartySelect.querySelectorAll('option');

options.forEach(function(option) {
var partyId = option.value;
var emails = option.getAttribute('data-emails');
if (emails) {
partyEmails[partyId] = JSON.parse(emails);
}
});

choosePartySelect.addEventListener('change', function() {
var partyId = this.value;

// Clear current options
corpEmailSelect.innerHTML = '';

if (partyId in partyEmails) {
var emails = partyEmails[partyId];
emails.forEach(function(email) {
var emailOption = document.createElement('option');
emailOption.value = email;
emailOption.text = email;
corpEmailSelect.add(emailOption);
});
}
});

// Trigger change event to populate initial state
choosePartySelect.dispatchEvent(new Event('change'));
});


</script>

{% comment %} // <script>
$(document).ready(function () {
// Initialize DataTable
let table = new DataTable('#party_ledger_table', {
dom: 'BQlfrtip',
ordering: false,
columnDefs: [
{ type: "date", targets: 0, displayFormat: 'dddd D MMMM YYYY' }
],
lengthMenu: [
[10, 25, 50, -1],
[10, 25, 50, 'All']
],
order: [[0, 'asc']],
buttons: [
{
extend: 'collection',
text: 'Export',
buttons: [
{ extend: 'copy', footer: true, header: true },
{
extend: 'excel',
footer: true,
header: true,
exportOptions: {
format: {
header: function (data) {
return $('<div></div>')
.append(data)
.find('.tooltip')
.remove()
.end()
.text();
}
}
}
},
{ extend: 'csv', footer: true, header: true },
{
extend: 'pdf',
footer: true,
header: true,
orientation: 'landscape',
modifier: { page: 'all' },
format: {
header: function (data, columnIdx) {
return columnIdx === 1 ? 'column_1_header' : data;
}
}
}
]
}
],
select: { style: 'multiple' },
drawCallback: function () {
var api = this.api();
$(api.table().column(6).footer()).html(
api.column(6, { page: 'current' }).data().sum()
);
$(api.table().column(7).footer()).html(
api.column(7, { page: 'current' }).data().sum()
);
}
});

// Hide default DataTable title
document.querySelector('.dtsb-title').style.display = 'none';

// Handle changes in 'choose_from' dropdown
const handlePartyOrVendor = () => {
var choose_from = document.getElementById('choose_from').value;
var vendor_div = document.getElementById('vendor_div');
var party_div = document.getElementById('party_div');
var party_select = document.getElementById('choose_party');
var vendor_select = document.getElementById('choose_vendor');

if (choose_from === "P") {
party_div.style.display = 'block';
vendor_div.style.display = 'none';
party_select.required = true;
vendor_select.required = false;
} else if (choose_from === "V") {
party_div.style.display = 'none';
vendor_div.style.display = 'block';
party_select.required = false;
vendor_select.required = true;
}
};

document.getElementById('choose_from').addEventListener('change', handlePartyOrVendor);
document.getElementById('choose_from').addEventListener('keyup', handlePartyOrVendor);

// Initialize Select2 for dropdowns
$('#choose_party').select2({
placeholder: 'Choose Party',
templateSelection: function (data) {
$(data.element).attr('data-custom-attribute', data.customValue);
return data.text;
}
});

$('#choose_vendor').select2({
placeholder: 'Choose Vendor',
templateSelection: function (data) {
$(data.element).attr('data-custom-attribute', data.customValue);
return data.text;
}
});

// Handle row selection and deselection
let selected_ids = [];

table.on('select', function (e, dt, type, indexes) {
indexes.forEach(index => {
let rowData = table.row(index).data();
let indexValue = rowData.id; // Assuming you have an ID in your data
if (!selected_ids.includes(indexValue)) {
selected_ids.push(indexValue);
}
});

document.getElementById('selected_fields').value = selected_ids.join(',');
document.getElementById('action_form').style.display = 'flex';
document.getElementById('list_selected').value = 1;
})
.on('deselect', function (e, dt, type, indexes) {
indexes.forEach(index => {
let rowData = table.row(index).data();
let indexValue = rowData.id; // Assuming you have an ID in your data
selected_ids = selected_ids.filter(item => item !== indexValue);
});

document.getElementById('selected_fields').value = selected_ids.join(',');
if (selected_ids.length === 0) {
document.getElementById('action_form').style.display = 'none';
document.getElementById('list_selected').value = 0;
}
});
});
</script> {% endcomment %}



{% endblock %}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.