@@ -232,7 +232,173 @@ def do_pyafipws_request_cae(self):
232
232
inv .l10n_latam_document_number , inv .l10n_latam_document_type_id .code
233
233
)
234
234
235
+ < << << << HEAD
235
236
if int (invoice_info ["ws_next_invoice_number" ]) != int (number_parts ["invoice_number" ]):
237
+ | | | | | | | parent of 8658e76 (temp )
238
+ mipyme_fce = int (doc_afip_code ) in [201 , 206 , 211 ]
239
+ # due date only for concept "services" and mipyme_fce
240
+ if int (concepto ) != 1 and int (doc_afip_code ) not in [202 , 203 , 207 , 208 , 212 , 213 ] or mipyme_fce :
241
+ fecha_venc_pago = inv .invoice_date_due or inv .invoice_date
242
+ if afip_ws != 'wsmtxca' :
243
+ fecha_venc_pago = fecha_venc_pago .strftime ('%Y%m%d' )
244
+ else :
245
+ fecha_venc_pago = None
246
+
247
+ # fecha de servicio solo si no es 1
248
+ if int (concepto ) != 1 :
249
+ fecha_serv_desde = inv .l10n_ar_afip_service_start
250
+ fecha_serv_hasta = inv .l10n_ar_afip_service_end
251
+ if afip_ws != 'wsmtxca' :
252
+ fecha_serv_desde = fecha_serv_desde .strftime ('%Y%m%d' )
253
+ fecha_serv_hasta = fecha_serv_hasta .strftime ('%Y%m%d' )
254
+ else :
255
+ fecha_serv_desde = fecha_serv_hasta = None
256
+
257
+ amounts = self ._l10n_ar_get_amounts ()
258
+ # invoice amount totals:
259
+ imp_total = str ("%.2f" % inv .amount_total )
260
+ # ImpTotConc es el iva no gravado
261
+ imp_tot_conc = str ("%.2f" % amounts ['vat_untaxed_base_amount' ])
262
+ # tal vez haya una mejor forma, la idea es que para facturas c
263
+ # no se pasa iva. Probamos hacer que vat_taxable_amount
264
+ # incorpore a los imp cod 0, pero en ese caso termina reportando
265
+ # iva y no lo queremos
266
+ if inv .l10n_latam_document_type_id .l10n_ar_letter == 'C' :
267
+ imp_neto = str ("%.2f" % inv .amount_untaxed )
268
+ else :
269
+ imp_neto = str ("%.2f" % amounts ['vat_taxable_amount' ])
270
+ imp_iva = str ("%.2f" % amounts ['vat_amount' ])
271
+ # se usaba para wsca..
272
+ # imp_subtotal = str("%.2f" % inv.amount_untaxed)
273
+ imp_trib = str ("%.2f" % amounts ['not_vat_taxes_amount' ])
274
+ imp_op_ex = str ("%.2f" % amounts ['vat_exempt_base_amount' ])
275
+ moneda_id = inv .currency_id .l10n_ar_afip_code
276
+ moneda_ctz = inv .l10n_ar_currency_rate
277
+
278
+ CbteAsoc = inv .get_related_invoices_data ()
279
+
280
+ # create the invoice internally in the helper
281
+ if afip_ws == 'wsfe' :
282
+ ws .CrearFactura (
283
+ concepto , tipo_doc , nro_doc , doc_afip_code , pos_number ,
284
+ cbt_desde , cbt_hasta , imp_total , imp_tot_conc , imp_neto ,
285
+ imp_iva ,
286
+ imp_trib , imp_op_ex , fecha_cbte , fecha_venc_pago ,
287
+ fecha_serv_desde , fecha_serv_hasta ,
288
+ moneda_id , moneda_ctz
289
+ )
290
+ # elif afip_ws == 'wsmtxca':
291
+ # obs_generales = inv.comment
292
+ # ws.CrearFactura(
293
+ # concepto, tipo_doc, nro_doc, doc_afip_code, pos_number,
294
+ # cbt_desde, cbt_hasta, imp_total, imp_tot_conc, imp_neto,
295
+ # imp_subtotal, # difference with wsfe
296
+ # imp_trib, imp_op_ex, fecha_cbte, fecha_venc_pago,
297
+ # fecha_serv_desde, fecha_serv_hasta,
298
+ # moneda_id, moneda_ctz,
299
+ # obs_generales # difference with wsfe
300
+ # )
301
+ elif afip_ws == 'wsfex' :
302
+ # # foreign trade data: export permit, country code, etc.:
303
+ if inv .invoice_incoterm_id :
304
+ incoterms = inv .invoice_incoterm_id .code
305
+ incoterms_ds = inv .invoice_incoterm_id .name
306
+ # máximo de 20 caracteres admite
307
+ incoterms_ds = incoterms_ds and incoterms_ds [:20 ]
308
+ else :
309
+ incoterms = incoterms_ds = None
310
+ # por lo que verificamos, se pide permiso existente solo
311
+ # si es tipo expo 1 y es factura (codigo 19), para todo el
312
+ # resto pasamos cadena vacia
313
+ if int (doc_afip_code ) == 19 and tipo_expo == 1 :
314
+ # TODO investigar si hay que pasar si ("S")
315
+ permiso_existente = "N"
316
+ else :
317
+ permiso_existente = ""
318
+ obs_generales = inv .narration
319
+ == == == =
320
+ mipyme_fce = int (doc_afip_code ) in [201 , 206 , 211 ]
321
+ # due date only for concept "services" and mipyme_fce
322
+ if int (concepto ) != 1 and int (doc_afip_code ) not in [202 , 203 , 207 , 208 , 212 , 213 ] or mipyme_fce :
323
+ fecha_venc_pago = inv .invoice_date_due or inv .invoice_date
324
+ if afip_ws != 'wsmtxca' :
325
+ fecha_venc_pago = fecha_venc_pago .strftime ('%Y%m%d' )
326
+ else :
327
+ fecha_venc_pago = None
328
+
329
+ # fecha de servicio solo si no es 1
330
+ if int (concepto ) != 1 :
331
+ fecha_serv_desde = inv .l10n_ar_afip_service_start
332
+ fecha_serv_hasta = inv .l10n_ar_afip_service_end
333
+ if afip_ws != 'wsmtxca' :
334
+ fecha_serv_desde = fecha_serv_desde .strftime ('%Y%m%d' )
335
+ fecha_serv_hasta = fecha_serv_hasta .strftime ('%Y%m%d' )
336
+ else :
337
+ fecha_serv_desde = fecha_serv_hasta = None
338
+
339
+ amounts = inv ._l10n_ar_get_amounts ()
340
+ # invoice amount totals:
341
+ imp_total = str ("%.2f" % inv .amount_total )
342
+ # ImpTotConc es el iva no gravado
343
+ imp_tot_conc = str ("%.2f" % amounts ['vat_untaxed_base_amount' ])
344
+ # tal vez haya una mejor forma, la idea es que para facturas c
345
+ # no se pasa iva. Probamos hacer que vat_taxable_amount
346
+ # incorpore a los imp cod 0, pero en ese caso termina reportando
347
+ # iva y no lo queremos
348
+ if inv .l10n_latam_document_type_id .l10n_ar_letter == 'C' :
349
+ imp_neto = str ("%.2f" % inv .amount_untaxed )
350
+ else :
351
+ imp_neto = str ("%.2f" % amounts ['vat_taxable_amount' ])
352
+ imp_iva = str ("%.2f" % amounts ['vat_amount' ])
353
+ # se usaba para wsca..
354
+ # imp_subtotal = str("%.2f" % inv.amount_untaxed)
355
+ imp_trib = str ("%.2f" % amounts ['not_vat_taxes_amount' ])
356
+ imp_op_ex = str ("%.2f" % amounts ['vat_exempt_base_amount' ])
357
+ moneda_id = inv .currency_id .l10n_ar_afip_code
358
+ moneda_ctz = inv .l10n_ar_currency_rate
359
+
360
+ CbteAsoc = inv .get_related_invoices_data ()
361
+
362
+ # create the invoice internally in the helper
363
+ if afip_ws == 'wsfe' :
364
+ ws .CrearFactura (
365
+ concepto , tipo_doc , nro_doc , doc_afip_code , pos_number ,
366
+ cbt_desde , cbt_hasta , imp_total , imp_tot_conc , imp_neto ,
367
+ imp_iva ,
368
+ imp_trib , imp_op_ex , fecha_cbte , fecha_venc_pago ,
369
+ fecha_serv_desde , fecha_serv_hasta ,
370
+ moneda_id , moneda_ctz
371
+ )
372
+ # elif afip_ws == 'wsmtxca':
373
+ # obs_generales = inv.comment
374
+ # ws.CrearFactura(
375
+ # concepto, tipo_doc, nro_doc, doc_afip_code, pos_number,
376
+ # cbt_desde, cbt_hasta, imp_total, imp_tot_conc, imp_neto,
377
+ # imp_subtotal, # difference with wsfe
378
+ # imp_trib, imp_op_ex, fecha_cbte, fecha_venc_pago,
379
+ # fecha_serv_desde, fecha_serv_hasta,
380
+ # moneda_id, moneda_ctz,
381
+ # obs_generales # difference with wsfe
382
+ # )
383
+ elif afip_ws == 'wsfex' :
384
+ # # foreign trade data: export permit, country code, etc.:
385
+ if inv .invoice_incoterm_id :
386
+ incoterms = inv .invoice_incoterm_id .code
387
+ incoterms_ds = inv .invoice_incoterm_id .name
388
+ # máximo de 20 caracteres admite
389
+ incoterms_ds = incoterms_ds and incoterms_ds [:20 ]
390
+ else :
391
+ incoterms = incoterms_ds = None
392
+ # por lo que verificamos, se pide permiso existente solo
393
+ # si es tipo expo 1 y es factura (codigo 19), para todo el
394
+ # resto pasamos cadena vacia
395
+ if int (doc_afip_code ) == 19 and tipo_expo == 1 :
396
+ # TODO investigar si hay que pasar si ("S")
397
+ permiso_existente = "N"
398
+ else :
399
+ permiso_existente = ""
400
+ obs_generales = inv .narration
401
+ > >> >> >> 8658e76 (temp )
236
402
237
403
raise UserError (_ ('Check document number. Next is %s' % invoice_info ["ws_next_invoice_number" ]))
238
404
0 commit comments