205
//#1968249 build a non empty label, when memo/payee/category are empty
206
void da_archive_get_display_label(GString *tpltitle, Archive *item)
208
g_string_truncate(tpltitle, 0);
209
if(item->memo != NULL)
211
g_string_append(tpltitle, item->memo);
215
g_string_append(tpltitle, _("(no memo)") );
218
Payee *pay = da_pay_get(item->kpay);
222
g_string_append_c(tpltitle, ' ');
223
g_string_append(tpltitle, pay->name);
229
Category *cat = da_cat_get(item->kcat);
233
g_string_append(tpltitle, " / ");
234
g_string_append(tpltitle, cat->fullname);
206
242
void da_archive_consistency(Archive *item)
406
/* = = = = = = = = = = = = = = = = = = = = */
409
static void _sched_nextdate_weekend_adjust(GDate *tmpdate)
413
wday = g_date_get_weekday(tmpdate);
414
if( wday == G_DATE_SATURDAY )
415
g_date_add_days (tmpdate, 2);
417
if( wday == G_DATE_SUNDAY )
418
g_date_add_days (tmpdate, 1);
368
422
static guint32 _sched_date_get_next_post(GDate *tmpdate, Archive *arc, guint32 nextdate)
370
424
guint32 nextpostdate = nextdate;
394
448
//DB( g_print("out: %2d-%2d-%4d\n", g_date_get_day(tmpdate), g_date_get_month (tmpdate), g_date_get_year(tmpdate) ) );
450
//#1906953 add ignore weekend
451
if( arc->weekend == ARC_WEEKEND_SKIP )
453
_sched_nextdate_weekend_adjust(tmpdate);
397
456
/* get the final post date and free */
398
457
nextpostdate = g_date_get_julian(tmpdate);
463
//#1906953 add ignore weekend
464
void scheduled_nextdate_weekend_adjust(Archive *arc)
466
if( arc->weekend == ARC_WEEKEND_SKIP )
468
GDate *tmpdate = g_date_new_julian(arc->nextdate);
470
_sched_nextdate_weekend_adjust(tmpdate);
471
arc->nextdate = g_date_get_julian(tmpdate);
472
g_date_free(tmpdate);
404
477
gboolean scheduled_is_postable(Archive *arc)
533
606
DB( g_print("\n[scheduled] date_advance\n") );
535
DB( g_print(" arc: '%s'\n", arc->memo ) );
537
608
post_date = g_date_new();
538
609
g_date_set_julian(post_date, arc->nextdate);
539
610
// saved the current day number
542
613
arc->nextdate = _sched_date_get_next_post(post_date, arc, arc->nextdate);
544
DB( g_print(" raw next post date: %2d-%2d-%4d\n", g_date_get_day(post_date), g_date_get_month (post_date), g_date_get_year(post_date) ) );
615
DB( g_print(" raw next post date: %02d-%02d-%4d\n", g_date_get_day(post_date), g_date_get_month (post_date), g_date_get_year(post_date) ) );
546
617
//for day > 28 we might have a gap to compensate later
547
618
if( (arc->unit==AUTO_UNIT_MONTH) || (arc->unit==AUTO_UNIT_YEAR) )
631
701
* return the maximum date a scheduled txn can be posted to
633
guint32 scheduled_date_get_post_max(void)
703
guint32 scheduled_date_get_post_max(guint32 start, gint auto_smode, gint auto_nbdays, gint auto_weekday, gint nbmonth)
636
706
GDate *today, *maxdate;
638
DB( g_print("\n[scheduled] date_get_post_max\n") );
640
//add until xx of the each month (excluded)
641
if(GLOBALS->auto_smode == 0)
643
DB( g_print(" - max is %d of next month\n", GLOBALS->auto_weekday) );
645
today = g_date_new_julian(GLOBALS->today);
647
//we compute user xx weekday of next month
648
maxdate = g_date_new_julian(GLOBALS->today);
649
g_date_set_day(maxdate, GLOBALS->auto_weekday);
650
if(g_date_get_day (today) >= GLOBALS->auto_weekday)
651
g_date_add_months(maxdate, 1);
653
nbdays = g_date_days_between(today, maxdate);
655
g_date_free(maxdate);
658
//add xx days in advance the current date
661
nbdays = GLOBALS->auto_nbdays;
664
DB( hb_print_date(GLOBALS->today, "today") );
665
DB( g_print(" - %d nbdays\n", nbdays) );
666
DB( hb_print_date(GLOBALS->today + nbdays, "maxpostdate") );
668
return GLOBALS->today + nbdays;
712
//add until xx of the yy month (excluded)
713
//if(auto_smode == 0)
714
case ARC_POSTMODE_PAYOUT:
716
today = g_date_new_julian(start);
717
daysinmonth = g_date_get_days_in_month(g_date_get_month(today), g_date_get_year(today));
718
maxdate = g_date_new_julian(start + (daysinmonth - auto_weekday));
720
nxtmonth = ceil((gdouble)g_date_get_month(maxdate)/(gdouble)nbmonth)*(gdouble)nbmonth;
721
DB( g_print("nxtmonth: %f = ceil( %d / %d) / %d\n", nxtmonth, g_date_get_month(today), month, month) );
722
g_date_set_day(maxdate, auto_weekday);
723
g_date_set_month(maxdate, nxtmonth);
725
//if( today > g_date_get_julian(maxdate) )
726
// g_date_add_months(maxdate, month);
728
nbdays = g_date_days_between(today, maxdate);
730
g_date_free(maxdate);
735
//add xx days in advance the current date
736
//if(auto_smode == 1)
737
case ARC_POSTMODE_ADVANCE:
738
nbdays = auto_nbdays;
741
case ARC_POSTMODE_DUEDATE:
747
return start + nbdays;