Nama ERP DocsNama ERP Docs
Home
Guides
Examples
GitHub
Home
Guides
Examples
GitHub
  • Home

    • Guides

      • بعض المعلومات عن استعمال هذا الموقع
      • Utility Links
      • System Minimum Requirements
      • Reports Guide (Jasper Reports)
      • Keyboard Shortcuts
      • Layout Names:
      • Field Values Calculator
      • Importing Data from Excel or Queries
      • Tempo Language Manual
      • Sending Invoices and Documents to Customers
      • SMS and WhatsApp Configuration in Nama ERP
      • Field Filter with Criteria
      • تعديل الترجمات في نظام نما
      • Criteria Based Validation
      • Attendance Machine Formula Guide
      • Email By Parameterized Reports In Task Scheduler
      • Nama Properties
      • Customer Reward Points (Loyalty Points)
      • دليل استعمال النقاط الفنية في نقاط البيع
      • ORACLE JDBC Integration Connection in context.xml for integration purposes
    • Examples

      • أمثلة لمسارات كيان
    • Reprocessing Transactions

      • Reprocessing Quantity, Cost, and Stock Ages
      • Accounting Utilities - Ledger and Debt Ages Reprocessing
      • Queries to Check for (and Fix) Cost And Qty Problems
      • Inventory Related Utility Queries
      • Manufacturing Utilities
      • Fixed Assets Module Utilities
      • Real Estate Utilities
      • Database Related Operations
      • General Purpose Utility Queries
      • Replication Utilities
    • Frequently Asked Questions

      • أسئلة عامة
      • أسئلة شائعة عن مسارات الكيان
      • أسئلة في موديول التوزيع والمخازن والمبيعات والمشتريات
      • أسئلة شائعة في موديول الرواتب والموارد البشرية
      • أسئلة شائعة عن تصميم التقارير
      • أسئلة شائعة حول أداة إنشاء التقارير
      • أسئلة شائعة عن الموافقات
      • أسئلة شائعة حول فلترة الحقول

أسئلة شائعة حول أداة إنشاء التقارير

كيف يمكنني إنشاء تقرير يظهر رصيد حساب معين لكل فرع بفلتر تاريخ، بالإضافة إلى إجمالي المبيعات لنفس الفرع مع فلتر تاريخ مختلف؟

السيناريو

  • أنشأت تقريرًا باستخدام أداة إنشاء التقارير على جدول LedgerTransLine.
  • أضفت عمودًا للفرع، وعمودًا آخر يحتوي على معادلة لحساب الرصيد (المدين - الدائن).
  • أنشأت مصدر بيانات خارجي (DataSource1) لجلب إجمالي المبيعات لنفس الفرع.
  • أضفت فلتر على حقل valueDate في الجدول الرئيسي لفلترة الأرصدة.
  • أنشأت مصدر البيانات للمبيعات من جدول SalesInvoice، وربطت الجدولين بواسطة حقل branch.

المشكلة

أرغب في استخدام فلتر تواريخ مستقل لبيانات المبيعات دون التأثير على فلتر تواريخ الأرصدة.


الحل

لتحقيق ذلك، يجب تنفيذ الخطوات التالية:

  1. إضافة مدخل مخصص للتاريخ باسم salesValueDate:

    • نوعه: Custom
    • نوع البيانات: Date
  2. ربط هذا المدخل مع مصدر البيانات الأول (الخاص بالمبيعات) في سطر الفلاتر باستخدام حقل valueDate.


استيراد إعدادات التقرير

Details
{
  "tableType": "DetailLine",
  "mainTable": "LedgerTransLine",
  "useDataSource1AsSubQuery": true,
  "fields": [
    { "fieldId": "branch" },
    {
      "fieldId": "credit.value.amount",
      "hidden": true,
      "hasTotalInSummary": true,
      "sqlAggregationType": "Sum"
    },
    {
      "fieldId": "debit.value.amount",
      "hidden": true,
      "hasTotalInSummary": true,
      "sqlAggregationType": "Sum"
    },
    {
      "type": "Normal",
      "arabicTitle": "الرصيد",
      "customJasperExpression": {
        "Details": {
          "expression": "@{debit.value.amount}@-@{credit.value.amount}@"
        }
      },
      "customPattern": "###,###.##",
      "hasTotalInSummary": true,
      "sqlAggregationType": "Sum"
    },
    {
      "fieldId": "$dataSource1.money.netValue",
      "arabicTitle": "المبيعات"
    }
  ],
  "parameters": [
    {
      "fieldId": "branch",
      "filterType": "Between",
      "showInsideReport": true,
      "generatedParameterName": "FromBranch,ToBranch"
    },
    {
      "fieldId": "valueDate",
      "filterType": "Between",
      "showInsideReport": true,
      "generatedParameterName": "FromValueDate,ToValueDate",
      "defaultValue": "$today()",
      "defaultValueWithBetween": "$today()"
    },
    {
      "fieldId": "salesValueDate",
      "arabicTitle": "من تاريخ مبيعات",
      "filterType": "Between",
      "parameterType": "Custom",
      "showInsideReport": true,
      "generatedParameterName": "FromSalesValueDate,ToSalesValueDate",
      "defaultValue": "$today()",
      "defaultValueWithBetween": "$today()",
      "patternType": "Date",
      "paramType": "Date"
    }
  ],
  "dataSource1LinkingLines": [
    {
      "dataSourceField": "branch",
      "operator": "Equals",
      "reportingWizardField": "branch"
    }
  ],
  "dataSource1FilterLines": [
    {
      "dataSourceField": "valueDate",
      "operator": "Between",
      "reportingWizardParameter": "FromSalesValueDate,ToSalesValueDate"
    }
  ]
}

استيراد مصدر البيانات

Details
{
  "mainTable": "SalesInvoice",
  "allowAllMainTableFieldsForUse": true,
  "fields": [
    {
      "fieldId": "money.netValue",
      "sqlAggregationType": "Sum"
    }
  ]
}

Summary in English

Question: How can I create a report that shows the balance of a specific account for each branch filtered by a date range, and at the same time show the total sales for each branch filtered by a different date range?

Answer:

  • Create a report based on the LedgerTransLine table to calculate balance per branch.

  • Add a custom SQL expression to compute balance (debit - credit).

  • Add an external data source (DataSource1) based on SalesInvoice, linked by branch, to retrieve sales totals.

  • Add two separate date filters:

    • One for the main table (valueDate) for account balances.
    • Another for the external data source, using a custom date parameter named salesValueDate.
  • Link salesValueDate to the valueDate field in the external data source.

This setup allows independent filtering of account balances and sales totals per branch.

اختيار سعر الصنف من قائمة الأسعار حسب تاريخ التقرير

المشكلة

إذا كان هناك أكثر من قائمة أسعار تحتوي على نفس الصنف، وتواريخها تتقاطع جزئيًا، مثلًا:

  • قائمة أسعار من 1 إلى نهاية الشهر
  • قائمة أخرى تبدأ من 15 إلى نهاية الشهر

فإنه يجب على التقرير اختيار السعر الصحيح بناءً على تاريخ تشغيل التقرير أو تاريخ يحدده المستخدم.

الحل

استخدم الدالة NamaRep.priceCalculator() داخل التعبير المخصص (Custom Jasper Expression) لجلب سعر الصنف في التاريخ الصحيح.

مثال 1: جلب سعر الصنف في تاريخ تشغيل التقرير

NamaRep.priceCalculator().item(@{details.item.item.id}@).unitPriceOnly().unitPrice()

هذا المثال يُرجع سعر الصنف في تاريخ تشغيل التقرير.

مثال 2: جلب سعر الصنف بناءً على تاريخ مدخل (مثلًا: FromDate)

NamaRep.priceCalculator().item(@{details.item.item.id}@).date($P{FromDate}).unitPriceOnly().unitPrice()

يستخدم هذا المثال التاريخ المحدد من المستخدم لحساب السعر.

ملاحظات

  • تأكد من أن الشركة (Legal Entity) مأخوذة من سياق التقرير تلقائيًا، أو يمكنك تحديدها يدويًا باستخدام:

    .legalEntity($P{CompanyId})
    
  • يمكنك أيضًا تحديد العميل، الكمية، الوحدة، أو أي عامل آخر يؤثر في السعر إذا كانت القوائم تحتوي على شروط إضافية.

  • الدالة تعيد null إذا لم يتم العثور على سعر مطابق.

Edit On github
Last Updated:: 6/3/25, 9:35 PM
Prev
أسئلة شائعة عن تصميم التقارير
Next
أسئلة شائعة عن الموافقات