TEST(PaydayTransactionForCommisionedEmployeeTest, PayrollTest) { ((DatabaseProxy *)getInstance())->ClearEmployees(); int empid = 101; Date date(2012, 10, 10); double amount = 1000.00; AddCommisionEmployee ace(empid, "name02", "Home6", 1000.00, 0.5); ace.Execute(); SalesReceiptTransaction srt(empid, date, amount); srt.Execute(); Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(empid); PaymentClassification* pc = e->GetPaymentClassification(); EXPECT_TRUE(pc != 0); CommisionClassification* cc = dynamic_cast<CommisionClassification*>(pc); EXPECT_TRUE(cc != 0); SalesReceipt receipt(cc->GetSalesReceipt(date)); EXPECT_TRUE(receipt.GetAmount() == amount); Date paydate(2011, 2, 14); PaydayTransaction pt(paydate); pt.Execute(); PayCheck *check = pt.GetPayCheck(empid); EXPECT_TRUE(check->GetName() == "name02"); EXPECT_EQ(check->GetGrossPay(), 1500.00); EXPECT_EQ(check->GetDeductions(), 0.0); EXPECT_EQ(check->GetNetPay(), 1500.00); }
void DiscoPrivate::_q_received(const Jreen::IQ &iq) { if(iq.subtype() != IQ::Get) return; QList<Payload*> payloads; if(const Disco::Info::Ptr info = iq.payload<Disco::Info>()) payloads << new Disco::Info(info->node(), identities, features, form); if(const Disco::Items::Ptr items = iq.payload<Disco::Items>()) payloads << new Disco::Items(items->node()); if(iq.payload<SoftwareVersion>()) payloads << new SoftwareVersion(software_name, software_version, os); if (!payloads.isEmpty()) { iq.accept(); IQ receipt(IQ::Result, iq.from(), iq.id()); foreach (Payload *payload, payloads) receipt.addExtension(payload); client->send(receipt); } }
TEST(SalesReceiptTransactionTest, PayrollTest) { int empid = 6; Date date(2012, 10, 10); double amount = 1000.00; AddCommisionEmployee ace(empid, "Test6", "Home6", 1000.00, 0.5); ace.Execute(); SalesReceiptTransaction srt(6, date, amount); srt.Execute(); Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(empid); PaymentClassification* pc = e->GetPaymentClassification(); EXPECT_TRUE(pc != 0); CommisionClassification* cc = dynamic_cast<CommisionClassification*>(pc); EXPECT_TRUE(cc != 0); SalesReceipt receipt(cc->GetSalesReceipt(date)); EXPECT_TRUE(receipt.GetAmount() == amount); }
void int_sci0_rxi0(void) { receipt(&com[0]); }
void int_sci1_rxi1(void) { receipt(&com[1]); }
void quit( int noremove /* don't remove system mailbox, trunc it instead */ ) { int mcount, p, modify, autohold, anystat, holdbit, nohold, fd; FILE *ibuf, *obuf, *fbuf, *readstat; register struct message *mp; register int c; char *id; int appending; char *mbox = Getf("MBOX"); /* * If we are read only, we can't do anything, * so just return quickly. */ mcount = 0; if (readonly) return; /* * See if there any messages to save in mbox. If no, we * can save copying mbox to /tmp and back. * * Check also to see if any files need to be preserved. * Delete all untouched messages to keep them out of mbox. * If all the messages are to be preserved, just exit with * a message. * * If the luser has sent mail to himself, refuse to do * anything with the mailbox, unless mail locking works. */ #ifndef CANLOCK if (selfsent) { printf(gettext("You have new mail.\n")); return; } #endif /* * Adjust the message flags in each message. */ anystat = 0; autohold = value("hold") != NOSTR; appending = value("append") != NOSTR; holdbit = autohold ? MPRESERVE : MBOX; nohold = MBOXED|MBOX|MSAVED|MDELETED|MPRESERVE; if (value("keepsave") != NOSTR) nohold &= ~MSAVED; for (mp = &message[0]; mp < &message[msgCount]; mp++) { if (mp->m_flag & MNEW) { receipt(mp); mp->m_flag &= ~MNEW; mp->m_flag |= MSTATUS; } if (mp->m_flag & MSTATUS) anystat++; if ((mp->m_flag & MTOUCH) == 0) mp->m_flag |= MPRESERVE; if ((mp->m_flag & nohold) == 0) mp->m_flag |= holdbit; } modify = 0; if (Tflag != NOSTR) { if ((readstat = fopen(Tflag, "w")) == NULL) Tflag = NOSTR; } for (c = 0, p = 0, mp = &message[0]; mp < &message[msgCount]; mp++) { if (mp->m_flag & MBOX) c++; if (mp->m_flag & MPRESERVE) p++; if (mp->m_flag & MODIFY) modify++; if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) { id = hfield("message-id", mp, addone); if (id != NOSTR) fprintf(readstat, "%s\n", id); else { id = hfield("article-id", mp, addone); if (id != NOSTR) fprintf(readstat, "%s\n", id); } } } if (Tflag != NOSTR) fclose(readstat); if (p == msgCount && !modify && !anystat) { if (p == 1) printf(gettext("Held 1 message in %s\n"), mailname); else printf(gettext("Held %d messages in %s\n"), p, mailname); return; } if (c == 0) { writeback(noremove); return; } /* * Create another temporary file and copy user's mbox file * therein. If there is no mbox, copy nothing. * If s/he has specified "append" don't copy the mailbox, * just copy saveable entries at the end. */ mcount = c; if (!appending) { if ((fd = open(tempQuit, O_RDWR|O_CREAT|O_EXCL, 0600)) < 0 || (obuf = fdopen(fd, "w")) == NULL) { perror(tempQuit); return; } if ((ibuf = fopen(tempQuit, "r")) == NULL) { perror(tempQuit); removefile(tempQuit); fclose(obuf); return; } removefile(tempQuit); if ((fbuf = fopen(mbox, "r")) != NULL) { while ((c = getc(fbuf)) != EOF) putc(c, obuf); fclose(fbuf); } fflush(obuf); if (fferror(obuf)) { perror(tempQuit); fclose(ibuf); fclose(obuf); return; } fclose(obuf); if ((fd = open(mbox, O_RDWR|O_CREAT|O_TRUNC, MBOXPERM)) < 0 || (obuf = fdopen(fd, "r+")) == NULL) { perror(mbox); fclose(ibuf); return; } if (issysmbox) touchlock(); } else { /* we are appending */ if ((fd = open(mbox, O_RDWR|O_CREAT, MBOXPERM)) < 0 || (obuf = fdopen(fd, "a")) == NULL) { perror(mbox); return; } } for (mp = &message[0]; mp < &message[msgCount]; mp++) if (mp->m_flag & MBOX) { if (msend(mp, obuf, (int)value("alwaysignore") ? M_IGNORE|M_SAVING : M_SAVING, fputs) < 0) { perror(mbox); if (!appending) fclose(ibuf); fclose(obuf); return; } mp->m_flag &= ~MBOX; mp->m_flag |= MBOXED; if (issysmbox) touchlock(); } /* * Copy the user's old mbox contents back * to the end of the stuff we just saved. * If we are appending, this is unnecessary. */ if (!appending) { rewind(ibuf); c = getc(ibuf); while (c != EOF) { putc(c, obuf); if (ferror(obuf)) break; c = getc(ibuf); } fclose(ibuf); fflush(obuf); } trunc(obuf); if (fferror(obuf)) { perror(mbox); fclose(obuf); return; } fclose(obuf); if (mcount == 1) printf(gettext("Saved 1 message in %s\n"), mbox); else printf(gettext("Saved %d messages in %s\n"), mcount, mbox); /* * Now we are ready to copy back preserved files to * the system mailbox, if any were requested. */ writeback(noremove); }
int udp_ping(QStringList command) { qDebug() << "udp_ping(" << command.join(" ") << ")" << endl; qDebug() << "udp_ping(" << command.join(" ") << ")" << endl; /** * Check input */ QTextStream errorStream(stderr); if(command.size() != 3 || command.at(0)!="ping" || command.at(1)!="udp" ) { errorStream << "Error: udp_ping(" << command.join(" ") << ") is no valid call (ping udp <ip_address> <port> rzv|max|random|default)" << endl; return 1; } /** * <functionality> */ QByteArray byteArray; /** * CIP for "rzv" */ if(command.at(2)=="rzv") { qDebug() << "rzv" << endl; byteArray.append(QByteArray(42, '\0')); } /** * Sent via TCP */ QUdpSocket *udpSocket; udpSocket = new QUdpSocket(); QTextStream outStream(stdout); QString out; udpSocket->abort(); udpSocket->connectToHost("127.0.0.1", 22366); qDebug() << "waitForConnected!"; if (udpSocket->waitForConnected(5000)) { qDebug() << "Connected!"; } else { errorStream << "Error: udp_ping(" << command.join(" ") << "): No connection available!" << endl; return 1; } qDebug() << QString("BytesWritten: %1").arg(udpSocket->write(byteArray, byteArray.length())); udpSocket->flush(); int numRead = 0, numReadTotal = 0; char buffer[MAXMSG]; forever { numRead = udpSocket->read(buffer, MAXMSG); qDebug() << "read buffer: " << numRead; numReadTotal += numRead; if (numRead <= 0 && !udpSocket->waitForReadyRead(30)) break; } qDebug() << numReadTotal << " bytes red"; if(numReadTotal==-1) { errorStream << "Error: udp_ping(" << command.join(" ") << "): " << udpSocket->errorString() << endl; return 1; } else { for(int i=0; i < numReadTotal; i++) { qDebug() << QString("receipt[%1]: %2\n").arg(i).arg(buffer[i], 8, 2, QLatin1Char('0')) << endl;; } QByteArray receipt(buffer); qDebug() << "receipt.size(): " << receipt.size(); for(int i = 0; i < receipt.size();++i) { qDebug() << QString("receipt[%1]: %2\n").arg(i).arg(receipt.at(i), 8, 2, QLatin1Char('0')) << endl;; } qDebug() << "buffer: " << buffer; } udpSocket->disconnectFromHost(); udpSocket->close(); outStream << out << endl; return 0; }