/*$Id:$*/
/*27.08.2021	27.08.2021	Белых А.И.	iceb_t_salorksl.cpp
Вывод сальдо 
*/
#include "buhl.h"

void iceb_t_salorksl(double dd, double kk, /*оборот за период*/
double ddn,double kkn, /*сальдо на начало периода*/
double debm,double krem, /*оборот за месяц*/
FILE *ff1,FILE *ffact)
{

double brr=dd+ddn;
double krr=kk+kkn;
if(ff1 != NULL)
  fprintf(ff1,"\
---------------------------------------------------------------------------------------\n");

if(debm != 0. || krem != 0.)
 {
  if(ff1 != NULL)
   {
    fprintf(ff1,"\
%*s:%12s",iceb_tu_kolbait(37,gettext("Оборот за месяц")),gettext("Оборот за месяц"),iceb_tu_prnbr(debm));

    fprintf(ff1," %12s\n",iceb_tu_prnbr(krem));
   }
  if(ffact != NULL)
   fprintf(ffact,"%*s %10.2f %10.2f| |\n",
   iceb_tu_kolbait(31,gettext("Оборот за месяц")),gettext("Оборот за месяц"),debm,krem);
 }

if(ff1 != NULL)
 {
  fprintf(ff1,"%*s:%12s",
  iceb_tu_kolbait(37,gettext("Оборот за период")),
  gettext("Оборот за период"),
  iceb_tu_prnbr(dd));

  fprintf(ff1," %12s\n",iceb_tu_prnbr(kk));
 }
 
if(ffact != NULL)
 fprintf(ffact,"%*s %10.2f %10.2f| |\n",
 iceb_tu_kolbait(31,gettext("Оборот за период")),gettext("Оборот за период"),dd,kk);

if(ff1 != NULL)
 {
  fprintf(ff1,"%*s:%12s",
  iceb_tu_kolbait(37,gettext("Сальдо раз-нутое")),
  gettext("Сальдо раз-нутое"),
  iceb_tu_prnbr(brr));
  fprintf(ff1," %12s\n",iceb_tu_prnbr(krr));
 }
 
if(ffact != NULL)
 fprintf(ffact,"%*s %10.2f %10.2f| |\n",
 iceb_tu_kolbait(31,gettext("Сальдо раз-нутое")),gettext("Сальдо раз-нутое"),brr,krr);

if(dd+ ddn >= kk+kkn)
 {
  brr=(dd+ddn)-(kk+kkn);

  if(ff1 != NULL)
    fprintf(ff1,"%*s:%12s\n",
    iceb_tu_kolbait(37,gettext("Сальдо свернутое")),gettext("Сальдо свернутое"),iceb_tu_prnbr(brr));

  if(ffact != NULL)
   fprintf(ffact,"%*s %10.2f %10s| |\n",
   iceb_tu_kolbait(31,gettext("Сальдо свернутое")),gettext("Сальдо свернутое"),brr," ");
 }
else
 {
  brr=(kk+kkn)-(dd+ddn);

  if(ff1 != NULL)
    fprintf(ff1,"%*s:%12s %12s\n",
    iceb_tu_kolbait(37,gettext("Сальдо свернутое")),gettext("Сальдо свернутое")," ",iceb_tu_prnbr(brr));


  if(ffact != NULL)
   fprintf(ffact,"%*s %10s %10.2f| |\n",
   iceb_tu_kolbait(31,gettext("Сальдо свернутое")),gettext("Сальдо свернутое")," ",brr);

 }
}
