You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
final pdf = pw.Document();
final textGray = PdfColor.fromHex('#57636C');
final dividerColor = PdfColor.fromHex('#EAECF0');
final greenContainer = PdfColor.fromHex('#7C9587');
final arabi = await PdfGoogleFonts.tajawalBold();
Future generateQrCodeImage(String qrData) async {
final qrCode = QrPainter(
data: qrData,
version: QrVersions.auto,
gapless: true,
);
final picData = await qrCode.toImageData(120);
return picData!.buffer.asUint8List();
}
pw.Widget buildTextEn(String text, PdfColor color, double fontSize,
{pw.Font? font, pw.FontWeight fontWeight = pw.FontWeight.normal}) {
return pw.Text(
text,
style: pw.TextStyle(
color: color,
fontSize: fontSize,
fontWeight: fontWeight,
font: font,
),
);
}
pw.Widget buildTextAr(String text, PdfColor color, double fontSize,
{pw.Font? font,
required List<pw.Font> fontFallback,
pw.FontWeight fontWeight = pw.FontWeight.normal}) {
return pw.Text(
text,
textDirection: pw.TextDirection.rtl,
style: pw.TextStyle(
color: color,
fontSize: fontSize,
fontWeight: fontWeight,
fontFallback: fontFallback,
font: font,
),
);
}
pw.Widget buildSectionHeader(String englishText, String arabicText,
PdfColor backgroundColor, pw.Font arabicFont) {
return pw.Container(
decoration: pw.BoxDecoration(
color: backgroundColor,
borderRadius: pw.BorderRadius.circular(5.0),
),
child: pw.Padding(
padding: pw.EdgeInsets.fromLTRB(10.0, 2.0, 10.0, 2.0),
child: pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
children: [
buildTextEn(englishText, PdfColors.white, 14.0,
fontWeight: pw.FontWeight.bold),
buildTextAr(arabicText, PdfColors.white, 14.0,
fontFallback: [arabicFont], fontWeight: pw.FontWeight.bold),
],
),
),
);
}
Future taxInvoicePdf(
String qrData,
double vatAmount,
double appAmount,
InvoiceRecord invoiceDoc,
CustomerCompaniesRecord customerCompanyDoc,
) async {
final qrImageData = await generateQrCodeImage(qrData);
final pdf = pw.Document();
final textGray = PdfColor.fromHex('#57636C');
final dividerColor = PdfColor.fromHex('#EAECF0');
final greenContainer = PdfColor.fromHex('#7C9587');
final arabi = await PdfGoogleFonts.tajawalBold();
pdf.addPage(
pw.Page(
build: (pw.Context context) {
return pw.Column(
mainAxisSize: pw.MainAxisSize.max,
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [
buildTextEn('Invoice ID: ${invoiceDoc.invoiceId}', textGray, 14.0),
pw.Padding(
padding: pw.EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 5.0),
child: buildTextEn(
'Date: ${DateFormat('yyyy-MM-dd').format(invoiceDoc.invoiceCreationDate!)}',
textGray,
14.0),
),
);
final bytes = await pdf.save();
return FFUploadedFile(
name: "taxInvoice_${invoiceDoc.invoiceId}", bytes: bytes);
}
pw.Widget buildSellerDetailsSection(pw.Font arabicFont) {
final textGray = PdfColor.fromHex('#57636C');
final dividerColor = PdfColor.fromHex('#EAECF0');
return pw.Padding(
padding: pw.EdgeInsetsDirectional.fromSTEB(5.0, 5.0, 5.0, 0.0),
child: pw.Column(
mainAxisSize: pw.MainAxisSize.max,
children: [
buildDetailsRow('Company Name :', ': اسم الشركة', arabicFont),
buildTextEn(
"Al-Rabt al-'Alami For Advertising Services", textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow('Address :', ': العنوان', arabicFont),
buildTextEn('King Abdullah Bin Abdulaziz Rd', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow('VAT Number :', ': الرقم الضريبي', arabicFont),
buildTextEn('311274337100003', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow('Commercial Number :', ': رقم السجل التجاري', arabicFont),
buildTextEn('1010797959', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
],
),
);
}
pw.Widget buildBuyerDetailsSection(
pw.Font arabicFont, CustomerCompaniesRecord customerCompany) {
final textGray = PdfColor.fromHex('#57636C');
final dividerColor = PdfColor.fromHex('#EAECF0');
return pw.Padding(
padding: pw.EdgeInsetsDirectional.fromSTEB(5.0, 5.0, 5.0, 0.0),
child: pw.Column(
mainAxisSize: pw.MainAxisSize.max,
children: [
buildDetailsRow('Name :', ': اسم', arabicFont),
buildTextEn('${customerCompany.companyName}', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow('Address :', ': عنوان', arabicFont),
buildTextEn('${customerCompany.countryName}', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow('VAT Number :', ': الرقم الضريبي', arabicFont),
buildTextEn('${customerCompany.vATNumber}', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow('Commercial Number :', ': رقم السجل التجاري', arabicFont),
buildTextEn('${customerCompany.commercialNumber}', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
],
),
);
}
pw.Widget buildProductTableDetailsSection(pw.Font arabicFont, double price) {
final headerColor = PdfColor.fromHex('#F3F3F3');
final textGray = PdfColor.fromHex('#57636C');
final dividerColor = PdfColor.fromHex('#DBDBDB');
return pw.ClipRRect(
horizontalRadius: 5.0,
verticalRadius: 5.0,
child: pw.Table(
border:
pw.TableBorder.symmetric(inside: pw.BorderSide(color: dividerColor)),
children: [
pw.TableRow(
decoration: pw.BoxDecoration(
color: headerColor,
),
children: [
pw.Container(
padding: pw.EdgeInsets.all(5.0),
alignment: pw.Alignment.center,
child: pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.start,
children: [
buildTextEn("Product ", PdfColors.black, 10.0,
fontWeight: pw.FontWeight.bold),
buildTextAr("منتج", PdfColors.black, 10.0,
fontFallback: [arabicFont],
fontWeight: pw.FontWeight.bold),
],
),
),
pw.Container(
padding: pw.EdgeInsets.all(5.0),
alignment: pw.Alignment.center,
child: pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.start,
children: [
buildTextEn("Price ", PdfColors.black, 10.0,
fontWeight: pw.FontWeight.bold),
buildTextAr("سعر", PdfColors.black, 10.0,
fontFallback: [arabicFont],
fontWeight: pw.FontWeight.bold),
],
),
),
pw.Container(
padding: pw.EdgeInsets.all(5.0),
alignment: pw.Alignment.center,
child: pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.start,
children: [
buildTextEn("Quantity ", PdfColors.black, 10.0,
fontWeight: pw.FontWeight.bold),
buildTextAr("كمية", PdfColors.black, 10.0,
fontFallback: [arabicFont],
fontWeight: pw.FontWeight.bold),
],
),
),
],
),
pw.TableRow(
decoration: pw.BoxDecoration(
color: headerColor,
),
children: [
pw.Padding(
padding: pw.EdgeInsets.all(5.0),
child: buildTextEn("Advertisement commission", textGray, 10.0),
),
pw.Padding(
padding: pw.EdgeInsets.all(5.0),
child: buildTextEn('$price', textGray, 10.0),
),
pw.Padding(
padding: pw.EdgeInsets.all(5.0),
child: buildTextEn("1", textGray, 10.0),
),
],
),
],
),
);
}
pw.Widget buildProductDetailsSection(
pw.Font arabicFont, InvoiceRecord invoice, double vat, double gt) {
final textGray = PdfColor.fromHex('#57636C');
final dividerColor = PdfColor.fromHex('#EAECF0');
return pw.Padding(
padding: pw.EdgeInsetsDirectional.fromSTEB(5.0, 5.0, 5.0, 0.0),
child: pw.Column(
mainAxisSize: pw.MainAxisSize.max,
children: [
buildDetailsRow(
'VAT percentage :', ': نسبة ضريبة القيمة المضافة', arabicFont),
buildTextEn('${invoice.invoiceVat2}%', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow(
'VAT value :', ': قيمة ضريبة القيمة المضافة', arabicFont),
buildTextEn('$vat', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow('Total without VAT :',
': الإجمالي بدون ضريبة القيمة المضافة', arabicFont),
buildTextEn('$gt', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
buildDetailsRow(
'Total with VAT :', ': الإجمالي مع ضريبة القيمة المضافة', arabicFont),
buildTextEn('${gt + vat}', textGray, 10.0),
pw.Divider(height: 1.0, thickness: 2.0, color: dividerColor),
],
),
);
}
pw.Widget buildDetailsRow(
String englishText, String arabicText, pw.Font arabicFont) {
englishText = englishText.replaceAll(":", '');
arabicText = arabicText.replaceAll(":", '');
return pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
children: [
buildTextEn(englishText, PdfColors.black, 10.0,
fontWeight: pw.FontWeight.bold),
buildTextAr(arabicText, PdfColors.black, 10.0,
fontFallback: [arabicFont], fontWeight: pw.FontWeight.bold),
],
);
}
The text was updated successfully, but these errors were encountered: