⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sale1.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
	if(Void_flag==1)
	{
		id_order=TS_VD_PLU;
   }
   if(RM_flag==1)
	{
		id_order=TS_RM_PLU;
   }
   if((dept[plink-1].per_rate != 0) && (sysflag->Auto_Per_Use_Flag == 1) &&( id_order==TS_PLU ))
#else
   if((dept[plink-1].per_rate != 0) && (sysflag->Auto_Per_Use_Flag == 1) && (transbuff[TnsBf_Len-1].ID == TS_PLU))
#endif
   			/* Not support in the VOID and RM function */
   {
   	#ifdef	REST_PLU_FUNC
	Do_Auto_Per(PLU, store_plu_index);		
#else
	Do_Auto_Per(PLU, Idx);
#endif
   }
   #endif /* End AUTO_PER */

	#ifdef	REST_PLU_FUNC
   Void_flag=0;
  	RM_flag = 0;
	Mul_flag = 0;
	#endif

   if(!NewTrans)
   {
      NewTrans=1;
      pflag=dept[plink-1].pflag;
      if((pflag&0x10)					/* single item */
      	
      	#ifdef	REST_PLU_FUNC
      	&&(do_menu_flag==0)
      	#endif
      	
      	)
      { /** do cash **/
         InCmd=KD_CASH;
         numcnt=0;
         Do_Cash();
      }
      else
      {
      	if(CurrMode != TRAINING)
         	continue_sale_flag=0xAA;
      }
   }
}


/************************************************************************/
void Do_Void(void)
{
   if(!NewTrans){errorType(ERR_SALE_FNSH);return;}
   if(Cash_flag){errorType(ERR_PAY_NO_END);return;}
   if((RM_flag) || (Mul_flag))
   	{errorType(ERR_KEY_SEQ);return;}

   if(!numcnt)
   {
      if(lastincmd == KD_AMOUNT)		/* Used to the open PLU void */
      {
			Lcm_Disp_Str( Void_Amount, LCM_LINE_2, ALIGN_LEFT, FALSE);
         tmp_count = 1*1000;
         Void_flag = 1;
         InCmd = KD_AMOUNT;
      }
      if(Void_flag)			/* Press the VOID key again, do nothing */
         return;

      InCmd = KD_EC;			/* No digit input, equal to the EC key */
      Do_EC();
   }
   else
   {
      if(lnum != 0)    		/* Use the input price void operation */      {
			Lcm_Disp_Str( Void_Amount, LCM_LINE_2, ALIGN_LEFT, FALSE);
         Void_Mode = 0;
         tmp_price = lnum;
         tmp_count = 1*1000;
      }
      else						/* If the input number is 0, used to VOID the preset price */
      {
//			tmp_price = 0;
//			Void_Mode = 1;		/* The DEPT VOID use the preset void mode */
      	if(numcnt == 1)
      	{
				Lcm_Disp_Str( Void_Amount, LCM_LINE_2, ALIGN_LEFT, FALSE);
	      	tmp_price = 0;
	         Void_Mode = 1;			/* The DEPT VOID use the preset void mode */
	      }
	      else if(numcnt == 2)					/* 00 + [VOID] + [SUBTTL] ==> [TRANS VOID] */
	      {
				if(!sysflag->tax_shift_mode)
					Clr_Tax_Flag();
				if(Cash_flag){errorType(ERR_PAY_NO_END);return;}
				if(!NewTrans){errorType(ERR_SALE_FNSH);return;}
				if((Void_flag) || (RM_flag) || (Mul_flag))
					{errorType(ERR_KEY_SEQ);return;}
					
				Lcm_Disp_Str( Trans_Void, LCM_LINE_2, ALIGN_LEFT, FALSE);
				
				Clr_Period();
		      Disp_Spec_Period();			/* Dispaly the special period */
				if(Wait_Sure(Disp_Sure) == NG)
	      	{
	      		bellcnt = 150;
	      		Clr_Dsp_Data();
	      		RightDisp(0, sysflag->sysdots);
	      		return;
	      	}
	      	else // Wait_Sure(Disp_Sure) == OK
	      	{
	      		Do_TSVD();
	      		return;
	      	}
	      }
	      else
	      {
				if(!sysflag->tax_shift_mode)
					Clr_Tax_Flag();
	      	errorType(ERR_DIGIT_ILLEGAL);
	      	return;
	      }
      }
      Tmp_PLU_VOID_Idx = lnum;		/* The input number may be the PLU index number */
      Void_flag = 1;
   }
}

/**********************************************************************/
void Do_RM(void)
{
	if(Cash_flag)
	{
		errorType(ERR_PAY_NO_END);
		numcnt = 0;
		return;
	}
	if(Void_flag)		/* If the last mode is VOID mode, error */
	{
		errorType(ERR_KEY_SEQ);
		numcnt = 0;
		return;
	}
	Lcm_Disp_Str( RM_Operation ,LCM_LINE_2, ALIGN_LEFT, FALSE);
	RM_flag = 1;
}


/***********************************************************************/
void Do_Rfnd(void)
{
    word Idx;
    byte flag;
    byte plink;				/* The PLU link department index number */
    long bak_price;
    long last_amount;
    byte i;
    #ifdef	REST_PLU_FUNC
    byte id_order; 
    id_order=TS_NULL;
    #endif

    if(Cash_flag)	/* The payment not end */
        {errorType(ERR_PAY_NO_END);return;}
    if(!NewTrans)	/* No new transaction */
        {errorType(ERR_SALE_FNSH);return;}
    if((Void_flag) || (RM_flag))		/* If the last mode is VOID mode or the RM mode, error */
        {errorType(ERR_KEY_SEQ);return;}
    if(Chk_Buff_Full() == NG)
        return;

    flag = refund.flag;
    if(!numcnt)
        lnum = refund.price;
    bak_price = lnum;			/* Get the price */
    
    if(Mul_flag == 0)
    {
        tmp_count = 1000;		/* Get the quantity */
        if((lnum > tmpvars.subtotal) || (lnum == 0))
            { errorType(ERR_DIGIT_ILLEGAL);return; }
    }
    else
    {
        if(tmp_count > MAXQUNTY)
            {errorType(ERR_XTIME_QTY);return;}
        lnum = Sale_Mul(lnum, sysflag->sysdots, tmp_count, 3, sysflag->xCount_round, sysflag->sysdots);
        if((lnum > tmpvars.subtotal) || (lnum == MIN_SIGNED_LONG) || (lnum < 0))
            {errorType(ERR_DIGIT_ILLEGAL);return;}
    }
    if(((tmp_count + report.RF_Item_Qty)/1000 > MAXRFTCNT) 
        ||  ((tmp_count + PTD_report.RF_Item_Qty)/1000 > MAXRFTCNT))
        {errorType(ERR_DIGIT_ILLEGAL);return;}
    if(lnum > MAX_RFND_PRICE)
        {errorType(ERR_DIGIT_ILLEGAL);return;}

    trans.price = bak_price;
    trans.count = tmp_count;
    trans.amount = lnum;
    if(Subt_Press_Flag)		/* Sub refund operation */
    {
        if(flag == 0)			/* Not support the sub total refund function */
            {errorType(ERR_FLAG_FUNCTION);return;}

        transbuff[TnsBf_Len].ID = TS_RF_SUBT;
        transbuff[TnsBf_Len].price = -trans.price;		/* Set it a negative value */
        transbuff[TnsBf_Len].quantity = trans.count;
        transbuff[TnsBf_Len].nth = 0;				/* No used */
        transbuff[TnsBf_Len].flag = (sysflag->xCount_round)<<4;
        TnsBf_Len ++;
    }
    else				/* Item refund operation */
    {
        if(flag == 1)
            {errorType(ERR_FLAG_FUNCTION);return;}
      #ifdef	REST_PLU_FUNC
        id_order = get_last_oper_id();
      #endif
      #ifdef	REST_PLU_FUNC
        if((id_order != TS_DEPT) && (id_order != TS_PLU))
      #else
        if(((transbuff[TnsBf_Len - 1].ID&0x1F) != TS_DEPT) && ((transbuff[TnsBf_Len - 1].ID&0x1F) != TS_PLU))
        	/* The last operation is not the DEPT or PLU */
      #endif
        	/* The last operation is not the DEPT or PLU */
            {errorType(ERR_KEY_ILLEGAL);return;}
      #ifdef	REST_PLU_FUNC
        last_amount = Sale_Mul(transbuff[id_order_posi].price, sysflag->sysdots, transbuff[id_order_posi].quantity, 
        				  3, (transbuff[id_order_posi].flag)>>4, sysflag->sysdots);		/* Get the last transaction amount */
      #else
        last_amount = Sale_Mul(transbuff[TnsBf_Len - 1].price, sysflag->sysdots, transbuff[TnsBf_Len - 1].quantity, 
        				  3, (transbuff[TnsBf_Len - 1].flag)>>4, sysflag->sysdots);		/* Get the last transaction amount */
      #endif
        if(trans.amount > last_amount)			/* The refund amount is larger than the last transaction amount */
            {errorType(ERR_RFND_OVER);return;}

        if((transbuff[TnsBf_Len - 1].ID&0x1F) == TS_DEPT)
            transbuff[TnsBf_Len].ID = TS_RF_ITEM_DEPT;
        else
            transbuff[TnsBf_Len].ID = TS_RF_ITEM_PLU;
        transbuff[TnsBf_Len].price = -trans.price;		/* Set it a negative value */
        transbuff[TnsBf_Len].quantity = trans.count;
        transbuff[TnsBf_Len].nth = trans.nth;
        transbuff[TnsBf_Len].flag = (sysflag->xCount_round)<<4;
        if(sysflag->Tax_System)			/* Tax mode */
        {
            for(i = 0; i < MAX_TAX_NUM; i++)
                transbuff[TnsBf_Len].flag |= TaxFlag[i]<<i;
        }
        else			/* VAT mode */
        {
            if((transbuff[TnsBf_Len - 1].ID&0x1F) == TS_DEPT)
                transbuff[TnsBf_Len].flag |= (dept[trans.nth].pflag) & (0x0F);
            else
            {
                plink = plu[trans.nth].plink;
                transbuff[TnsBf_Len].flag |= (dept[plink - 1].pflag) & (0x0F);
            }
        }
        TnsBf_Len ++;
    }

   #ifdef AUTO_PER		/* Support the department auto percent function */
    Auto_Per_Flag = 0;
   #endif /* End AUTO_PER */

    Clr_Dsp_Data();

    Lcm_Disp_Desc(refund.desc, NO, LCM_LINE_2 ,ALIGN_LEFT, FALSE);

    RightDisp(-trans.amount, sysflag->sysdots);
    Sale_Prn(transbuff[TnsBf_Len - 1]);
    Update_Tmpvars(transbuff[TnsBf_Len - 1], POSITIVE);
    Mul_flag = 0;
}

/*************************************************************/
/**---------------------------------------------------**
 ** processing for percent + and percent -            **
 **---------------------------------------------------**/
void Do_Per(void)
{
    byte flag;
    byte plink;		/* The PLU link DEPT index number */
    long tmp;
    byte i;
   #ifdef	REST_PLU_FUNC
    byte id_order;

    id_order=TS_NULL;
   #endif

    if(Cash_flag)	/* The payment not end */
        {errorType(ERR_PAY_NO_END);return;}
    if(!NewTrans)	/* No new transaction */
        {errorType(ERR_SALE_FNSH);return;}
    if((Void_flag) || (RM_flag) || (Mul_flag))
        {errorType(ERR_KEY_SEQ);return;}
    if(numcnt>5)   /* Accept the manual input rate */
        {errorType(ERR_DIGIT_ILLEGAL);return;}
    if(Chk_Buff_Full() == NG)
        return;
    #ifdef AUTO_PER			/* Support the department auto percent function */
    if(Auto_Per_Flag == 1)
        {errorType(ERR_KEY_ILLEGAL);return;}
    #endif /* End AUTO_PER */

    if(Subt_Press_Flag == 0)			/*  Item percent operation */
    {
        #ifdef	REST_PLU_FUNC
        id_order = get_last_oper_id();
        #endif
        #ifdef	REST_PLU_FUNC
        if((id_order != TS_DEPT) && (id_order != TS_PLU))
        #else
        if(((transbuff[TnsBf_Len - 1].ID&0x1F) != TS_DEPT) && ((transbuff[TnsBf_Len - 1].ID&0x1F) != TS_PLU))
        #endif
        		/* The last operation is not the DEPT or PLU */
            {errorType(ERR_KEY_ILLEGAL);return;}
        /** percent process **/
        if(numcnt)
            Per_Rate = lnum*getLong(3-dec_cnt);			/* Adjust, for the percentage rate has 3 decimal points */
        else
            Per_Rate = percent[per_idx].rate;

        flag = percent[per_idx].flag;
        if((flag&0x02)==0)		/* after item is allow */
        {
            if(Per_Rate == 0 || Per_Rate > MAX_PER_VALUE)
            {
                errorType(ERR_PER_RATE_ZERO);
                return;
            }
        }
        else
        {
            errorType(ERR_FLAG_FUNCTION);
            return;
        }

        lnum = trans.amount;
        per_tmp = Sale_Mul(((flag&0x01)==0)?lnum:-lnum, sysflag->sysdots, Per_Rate, 5, percent[per_idx].round, sysflag->sysdots);
        if(((percent[per_idx].flag)&0x01)==0)				/* Only +% need this judge */
        {
            if((per_tmp+tmpvars.netamt)>MAXCASH)
            {
                errorType(ERR_TRANS_AMT);
                return;     
            }
        }
        /** calculation tax **/
        if(sysflag->Tax_System)
        {
            tmp = 0;
            for(i =0; i< MAX_TAX_NUM; i++)
                tmp += caltax(TaxFlag[i],i,trans.amount);
        }
        else
            tmp = 0;
        if(tmp+trans.amount+tmpvars.netamt>MAXCASH)
            {errorType(ERR_TRANS_AMT);return;}
        trans.amount=per_tmp;

        if((transbuff[TnsBf_Len - 1].ID&0x1F) == TS_DEPT)
            transbuff[TnsBf_Len].ID = TS_PER_ITEM_DEPT;
        else
            transbuff[TnsBf_Len].ID = TS_PER_ITEM_PLU;
        transbuff[TnsBf_Len].ID |= per_idx<<5;
        transbuff[TnsBf_Len].price = trans.amount;
        if((flag&0x01)==0)
            transbuff[TnsBf_Len].quantity = Per_Rate;			/* +% */
        else
            transbuff[TnsBf_Len].quantity = -Per_Rate;		/* -% */
        transbuff[TnsBf_Len].nth = trans.nth;
        transbuff[TnsBf_Len].flag = (percent[per_idx].round)<<4;					/* The auto percent operations roundings */
        if(sysflag->Tax_System)			/* Tax mode */
        {
            for(i =0; i < MAX_TAX_NUM; i++)
                transbuff[TnsBf_Len].flag |= (TaxFlag[i]<<i);
        }
        else			/* VAT mode */
        {
            if(transbuff[TnsBf_Len - 1].ID == TS_PLU)
            {
                plink =

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -