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

📄 sale1.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
   if(Void_flag)				/* The VOID mode */
   {
   	if(trans.amount > calPrtAmt(PLU,ch))		/* Judge the VOID amount is larger than the buffer amount or not */
         {errorType(ERR_VOID_OVER); return(NOTOK);}
      if(maxcheck(plink-1,PLU) == NOTOK)				/* Update the Department data */
      	return (NOTOK);
      TnsBf_Len --;			/*** New add ***/

      transbuff[TnsBf_Len].ID = TS_VD_PLU;			/* PLU VOID operation */
		transbuff[TnsBf_Len].price = -trans.price;	/* Set it a negative value */
	   transbuff[TnsBf_Len].quantity = 1*1000;		/* Set 1 quantity */
   }
   else if(RM_flag)		/* The RM mode */
   {
   	maxcheck(plink-1,PLU);
   	TnsBf_Len --;			/*** New add ***/

      transbuff[TnsBf_Len].ID = TS_RM_PLU;			/* PLU RETURN operation */
		transbuff[TnsBf_Len].price = -trans.price;	/* Set it a negative value */
	   transbuff[TnsBf_Len].quantity = trans.count;	/* The quantity is always negative */
   }
   else						/* The normal press PLU mode */
   {
      if(maxcheck(plink-1,PLU) == NOTOK)				/* Update the Department data */
      	return (NOTOK);
      TnsBf_Len --;			/*** New add */

      transbuff[TnsBf_Len].ID = TS_PLU;
		transbuff[TnsBf_Len].price = trans.price;		/* Positive value */
	   transbuff[TnsBf_Len].quantity = trans.count;
   }
   transbuff[TnsBf_Len].nth = ch;
   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 */
		transbuff[TnsBf_Len].flag |= (dept[plink - 1].pflag) & (0x0F);
   TnsBf_Len ++;
   if(!NewTrans)			/* Is the new transaction, store the tax/VAT rate and the tax/VAT mode */
   	Update_TVAT_Buff();

   if(CurrMode == REGISTER)
   {
		Set_Rpt_Flag(RPT_PLU_DAILY);
		#ifdef	PLU_PTD_RPT
		Set_Rpt_Flag(RPT_PLU_PTD);
		#endif
	}
   #ifdef STOCK		/* Spport the stock function */
   
   #ifdef	REST_PLU_FUNC
   if(do_menu_flag==0)
   #endif
   	{
	   if((sysflag->PLU_Stock_Flag == 1) && (CurrMode == REGISTER))		/* Not in the training mode */
	   {
		   if(calTotStk(ch) < 0)
		   {
		   	bellcnt = 150;			/* Sound a voice */
		   	Prompt_Stock_Empty();
		   }
		}
	}
   #endif /* End STOCK */
   #ifdef AUTO_PER			/* Support the department auto percent function */
   Auto_Per_Flag = 0;
   #endif /* End AUTO_PER */
   return (OK);
}


/*****************************************************************
*  PLU key input when Registration mode 
*****************************************************************/
void Do_PLU(void)
{
   byte plink=0;			/* Store the PLU link department */
   byte pflag;			/* Store the PLU linked department's flag */
   byte tmp;			/* The temporary variable */
   word Idx;			/* The PLU index number */
   long mul_price;	/* Store the calculate price */
   byte i, j;
#ifdef	REST_PLU_FUNC
   word tmp_idx;
   byte id_order;
   byte plu_length;
	byte qty[MAX_LENGTH_15+1];
	byte len;

	id_order=TS_NULL;
	plu_length=0;
#endif

   if(Cash_flag)
   	{errorType(ERR_PAY_NO_END);return;}		/* The payment is not end, error */
   if(numcnt || (Void_flag == 1))  	/** manual price processing **/
   			/* When the VOID key press, can not to input the PLU number again */
   {
      if((pluenflag == 0) && (numcnt != 0) && (Void_flag == 1))
         {errorType(ERR_KEY_SEQ); return;}
      if((Void_flag == 1) && (numcnt == 0))
         lnum = Tmp_PLU_VOID_Idx;
      if((lnum == 0) || (lnum > Max_Plu_No))
      	{errorType(ERR_DIGIT_ILLEGAL);return;}

      Idx = (word)(lnum-1);		/* Get the PLU index number */
#ifdef	REST_PLU_FUNC
      if(plu[Idx].attr.inht == 0)
		{
			errorType(ERR_PLU_ATTR);
			return;
		}
		if((plu[Idx].attr.mode==PLU_DESC)||(plu[Idx].attr.mode==PLU_GIFT))
		{
			errorType(ERR_NORMAL_ATTR); 
			return;
		}
		store_plu_index=Idx; 
#endif
      if( get_plu_price(Idx) == NOTOK)
         {errorType(ERR_ZERO_TRANS);return;}
      plink = plu[Idx].plink;
		if((lnum > sysflag->HaloNum) || (lnum >= getLong(dept[plink - 1].Hdlo)))
      	{errorType(ERR_HALO);return;}

      if(Mul_flag)			/* XTime pressed */
      {   
	   	if(tmp_count > MAXQUNTY)
	   		{errorType(ERR_XTIME_QTY);return;}
	   	if(sysflag->wgt_bar.reg_flag)
	   	{
	   		mul_price = sysflag->wgt_bar.reg_amount;
	   		sysflag->wgt_bar.reg_flag = 0;
	   	}
	   	else
	   	{
				mul_price = Sale_Mul(lnum, sysflag->sysdots, tmp_count, 3, sysflag->xCount_round, sysflag->sysdots);
			}
			if((mul_price > sysflag->HaloNum) || (mul_price == MIN_SIGNED_LONG) || (mul_price < 0))
         	{errorType(ERR_HALO);return;}
         trans.price = lnum;
         trans.count = tmp_count;
         trans.amount = mul_price;
      }
      else
      {
         if(sysflag->wgt_bar.reg_flag)
         {
         	trans.price = sysflag->wgt_bar.reg_amount;
         	sysflag->wgt_bar.reg_flag = 0;
         }
         else
         {
	      	trans.price = lnum;
	      }
         trans.count = 1*1000;		/* For the quantity has 3 decimal points */
         trans.amount = trans.price;
      }
#ifdef	REST_PLU_FUNC
		store_trans_price = trans.price;
      menu_sub_total+=((Void_flag||RM_flag)?-1:1)*trans.amount;
      menu_sub_count+=trans.count;
#endif
      
      pflag=dept[plink-1].pflag;			/* Get the linked department's flag */
      if(sysflag->Tax_System)
      {
      	if(!Tax_Emp_Flag)
      	{
            ltmp = 0;
            for(i = 0; i < MAX_TAX_NUM; i++)
            {
                TaxFlag[i] = (((pflag>>i)&0x01)^shift_flag[i]);
                ltmp += caltax(TaxFlag[i],i,trans.amount);
            }
//	         Tax1Flag=(pflag&0x01)^shift1_flag;
//	         Tax2Flag=((pflag>>1)&0x01)^shift2_flag;
//	         Tax3Flag=((pflag>>2)&0x01)^shift3_flag;
//	         ltmp=caltax(Tax1Flag,0,trans.amount)+caltax(Tax2Flag,1,trans.amount)+caltax(Tax3Flag,2,trans.amount);
	      }
	      else
	      {
              ltmp = 0;
              for(i = 0; i < MAX_TAX_NUM; i++)
              {
                  TaxFlag[i] = 0;
              }
//	      	Tax1Flag = Tax2Flag = Tax3Flag = 0;
//	      	ltmp = 0;
	      }
			if(!sysflag->tax_shift_mode)
         	Clr_Tax_Flag();
      }
      else
      	ltmp = 0;

		#ifdef	REST_PLU_FUNC
		plu_length=cal_sale_plu_length(Idx);
/////////////////*calculate the length of menu*/////////////////////////
		if(Chk_MenuBuff_Full(plu_length) == NG)
			return;
////////////////////////////////////////////////////////////////////////
		#endif

    /*** maxcheck for PLU processing  **/
		if(PLUcheck(Idx) == NOTOK) return;		/* The PLUcheck contain the maxcheck */
		Clr_Dsp_Data();
      if(Mul_flag)
      {
         Item_Mode = MULT;
			Lcm_Disp_Desc(plu[Idx].desc, NO ,LCM_LINE_2 ,ALIGN_LEFT , FALSE);
			Qty_Adjust(tmp_count);
//			len=LongAndDot2Str(adj_num,adj_dots, qty ,1,0,0,0);
//			VFDDisplay(qty+MAX_LENGTH_15-len, NOTCLEARD, LEFT);
      }
      else 
      {
         Item_Mode = SNGL;
         repcnt =1;
//			Insert_Num((Idx+1)/100,0);
//			tmp = (Idx+1)%100;
//			Insert_Num(tmp/10,1);
//			Insert_Num(tmp%10,2);

			//Insert_Num(plink/10,0);					/* Dispaly the PLU linked department number */
			//Insert_Num(plink%10,1);
			Lcm_Disp_Desc(plu[Idx].desc, NO ,LCM_LINE_2 ,ALIGN_LEFT , FALSE);
			Insert_Num( repcnt/10 ,0);
			Insert_Num( repcnt%10 ,1);
      }
      RightDisp(((Void_flag||RM_flag)?-1:1)*trans.amount, sysflag->sysdots);
   }

   		/* PLU repeat operation */
   else if((lastincmd==InCmd)&&(Item_Mode == SNGL)&&(RM_flag == 0)&&(TnsBf_Len != 0)
   #ifdef	REST_PLU_FUNC
				&& (get_last_oper_id() == TS_PLU))
 #else
   		&&((transbuff[TnsBf_Len-1].ID&0x1F) == TS_PLU))
 #endif
   {
   	#ifdef	REST_PLU_FUNC
		Idx = store_plu_index;

#else
 	Idx = transbuff[TnsBf_Len - 1].nth;
#endif
	   #ifdef AUTO_PER		/* Support the department auto percent function */
	   if(Auto_Per_Flag == 1)
	   	trans.amount = bak_trans_amount;
	   else
	   #endif /* End AUTO_PER */
#ifdef	REST_PLU_FUNC
			trans.amount = store_trans_price;		/* The amount is equal to the price */
#else
			trans.amount = transbuff[TnsBf_Len - 1].price;
#endif
      trans.price = trans.amount;
		trans.count = 1*1000;
      if(sysflag->Tax_System)
      {
         ltmp = 0;
         for(i =0; i < MAX_TAX_NUM; i++)
            ltmp += caltax(TaxFlag[i],i,trans.amount);
      }
      else
      	ltmp = 0;
      /*** maxcheck for PLU processing  **/
      #ifdef	REST_PLU_FUNC
      plu_length=cal_sale_plu_length(Idx);

		if(Chk_MenuBuff_Full(plu_length) == NG)                
			return;   
		#endif
		if(PLUcheck(Idx) == NOTOK) return;		/* The PLU check contain the maxcheck */

      repcnt++;
      //if(repcnt==10)
      if(repcnt ==100)
      	repcnt=0;
      Item_Mode = SNGL;
		Clr_Dsp_Data();
//		Insert_Num((Idx+1)/100,0);
//		tmp = ((word)(Idx+1))%100;
//		Insert_Num(tmp/10,1);
//		Insert_Num(tmp%10,2);
//		Insert_Num(repcnt,3);

      //plink=plu[Idx].plink;
		//Insert_Num(plink/10,0);
		//Insert_Num(plink%10,1);
		//Insert_Num(repcnt,2);
		Lcm_Disp_Desc( plu[Idx].desc,NO,LCM_LINE_2,ALIGN_LEFT, FALSE);
		Insert_Num( repcnt/10,0);
		Insert_Num( repcnt%10,1);
		
      RightDisp(trans.amount, sysflag->sysdots);
   }
   else
   {
      errorType(ERR_KEY_ILLEGAL);
      return; 
   }

  /** print and display processing **/
   trans.nth=Idx;

	Sale_Prn(transbuff[TnsBf_Len - 1]);
	Update_Tmpvars(transbuff[TnsBf_Len - 1], POSITIVE);

#ifdef	REST_PLU_FUNC
	Idx++;
	for(j=0;j<MAX_PLUTAB_NO;j++)                         /*DESC PLU*/
	{
		if(Idx==plu_relation_tab[j].mainplu)
		{
			tmp_idx=plu_relation_tab[j].slaveplu;
			if(tmp_idx==0)              /*if the slave plu=0 ,ignore*/
				continue;
			if(plu[tmp_idx-1].attr.inht==0)
			{
//				errorType(ERR_PLU_ATTR);
//				return;
				continue;
			}
			if(plu[tmp_idx-1].attr.mode==PLU_DESC)
			{ 
//				if(Chk_Buff_Full() == NG)
//					return;      
				transbuff[TnsBf_Len].ID = TS_PLU_DESC;
			   transbuff[TnsBf_Len].nth = tmp_idx-1;
			   TnsBf_Len ++;
				Sale_Prn(transbuff[TnsBf_Len - 1]);				
			   Update_Tmpvars(transbuff[TnsBf_Len - 1], POSITIVE);
			}            			
		}
	}
	if(Void_flag==0)
	{
		for(j=0;j<MAX_PLUTAB_NO;j++)         /*gift PLU*/
		{
			if(Idx==plu_relation_tab[j].mainplu)
			{
				tmp_idx=plu_relation_tab[j].slaveplu;
				if(tmp_idx==0)              /*if the slave plu=0 ,ignore*/
					continue;
				if(plu[tmp_idx-1].attr.inht==0)
				{
//					errorType(ERR_PLU_ATTR);
//					return;
					continue;
				}
				if(plu[tmp_idx-1].attr.mode==PLU_GIFT)
				{
//					if(Chk_Buff_Full() == NG)
//						return; 
					if(RM_flag)		/* The RM mode */
				   {				
				      transbuff[TnsBf_Len].ID = TS_RM_PLU_GIFT;			/* PLU RETURN operation */
					   transbuff[TnsBf_Len].quantity = -trans.count;	/* The quantity is always negative */
				   }
				   else						/* The normal press PLU mode */
				   {
						transbuff[TnsBf_Len].ID = TS_PLU_GIFT;
					   transbuff[TnsBf_Len].quantity = trans.count;	
					}
					transbuff[TnsBf_Len].nth = tmp_idx-1;	 	

				   TnsBf_Len ++;		
					Sale_Prn(transbuff[TnsBf_Len - 1]);					
				   Update_Tmpvars(transbuff[TnsBf_Len - 1], POSITIVE);	  
				}            			
			}
		}
	}
	#endif


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

   #ifdef AUTO_PER			/* Support the department auto percent function */
   #ifdef	REST_PLU_FUNC
 	id_order = TS_PLU;

⌨️ 快捷键说明

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