diff --git a/.DS_Store b/.DS_Store index 69570421..20d0eea9 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/inventory/__pycache__/forms.cpython-311.pyc b/inventory/__pycache__/forms.cpython-311.pyc index e0e01ab1..be128d82 100644 Binary files a/inventory/__pycache__/forms.cpython-311.pyc and b/inventory/__pycache__/forms.cpython-311.pyc differ diff --git a/inventory/__pycache__/mixins.cpython-311.pyc b/inventory/__pycache__/mixins.cpython-311.pyc index b69c4e09..96746b95 100644 Binary files a/inventory/__pycache__/mixins.cpython-311.pyc and b/inventory/__pycache__/mixins.cpython-311.pyc differ diff --git a/inventory/__pycache__/models.cpython-311.pyc b/inventory/__pycache__/models.cpython-311.pyc index e5c2e1e0..1882156b 100644 Binary files a/inventory/__pycache__/models.cpython-311.pyc and b/inventory/__pycache__/models.cpython-311.pyc differ diff --git a/inventory/__pycache__/urls.cpython-311.pyc b/inventory/__pycache__/urls.cpython-311.pyc index 56704c75..8c9d0f07 100644 Binary files a/inventory/__pycache__/urls.cpython-311.pyc and b/inventory/__pycache__/urls.cpython-311.pyc differ diff --git a/inventory/__pycache__/views.cpython-311.pyc b/inventory/__pycache__/views.cpython-311.pyc index 34005136..6efbd1f1 100644 Binary files a/inventory/__pycache__/views.cpython-311.pyc and b/inventory/__pycache__/views.cpython-311.pyc differ diff --git a/inventory/mixins.py b/inventory/mixins.py index 966a8666..520decc6 100644 --- a/inventory/mixins.py +++ b/inventory/mixins.py @@ -1,6 +1,6 @@ from django import forms from django.utils.translation import get_language - +from django.urls import reverse, reverse_lazy class AddClassMixin: """ @@ -40,4 +40,27 @@ class LocalizedNameMixin: # form.save() # return super().form_valid(form) # else: -# return form.errors \ No newline at end of file +# return form.errors +class BaseDateNavigationUrlMixIn: + BASE_DATE_URL_KWARGS = ( + 'entity_slug', + 'unit_slug', + 'ledger_pk', + 'account_pk', + 'coa_slug' + ) + + def get_context_data(self, **kwargs): + context = super(BaseDateNavigationUrlMixIn, self).get_context_data(**kwargs) + self.get_base_date_nav_url(context) + return context + + def get_base_date_nav_url(self, context, **kwargs): + view_name = context['view'].request.resolver_match.url_name + view_name_base = '-'.join(view_name.split('-')[:2]) + context['date_navigation_url'] = reverse( + view_name_base, + kwargs={ + k: v for k, v in self.kwargs.items() if + k in self.BASE_DATE_URL_KWARGS + }) \ No newline at end of file diff --git a/inventory/templatetags/__pycache__/custom_filters.cpython-311.pyc b/inventory/templatetags/__pycache__/custom_filters.cpython-311.pyc index 3b76d055..225454e2 100644 Binary files a/inventory/templatetags/__pycache__/custom_filters.cpython-311.pyc and b/inventory/templatetags/__pycache__/custom_filters.cpython-311.pyc differ diff --git a/inventory/templatetags/custom_filters.py b/inventory/templatetags/custom_filters.py index aa4d1ea6..7149e67f 100644 --- a/inventory/templatetags/custom_filters.py +++ b/inventory/templatetags/custom_filters.py @@ -325,4 +325,25 @@ def number_to_words_arabic(number): # if language == 'ar': # return number_to_words_arabic(number) # else: -# return number_to_words_english(number) \ No newline at end of file +# return number_to_words_english(number) + +@register.inclusion_tag('components/date_picker.html', takes_context=True) +def date_picker(context, nav_url=None, date_picker_id=None): + try: + entity_slug = context['view'].kwargs.get('entity_slug') + except KeyError: + entity_slug = context['entity_slug'] + + if not date_picker_id: + date_picker_id = f'djl-datepicker-{randint(10000, 99999)}' + + if 'date_picker_ids' not in context: + context['date_picker_ids'] = list() + context['date_picker_ids'].append(date_picker_id) + + date_navigation_url = nav_url if nav_url else context.get('date_navigation_url') + return { + 'entity_slug': entity_slug, + 'date_picker_id': date_picker_id, + 'date_navigation_url': date_navigation_url + } \ No newline at end of file diff --git a/inventory/views.py b/inventory/views.py index 537b001d..1f70ce10 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -439,21 +439,23 @@ class AjaxHandlerView(LoginRequiredMixin, View): model_id = request.GET.get("model_id") year = request.GET.get("year") - if not model_id or not year: - return JsonResponse( - {"error": "Missing required parameters: model_id or year"}, status=400 - ) + model_id = int(model_id) + year = int(year) + + query = Q(id_car_model=model_id) & ( + Q(year_begin__lte=year, year_end__gte=year) | + Q(year_end__isnull=True) | + Q(year_begin__isnull=True) + ) try: - model_id = int(model_id) - year = int(year) - except ValueError: - return JsonResponse({"error": "Invalid year format"}, status=400) - - series = models.CarSerie.objects.filter( - id_car_model=model_id,year_begin__lte = year, year_end__gte = year - ).values("id_car_serie", "name", "arabic_name", "generation_name") - # - + series = models.CarSerie.objects.filter(query).values( + "id_car_serie", + "name", + "arabic_name", + "generation_name" + ) + except Exception as e: + return JsonResponse({"error": "Server error occurred"}, status=500) return JsonResponse(list(series), safe=False) def get_trims(self, request): diff --git a/locale/ar/LC_MESSAGES/django.mo b/locale/ar/LC_MESSAGES/django.mo index d3d5e518..acf0f596 100644 Binary files a/locale/ar/LC_MESSAGES/django.mo and b/locale/ar/LC_MESSAGES/django.mo differ diff --git a/locale/ar/LC_MESSAGES/django.po b/locale/ar/LC_MESSAGES/django.po index 5260194c..c55972b5 100644 --- a/locale/ar/LC_MESSAGES/django.po +++ b/locale/ar/LC_MESSAGES/django.po @@ -7470,27 +7470,18 @@ msgid "Not set." msgstr "غير محدد" #: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:84 -#, fuzzy, python-format -#| msgid "%(count)d day" -#| msgid_plural "%(count)d days" msgid "%(count)d day" msgid_plural "%(count)d days" msgstr[0] "%(num)d يوم" msgstr[1] "%(num)d أيام" #: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:88 -#, fuzzy, python-format -#| msgid "%(count)d hour" -#| msgid_plural "%(count)d hours" msgid "%(count)d hour" msgid_plural "%(count)d hours" msgstr[0] "%(num)d ساعة" msgstr[1] "%(num)d ساعات" #: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:92 -#, fuzzy, python-format -#| msgid "%(count)d minute" -#| msgid_plural "%(count)d minutes" msgid "%(count)d minute" msgid_plural "%(count)d minutes" msgstr[0] "%(num)d دقيقة" @@ -8921,62 +8912,62 @@ msgstr "ديسمبر" #: venv/lib/python3.11/site-packages/django/utils/dates.py:53 msgctxt "abbrev. month" msgid "Jan." -msgstr "يناير." +msgstr "يناير" #: venv/lib/python3.11/site-packages/django/utils/dates.py:54 msgctxt "abbrev. month" msgid "Feb." -msgstr "فبراير." +msgstr "فبراير" #: venv/lib/python3.11/site-packages/django/utils/dates.py:55 msgctxt "abbrev. month" msgid "March" -msgstr "مارس." +msgstr "مارس" #: venv/lib/python3.11/site-packages/django/utils/dates.py:56 msgctxt "abbrev. month" msgid "April" -msgstr "أبريل." +msgstr "أبريل" #: venv/lib/python3.11/site-packages/django/utils/dates.py:57 msgctxt "abbrev. month" msgid "May" -msgstr "مايو." +msgstr "مايو" #: venv/lib/python3.11/site-packages/django/utils/dates.py:58 msgctxt "abbrev. month" msgid "June" -msgstr "يونيو." +msgstr "يونيو" #: venv/lib/python3.11/site-packages/django/utils/dates.py:59 msgctxt "abbrev. month" msgid "July" -msgstr "يوليو." +msgstr "يوليو" #: venv/lib/python3.11/site-packages/django/utils/dates.py:60 msgctxt "abbrev. month" msgid "Aug." -msgstr "أغسطس." +msgstr "أغسطس" #: venv/lib/python3.11/site-packages/django/utils/dates.py:61 msgctxt "abbrev. month" msgid "Sept." -msgstr "سبتمبر." +msgstr "سبتمبر" #: venv/lib/python3.11/site-packages/django/utils/dates.py:62 msgctxt "abbrev. month" msgid "Oct." -msgstr "أكتوبر." +msgstr "أكتوبر" #: venv/lib/python3.11/site-packages/django/utils/dates.py:63 msgctxt "abbrev. month" msgid "Nov." -msgstr "نوفمبر." +msgstr "نوفمبر" #: venv/lib/python3.11/site-packages/django/utils/dates.py:64 msgctxt "abbrev. month" msgid "Dec." -msgstr "ديسمبر." +msgstr "ديسمبر" #: venv/lib/python3.11/site-packages/django/utils/dates.py:67 msgctxt "alt. month" diff --git a/static/images/car_make/Lincoln.png b/static/images/car_make/Lincoln.png new file mode 100644 index 00000000..a8b95d17 Binary files /dev/null and b/static/images/car_make/Lincoln.png differ diff --git a/templates/base.html b/templates/base.html index 8c3dc33b..10f1ca12 100644 --- a/templates/base.html +++ b/templates/base.html @@ -106,7 +106,7 @@ function notify(tag,msg){ {% block customJS %} - + diff --git a/templates/ledger/reports/components/date_picker.html b/templates/ledger/reports/components/date_picker.html new file mode 100644 index 00000000..5dc57944 --- /dev/null +++ b/templates/ledger/reports/components/date_picker.html @@ -0,0 +1,7 @@ +{% load i18n %} + +{% if date_navigation_url %} + +{% endif %} + diff --git a/templates/ledger/reports/components/period_navigator.html b/templates/ledger/reports/components/period_navigator.html index ae69e2d2..2a026318 100644 --- a/templates/ledger/reports/components/period_navigator.html +++ b/templates/ledger/reports/components/period_navigator.html @@ -1,4 +1,5 @@ {% load django_ledger %} + {% load i18n %}
@@ -17,15 +18,15 @@

- Year: + {{ _("Year") }}: - - + + {{ previous_year }} {{ year }} {{ next_year }} - - + +

diff --git a/templates/ledger/reports/income_statement.html b/templates/ledger/reports/income_statement.html index 58ff69ff..8dc98581 100644 --- a/templates/ledger/reports/income_statement.html +++ b/templates/ledger/reports/income_statement.html @@ -32,7 +32,7 @@

{% if quarter %}{{ year }} | Q{{ quarter }} {% elif month %}{{ start_date | date:'F, Y' }} - {% else %}Fiscal Year {{ year }} + {% else %}{{ _("Fiscal Year")}} {{ year }} {% endif %}

{{ from_date | date:'m/d/Y' }} - {{ to_date | date:'m/d/Y' }}