Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

invoice date timestamp not work with VAT app #6

Closed
EngFarisAlsmawi opened this issue Dec 6, 2021 · 4 comments · Fixed by #8
Closed

invoice date timestamp not work with VAT app #6

EngFarisAlsmawi opened this issue Dec 6, 2021 · 4 comments · Fixed by #8
Labels
bug Something isn't working

Comments

@EngFarisAlsmawi
Copy link
Contributor

you have issue with invoice date timestamp
invoice date must be datetime as string not timestamp float..

datetime must be convert to string using this patch code:

invoice_date.isoformat()[:-6] + "Z",


Thank you for this package
Best regards,

@EngFarisAlsmawi EngFarisAlsmawi added the bug Something isn't working label Dec 6, 2021
@TheAwiteb
Copy link
Owner

Hello Faris Al samawi, I think that I did not understand your issue well, can you write the code in which you encounter the issue or a similar code that explains the issue, and for clarify as you see in variables the invoice_date is received as timestamp and it will be returned to you when you call it as datetime object, This is what I understood from document security requirements for electronic invoices on page No. 23 "Time stamp of the invoice (date and time) 3"

fatoora/fatoora/fatoora.py

Lines 105 to 112 in d9f8465

@property
def invoice_date(self) -> datetime:
return datetime.fromtimestamp(float(self.tags[3]))
@invoice_date.setter
@validate_arguments
def invoice_date(self, new_value: float) -> None:
self.tags[0x03] = "{:.4f}".format(float(new_value))

@EngFarisAlsmawi
Copy link
Contributor Author

EngFarisAlsmawi commented Dec 7, 2021

Hi @TheAwiteb
Ok, We are using your package in RAQ ERP Platform , so that thank you a lot for this package.

This is my code for create qrcode :


 fatoora_obj = Fatoora(
                seller_name=company_name,
                tax_number=vat,
                #convert to timestamp because a constructor arguments type is float.
                invoice_date=self.date_order.timestamp(), 
                total_amount=float(self.amount_total),
                tax_amount=float(self.amount_tax),
            )

when test my code using fatoora sdk command invoice date return as timestamp
every things work fine, but when use VAT app for mobile from google play to scan qrcode a result is empty.
result like this:

WhatsApp Image 2021-12-07 at 12 39 31 PM

My Fixed Patch:
1- change construct arguments such as:

  def __init__(
        self,
        seller_name: str,
        tax_number: str,
        invoice_date: str,
        total_amount: float,
        tax_amount: float,
        tags: TLV = TLV(),
    ):

2- Tax Proprity:

    @property
    def tax_number(self) -> str:
        return self.tags[2]

3- invoice date setter and getter:

   @property
   def invoice_date(self) -> str:
       return self.tags[3]
       # return datetime.fromtimestamp(float(self.tags[3]))

   @invoice_date.setter
   @validate_arguments
   def invoice_date(self, new_value: str) -> None:
       self.tags[0x03] = str(new_value) # "{:.4f}".format(float(new_value))

4- TestCase:

 fatoora_obj = Fatoora(
                seller_name="فارس السماوي",
                tax_number="12345678990003",
                invoice_date=self.date_order.isoformat(),
                total_amount=float(self.amount_total),
                tax_amount=float(self.amount_tax),
            )

5- Result with Vat App:

WhatsApp Image 2021-12-06 at 10 21 19 AM_2

I am clone your repo and implement changes.

@EngFarisAlsmawi
Copy link
Contributor Author

EngFarisAlsmawi commented Dec 7, 2021

Also for real application (with framework such as django) save qrcode for invoice order as image is inexpedient, ( this required handle and access to static and media files using django)

The best solution is render image as image data in fly and render it in django template:


        qr_code = qrcode.make(fatoora_obj.base64)
        stream = BytesIO()
        stream.seek(0)
        qr_code.save(stream)
        img_encoded = base64.b64encode(stream.getvalue()).decode("ascii")
        img_data = "data:image/png;base64," + img_encoded
        return img_data

django html template (TestCase):

<img src ="{{img_data}}" alt="qrcode"/>

It's work fine.
image

Best regards,

TheAwiteb added a commit that referenced this issue Dec 7, 2021
@TheAwiteb TheAwiteb mentioned this issue Dec 7, 2021
@TheAwiteb
Copy link
Owner

TheAwiteb commented Dec 7, 2021

@EngFarisAlsmawi
I hope you are working in PR and adding your project in 'Project use this package' will make me very happy

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants