|
6 | 6 | from datetime import datetime, date, time
|
7 | 7 | import os
|
8 | 8 |
|
9 |
| -# TODO |
10 |
| -# Crear Vat declaration |
11 |
| -# Se agrega al vat declararion el item de cada factura presente en esta declaracion |
12 |
| -# Al guardar se agrega a cada una de las facturas el Doctype, Doctype ID o title en el campo de child table Dynamic Link |
13 |
| -# A cada factura de las que tocamos, le agregamos al campo custom field, el titulo de ESTA VAT Declaration que creamos. |
| 9 | +@frappe.whitelist() |
| 10 | +def generate_vat_declaration(filters, report_data): |
| 11 | + try: |
| 12 | + # TODO |
| 13 | + # Crear Vat declaration |
| 14 | + # Opcion 1: |
| 15 | + # CON JS: si se desea obtener la data desde el report, se obtiene como argumento report.data |
| 16 | + # CON PY: De lo contrario, obviamos lo de arriba y solo trabajamos lo de abajo: |
| 17 | + # Necesitamos filters del report, pasados como argumentos desde el frappe.call: declared , company, month, year, [] |
| 18 | + # validaciones: |
| 19 | + if filters.declared == 'Not Declared': |
| 20 | + # Generate doctype for vat declaration |
| 21 | + this_dec = frappe.get_doc("VAT Declaration") |
| 22 | + this_dec.title = "Hello VAT Declaration" |
| 23 | + this_dec.company = filters.company |
| 24 | + this_dec.declaration_year = filters.year |
| 25 | + this_dec.declaration_month = filters.month |
| 26 | + this_dec.declaration_month = filters.month |
| 27 | + this_dec.posting_date = "2020-07-17" |
| 28 | + this_dec.declaration_items = [ |
| 29 | + { |
| 30 | + "link_doctype": "Purchase Invoice", |
| 31 | + "link_name": "ACC-PINV-2020-00001" |
| 32 | + } |
| 33 | + ] |
| 34 | + this_dec.save() |
| 35 | + # Se agrega al vat declararion el item de cada factura presente en esta declaracion |
| 36 | + # Al guardar se agrega a cada una de las facturas el Doctype, Doctype ID o title en el campo de child table Dynamic Link |
| 37 | + # A cada factura de las que tocamos, le agregamos al campo custom field, el titulo de ESTA VAT Declaration que creamos. |
| 38 | + else: |
| 39 | + # We somehow tried to send the declared or all non declared and declared documents. This is not allowed for our purpose! |
| 40 | + pass |
| 41 | + except: |
| 42 | + frappe.msgprint("algo salio mal") |
| 43 | + else: |
| 44 | + frappe.msgprint("estas fregado") |
| 45 | + |
0 commit comments